It is currently Mon Apr 29, 2024 1:25 am


Create trees with wind effect

Any thing to do with Tree It, post and read about it here.
  • Author
  • Message
User avatar

Tomcat

  • Posts: 3
  • Joined: Sun Jan 08, 2023 12:47 am

Create trees with wind effect

PostSun Jan 08, 2023 1:23 am


Based on the Making trees tutorial.

This is not a tutorial, but rather a hint, a short note to a tutorial on creating trees. This tutorial suggests taking the tree model from SketchFab. But there is another way to do it. If you use the free program TreeIt (no need to register to download, for what a huge thank you to the author), you can skip the step "Paint with vertex colors" — the program will do it yourself.

The program is constantly updated. You can guess about the new version of the program, you can by the date of release.

The program has an additional library of trees.

Choose the desired type of tree and use settings to achieve a suitable result.

Next, the tree model is exported to .fbx

Godot 4 well understands the format .fbx

Image

The resulting file is placed in a scene and begin editing:

New Inherited Scene → Open Anyway

The scene will have several Tree_* nodes (Tree_0; Tree_1 etc.)

Need to go into each of these nodes

MeshInstance3D → Mesh → Surface 0 → Material → Vertex Color

Uncheck the box "Use as Albedo".

Image

And Convert to ShaderMaterial.

In the shader you need to add the lines from the tutorial the code to create the sway of the leaves . Replace them with the vertex block.

Only in the line :

Code: Select all
float strength = COLOR.r * sway_strength;


must be replaced by
Code: Select all
COLOR.r
(red channel) with
Code: Select all
COLOR.b
(blue). The point is that Tree It itself paints the tree to implement sway from the wind and you don't have to do it manually.

This section should look like this:

Code: Select all
uniform float sway_speed = 1.0;
uniform float sway_strength = 0.05;
uniform float sway_phase_len = 8.0;

void vertex() {
   UV=UV*uv1_scale.xy+uv1_offset.xy;
   float strength = COLOR.b * sway_strength;
   VERTEX.x += sin(VERTEX.x * sway_phase_len * 1.123 + TIME * sway_speed) * strength;
   VERTEX.y += sin(VERTEX.y * sway_phase_len + TIME * sway_speed * 1.12412) * strength;
   VERTEX.z += sin(VERTEX.z * sway_phase_len * 0.9123 + TIME * sway_speed * 1.3123) * strength;
}


By setting variables in the global uniform can change the strength of the wind across the scene.

It should look like this:

Image
"Curiosity killed the cat, but satisfaction brought it back"

Impheris

  • Posts: 39
  • Joined: Sun Oct 25, 2020 9:33 am

Re: Create trees with wind effect

PostTue Feb 14, 2023 6:01 pm

thank you for the info

Return to Tree It



cron