Description of packed SpeedTree (Wind) shader inputs

Looking for information about SpeedTreeWind.cginc inputs. Haven’t found any information on the net.

Specifically these:

CBUFFER_START(SpeedTreeWind)
    float4 _ST_WindVector;
    float4 _ST_WindGlobal;  // (_Time.y, ?, ?, ?)
    float4 _ST_WindBranch; // (_Time.y, ?, ?, ?)
    float4 _ST_WindBranchTwitch;
    float4 _ST_WindBranchWhip;
    float4 _ST_WindBranchAnchor;
    float4 _ST_WindBranchAdherences;
    float4 _ST_WindTurbulences;
    float4 _ST_WindLeaf1Ripple; // (_Time.y, ?, ?, ?)
    float4 _ST_WindLeaf1Tumble; // (_Time.z, ?, ?, ?)
    float4 _ST_WindLeaf1Twitch; // (?, ?, _Time.y, ?)
    float4 _ST_WindLeaf2Ripple; // (_Time.y, ?, ?, ?)
    float4 _ST_WindLeaf2Tumble; // (_Time.z, ?, ?, ?)
    float4 _ST_WindLeaf2Twitch; // (?, ?, _Time.y, ?)
    float4 _ST_WindFrondRipple; // (_Time.y, ?, ?, ?)
    float4 _ST_WindAnimation;
CBUFFER_END

Names give some idea, but what is actually packed inside those xyzw?
I do need to find every variable that sets time to modify it via my own variable instead.

EDIT:
Twitch has packed _Time as Z. This is what I was missing.

Replacing those commented values in shader code will stop time, if passed the Time.time with the accordance to the _Time (time / 20, time, time * 2, time *3).

Note that those values are approximate, and I don’t really know what values are used exactly. To my eye it’s pretty close, if not exact.

Leaves are alterations of 2 variants I think? But passing same time value for them seems to be nice solution. Although, if in doubt - pass additional offset for them.

I do not think there is any info about the calculation. It is generated by the hidden “Tree” component on the speedtrees and added to the MaterialPropertyBlock of the Renderer. This happens only when the renderer is visible in a camera.

1 Like

Yeah, I’ve figured that out. Maybe somebody from UT will shed some light on the parameters. (Somebody did worked on these shaders, right?)

I’ve almost figured it out, a bit confused why do they need so many time variables sent, if they simply could use one.

If you do figure it out it would be great if you could share :slight_smile:

Found out what I was missing. Twitch has Z as time as well. Updated OP with data for time.

Replacing those values will stop time, if passed the Time.time with the accordance to the _Time (time / 20, time, time * 2, time *3).

Note that those values are approximate, and I don’t really know what values are used exactly. To my eye it’s pretty close, if not exact.

Rest of the variables are probably packed with the animation / wind direction / tree data, which I don’t need to know anyway.

1 Like