Making trees

    The aim is to not focus on the modelling techniques (there are plenty of tutorials about that), but how to make them look good in Godot.

    I took this tree from SketchFab:

    ../../_images/tree_base.png

    The first thing you may want to do is to use the vertex colors to paint how much the tree will sway when there is wind. Just use the vertex color painting tool of your favorite 3D modelling program and paint something like this:

    This is a bit exaggerated, but the idea is that color indicates how much sway affects every part of the tree. This scale here represents it better:

    ../../_images/tree_gradient.png

    This is a simple example of a shader for leaves:

    Here, the texture is read, as well as a transmission color, which is used to add some back-lighting to the leaves, simulating subsurface scattering.

    This is the code to create the sway of the leaves. It’s basic (just uses a sinewave multiplying by the time and axis position, but works well). Notice that the strength is multiplied by the color. Every axis uses a different small near 1.0 multiplication factor so axes don’t appear in sync.

    Finally, all that’s left is the fragment shader:

    And this is pretty much it.

    The trunk shader is similar, except it does not write to the alpha channel (thus no alpha prepass is needed) and does not require transmission to work. Both shaders can be improved by adding normal mapping, AO and other maps.

    https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch16.html