Announcement

Collapse
No announcement yet.

Custom Speedtree wind for Instanced Indirect Rendering (Unity)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom Speedtree wind for Instanced Indirect Rendering (Unity)

    I am using Instanced Indirect Rendering to control rendering of huge amounts of Speedtrees on the GPU. (Culling/lod selection/draw call submission performed entirely on GPU)
    This is able to render millions of trees at realtime framerates. However, in Unity there is no way to retrieve the wind values, for uploading to the GPU.

    The only way to use speedtree wind is by placing the speedtree models in the scene as game objects. Unfortunately this is only feasible for a few thousand trees and not suitable for large landscapes.
    Our game has large islands (8 to 10 square kilometers) and requires large amounts of foliage).

    We would like to use the speedtree wind, but there is no way currently to access the data.

    In a shader, there are values such as:

    float4 _ST_WindVector;
    float4 _ST_WindGlobal;
    float4 _ST_WindBranch;
    float4 _ST_WindBranchTwitch;
    float4 _ST_WindBranchWhip;
    float4 _ST_WindBranchAnchor;
    float4 _ST_WindBranchAdherences;
    float4 _ST_WindTurbulences;
    float4 _ST_WindLeaf1Ripple;
    float4 _ST_WindLeaf1Tumble;
    float4 _ST_WindLeaf1Twitch;
    float4 _ST_WindLeaf2Ripple;
    float4 _ST_WindLeaf2Tumble;
    float4 _ST_WindLeaf2Twitch;
    float4 _ST_WindFrondRipple;
    float4 _ST_WindAnimation;

    Which need to be set for correct wind, but the generation of these values are not exposed to the user as I assume it is all handled internally in Unity, and there is no way to retrieve it.

    Is the source code for this wind publicly available?
    It would be great to generate/upload the values ourselves.

    Wind in Unity also requires placing a wind zone, and only works in play mode. It would be great to remove these limitations by having full control over the wind values and when they are generated.




    Attached Files

  • #2
    Hello,

    There is a CPU component of wind from our SpeedTree SDK that runs in the engine. It maintains state and interpolates wind values as necessary to make those values you see in the shader. I don't know all the intricacies of rendering in Unity, but using instanced indirect, while allowing for faster drawing, will also go outside the built-in render loop that updates those. We don't currently have a C# version of that that you can drop into your assets, unfortunately.

    For the next version, SpeedTree v9, we're working on some wholly-GPU wind that might allow you to get this done more easily, with some caveats about not changing wind strength and direction. If you're interested, please contact [email protected], and we can discuss it.

    Comment

    Working...
    X