Search Unity

[Solved] Shiny Terrain in 5.0.1f1?

Discussion in 'General Graphics' started by vdeloso, Apr 22, 2015.

  1. vdeloso

    vdeloso

    Joined:
    Mar 4, 2015
    Posts:
    10
    So, I recently upgraded to 5.0.1f1 from 5.0.0f4 and noticed that my terrain has a shiny layer has been added. All of the terrain tiles we use are generated via script and are using the "Built In Standard" for the Base Terrain material. Running from the editor, I tried changing the material and noticed that the "Built In Legacy Diffuse" is the Material that removes the odd shiny effect. In the picture below, you can see where the Legacy looks correct and the adjacent terrain tiles have the shiny effect.

    shiny-terrain-5.PNG

    As a current workaround, I have a small, hidden terrain object in the scene with the correct material that I want to use. Then for all generated terrain tiles, I set the material type to the one from the corrected terrain game object's material type. Really not optimal... is there another way to programmatically reference the built-in materials?

    Manipulating the direction of the global lighting does not change the effect, neither does disabling lighting from Scene view.

    Another developer here has not upgraded yet (from 5.0.0f4) and does not encounter this rendering issue, so I can assume that it's something to do with the changes in the version that I am using.

    Is there a way for me to manipulate the Built In Standard material to not cause this shiny effect? Is this a known issue from the changes in 5.0.1? Or am I just stuck with using the Legacy Diffuse material for my terrain?

    Update: Also tested with 5.0.1p2 and the effect is still there.
     
    Last edited: Apr 27, 2015
  2. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    272
    Hi! You need to go to the 'Edit Textures' dialog and lower the smoothness value of your textures.
     
  3. vdeloso

    vdeloso

    Joined:
    Mar 4, 2015
    Posts:
    10
    I don't see a slider or anything that will let me modify the smoothness for a texture...
    shiny-edit.PNG

    All I am doing is setting a loaded image to the texture of a SplatPrototype for the terrain. I tried setting the splat.smoothness to 0, but the effect still shows.

    Code (CSharp):
    1. private void SetupSplatPrototype(TerrainTile target, Texture2D texture, float terrainSize)
    2. {
    3.     SplatPrototype splat = new SplatPrototype();
    4.     splat.texture = texture;
    5.     splat.smoothness = 0;
    6.     splat.tileSize = new Vector2(terrainSize, terrainSize);
    7.     target.Tile.terrainData.splatPrototypes = new SplatPrototype[] { splat };
    8. }
     
  4. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    272
    OK then we'll need a repro project to figure out what's going on. Is it possible for you to extract a single scene from your project in which you can reproduce this issue and attach it here?
     
  5. vdeloso

    vdeloso

    Joined:
    Mar 4, 2015
    Posts:
    10
    I generated a completely new project from Unity 5.0.1p2, copied the bare essentials of the code and source data. Running it, the terrain still appears shiny. Please note, I cannot edit the source texture image and must use it as is. If any modifications need to be done to the image, they must be done through the Unity script and not from an external non-live editor.

    Had to host it on my dropbox as the zipped project exceeds the forum attachment size (3.63mb): project link.
     
  6. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    272
    OK. I know what the problem is.

    In your script, you used Texture2D.LoadImage to load a .png file. Texture2D.LoadImage will load any .png file into ARGB32 format. If the original image doesn't have an alpha channel (which is your case), the default alpha value for the Texture2D is 1.0. As the standard terrain shader uses the alpha channel of the splat texture as the smoothness value for the surface, you got a very shinny surface with its smoothness = 1.0.

    Changing the source image into .jpg format fixes the problem, as Texture2D.LoadImage will load .jpg files into RGB24 format. Terrain material system will correctly handle this format (smoothness will be controlled by SplatPrototype.smoothness instead).

    If you can't do anything about the source image, here is one of the tricks you can do in the scripts:
    Code (CSharp):
    1. Texture2D texture = new Texture2D(2, 2);
    2. texture.LoadImage(File.ReadAllBytes(pngImagePath));
    3. texture.LoadImage(texture.EncodeToJPG(100));
     
    vdeloso likes this.
  7. vdeloso

    vdeloso

    Joined:
    Mar 4, 2015
    Posts:
    10
    Alright, thanks for the help regarding this issue. I opted to consolidate it to the following:
    Code (CSharp):
    1. splat.texture = texture;
    2. splat.texture.LoadImage(texture.EncodeToJPG(100));
    Since the source texture can be either from file cache or loaded from the web. Things look back to normal now, I get to retain the standard material for terrain and no longer need the awkward extra base terrain tile.
     
  8. BES

    BES

    Joined:
    Feb 26, 2013
    Posts:
    212
  9. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    652
    I was using textures imported into Unity and getting the same shine on quite a few objects not just the terrain. I checked the import settings for all my textures and unchecked Alpha from greyscale and it looks fine now.
     
    correia55 and CoughE like this.
  10. R4347

    R4347

    Joined:
    Feb 13, 2017
    Posts:
    2
    Hey guys I figured out a easier way to do it without coding just click on terrain and than click on the gear far right of the inspector under terrain, there you will see Base terrain next to material click and select "Built in Legacy diffuse' and the shine will come right off. No need to open coding windows it wasnt that complicated XD
     
    Shikoba11 likes this.
  11. vdeloso

    vdeloso

    Joined:
    Mar 4, 2015
    Posts:
    10
    Considering that our terrain was being generated at run time via script, we definitely needed to edit the terrain data via script. The use case if for those that are doing streaming terrain and from source images that we cannot modify.
     
  12. R4347

    R4347

    Joined:
    Feb 13, 2017
    Posts:
    2
    Well, thats how I did it if anyone else igured it out it would have been posted here.
     
  13. Joaquinmolina

    Joaquinmolina

    Joined:
    Jul 17, 2015
    Posts:
    13
    I had the same issue and found a solution.
    -
    click on your terrain and make sure it's selected in your hierarchy.
    -
    on your far right under the inspector tab, next to the little pad lock, look for a down arrow on the right side, click on the down arrow and select DEBUG.
    -
    There, under the DEBUG window, look for the terrain tab. There you will look for REFLECTION PROBE USAGE, have that setting set to Zero (0).
    -
    Then leave DEBUG and select NORMAL on the down arrow.
    -
    Hope that helped.
     
    Sulemanalimalik and Tapgames like this.
  14. ReZult_Studios

    ReZult_Studios

    Joined:
    Jun 11, 2016
    Posts:
    25
    Go to the Terrain Settings and change the material to legacy diffuse!
     
    Ssssilk likes this.
  15. Revir

    Revir

    Joined:
    Jan 26, 2016
    Posts:
    2
    I found another fix thanks to some of your suggesting getting me looking in the right place.

    I found that if you go into the Terrain Settings and change the Splat Map Distance, this has a great effect on how shiny the terrain texture is. Changing this to a value lower then 500 removes all shininess. At least for me! It seems a bit wonky.
     
  16. ice2011

    ice2011

    Joined:
    Jan 5, 2015
    Posts:
    7
    Here is the more updated approach (Unity 2019.2.9f1) to remove that tongue biting shiny terrain from your scene.
    1. Select "Terrain"
    2. Select "Terrain Settings"
    3. "Reflection Probes" (To your desired options)

    "Never. Stop. Following. Your. Passion."
     
unityunity