Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

terrain - runtime created texture with mipmapping cause gray render errors

Discussion in 'Scripting' started by miniduck, Jun 2, 2013.

  1. miniduck

    miniduck

    Joined:
    Sep 27, 2012
    Posts:
    117
    Hi

    I'm creating a texture during runtime with mipmapping which is applied to terrain. In far distance it gives a weird grayish drawing error. Triangles here and there flickering at times.
    Works fine if mipmapping is disabled.
    Works fine if saving the texture to disk and reloading it using WWW.

    Any ideas how fix it properly?

    I'm using the latest Unity version.

    Basic code that cause the error.
    Code (csharp):
    1. Texture2D splat_texture = new Texture2D(512, 512, TextureFormat.RGB24, true); // mipmap set to true cause gray flicker render error in distance
    2.  
    3. // ... setpixels here
    4.  
    5. SplatPrototype splat_prot = new SplatPrototype();
    6. splat_prot.tileOffset = new Vector2(0, 0);
    7. splat_prot.tileSize = new Vector2(256, 256);
    8. splat_prot.texture = splat_texture;
    9. // splat_prot.texture = Instantiate(splat_texture) as Texture2D; // same error
    10.  
    11. // ... update splatprototypes on terrain
     
  2. codebeans

    codebeans

    Joined:
    Apr 7, 2014
    Posts:
    79
unityunity