Announcement

Collapse
No announcement yet.

[Unity 3D] SpeedTree Wind stops to work when MaterialPropertyBlock is applied

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

  • [Unity 3D] SpeedTree Wind stops to work when MaterialPropertyBlock is applied

    Hi,
    I am using Unity 3d / SpeedTree Shader in order to render some vegetation, and I wish to use a custom replacement shader to render the vegetation differently.
    So far I can use #include "SpeedTree8Common.cginc" and SpeedTreeVert(v); on my vertex program to render the wind movement.
    However, when I try to use MaterialPropertyBlock (on each material) to apply different features for my shader, the wind stops to work.
    Here is the function I am currently using to set a new float property to the material
    Code:
    private void ApplyMyCustomProperty(Renderer renderer)
    {
        MaterialPropertyBlock myPropertyBlock = new MaterialPropertyBlock();
        renderer.GetPropertyBlock(myPropertyBlock);
        myPropertyBlock.SetFloat("_CustomProperty", 0.75f);
        renderer.SetPropertyBlock(myPropertyBlock, 0);
    }

    Does anyone know how can I still use the SpeedTree Properties from my material and add a new property?


    Sincerely,
    Thomas
Working...
X