No announcement yet.

In SpeedTree8 shader in Unity, please allow us to edit the CLIP value

  • Filter
  • Time
  • Show
Clear All
new posts

  • In SpeedTree8 shader in Unity, please allow us to edit the CLIP value

    The supplied shader looks great closeup. However, as the LOD moves away, the alpha gets worse, and the trees starts to look like a series of dots.
    To fix this, allow us to adjust the clip value. Currently, it's hardcoded like this:

    OUT.Alpha = color.a * IN.color.a;
    clip(OUT.Alpha - 0.3333);

    However, it produces way better results when the clip value is lower at lower LOD levels. I believe if you simply allowed us to adjust that "0.3333" value on the foliage, we will get significantly better results on lower LOD levels.

  • #2

    This problem occurs because when the opacity texture is downscaled into the mipmaps, it blurs the white and black parts, ending up grey (and closer, if not past, the alpha cutoff value).

    Adjusting the alpha cutoff on the shader will indeed help the trees in the distance by making it thicker, but it will also affect the tree up close, making the leaves thicker.

    Instead, you can adjust the problem where it occurs - in the mipmap generation. On the texture, make sure "mip maps preserve coverage" is enabled, and play with the cutoff value there. This will help the mipped opacity not go grey.

    Admittedly, Unity doesn't have a lot of controls for fiddling with the mip generation on textures (a min/max would be great). In the Modeler we have a bit of shader code that detects a lower mip being used and boosts the alpha. I will log to look into possibly adding this, or if that doesn't pan out, allow adjusting the alpha clip.

    Hope this helps


    • #3
      Edit: Somehow I missed that you were considering allowing us to specify clip. That would be great. Currently I am overriding the materials with a hand-edited version of the shader, and it does improve the visuals quite a bit.