Search Unity

ats color map ULTRA shader [RELEASED]

Discussion in 'Assets and Asset Store' started by larsbertram1, Oct 17, 2012.

  1. FirstTimeCreator

    FirstTimeCreator

    Joined:
    Sep 28, 2016
    Posts:
    768
    Can you edit the shader to only run on textures with extrusion > 0 ? I am a programmer but I haven't got into shaders yet, I am more focused on environment and controllers.

    Also I will make a tutorial video for you. I am setting up a mars crator on a 1024 X 1024 terrain as we speak, and I will record my setup.

     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    for a tessellated mesh? i do not know any solution for that.
    occlusion culling will not help much with a terrain unless you have giant occluders, which occlude a whole chunk of the terrain i guess.
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    no, that is not supported. you tessellate geometry – not textures, so i have no idea how splat map driven tessellation factors would look at the seems. not to mention that the tessellation shader does not know anything about splat maps right now. so that would need at least another 2 texture lookups in the tess shader.
    and extrusion defines the amount of extrusion not tessellation.
    have a look at the "CMU-Common.cginc" which contains the tess functions used.
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    see my answer above.
     
  5. FirstTimeCreator

    FirstTimeCreator

    Joined:
    Sep 28, 2016
    Posts:
    768
    Oh I see you are using the normal map to tessellate the entire terrain in one pass am I correct.

    #if defined (_TERRAIN_NORMAL_MAP) || defined(NOLOD) || defined(NOLODBASE)
    float4 heightNormal_sample = tex2Dlod(_TerrainHeightNormal, float4(v.texcoord.xy, 0, 0));
    //heightNormal_sample = lerp(heightNormal_sample, tex2Dlod(_TerrainHeightNormal, float4(v.texcoord.xy, 1, 1)), 0.25);
    float baseHeight = DecodeFloatRG(heightNormal_sample.rg);
    v.vertex.y = baseHeight * _TerrainParams.x + _TerrainParams.y; // baseHeight * height of terrain + TerrainShift

    Would it be possible to write a tessellation shader than you can control the tessellation geometry based upon the detail texture heightmaps/normals instead of a single normal map for the entire terrain? If so I may get cracking at writing shaders myself. There needs to be some type of control method for optimization and the number of verts being created by the tessellation shader.
     
    Last edited: Mar 18, 2017
  6. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    You can not only tessellate one texture as the whole model/terrain has to be tessellated the same. Also setting the extrusion to 0 does not disable the tessellation but only the extrusion amount. Do not have it open right now but adjust the near tessellation to actually edit tessellation.
     
  7. FirstTimeCreator

    FirstTimeCreator

    Joined:
    Sep 28, 2016
    Posts:
    768
    I did both near and far and didn't get a performance change, it was very minimal.
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    not really: the combined terrain height normal texture holds the "hi-res" hight and slope information of the terrain – which do not get baked into the mesh by the terrain engine in case you use rather high pixel errors.
    so the shader reconstruct that information by sampling that texture.
    tessellation is done by the tessellator: i have no influence on that (like the shape of the new triangles) apart from setting the tess factor.
    see what it actually does by switching to wireframe in the scene view tab.
    if unity's terrain used quads instead of triangles and unity's shader supported quad tessellation the result might look much nicer...
     
  9. FirstTimeCreator

    FirstTimeCreator

    Joined:
    Sep 28, 2016
    Posts:
    768
    What if you didn't use unity terrain but used a generated model instead would that open up any possibilities for optimization, or should you just tessellate it in a modeling program. The problem with that is the 64K vert limit right you would have to cut up the model and stitch them together in unity for high definition.

     
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    you may want to have a look at this:
    https://forum.unity3d.com/threads/w...ne-replacement-and-extraction-toolset.448766/
     
  11. FirstTimeCreator

    FirstTimeCreator

    Joined:
    Sep 28, 2016
    Posts:
    768
  12. FirstTimeCreator

    FirstTimeCreator

    Joined:
    Sep 28, 2016
    Posts:
    768
    Check it out I got it to work at a very respectable response time.

    Using a smaller terrain 1024/1024 makes a big difference, also adjusted it based on wireframe view, im just getting started but I intend on making a mars scene.

    I am also only using 4 detail textures instead of 8.

    Im going to play around with it see what kind of result I can get ;). Now im happy.



     
  13. FirstTimeCreator

    FirstTimeCreator

    Joined:
    Sep 28, 2016
    Posts:
    768
    Ok so I got it optimized using a near tessellation of 45 and far of 50, but every time I play it and stop the shader values reset. Why is it resetting my values? (I am not editing them during play mode).

    *Edit

    Nevermind figured it out I need to remove your script from the terrain as I am editing the material instead, the script was overwriting my values when I clicked on the terrain.
     
    Last edited: Mar 18, 2017
  14. FirstTimeCreator

    FirstTimeCreator

    Joined:
    Sep 28, 2016
    Posts:
    768
  15. FirstTimeCreator

    FirstTimeCreator

    Joined:
    Sep 28, 2016
    Posts:
    768
    hopeful likes this.
  16. FirstTimeCreator

    FirstTimeCreator

    Joined:
    Sep 28, 2016
    Posts:
    768
    Hey Im having and issue with the snow and I cant figure out what im dong wrong, I checked the normal size and it matches there is no error:

    EDIT:
    For snow to work do I need all 8 detail textures? im using 4 here just to test performance before adding the rest.

    EDIT:
    I added all detail textures, still getting black now on my mountain tops.

    EDIT:
    ignore this post I forgot to drop Lux in.



     
    Last edited: Mar 18, 2017
  17. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    Hello Lars thank for respond, I think I will buy your shader 3.0 because oit has wet and snow, but last question about downgrading to any material when directx9 is only avaliable, Is there any special place to put this material in your shader? or Should I set it in any settings of unity? I never made material/ shader downgrade automatically in unity so sorry if my question is weird, I'm just no programmer and I would to know that i could set that downgrade on myself without coding?
     
  18. FirstTimeCreator

    FirstTimeCreator

    Joined:
    Sep 28, 2016
    Posts:
    768
    You should learn its really not hard to remove and add materials to a gameobject, in this case just detect available API's for the target machine and before the scene starts remove the custom material from the terrain, though it wont be as pretty without this shader ;).

    C# is the easiest language in the world.. I can say that after writing Java and C++.

     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    right now it would need you to create and setup a 2nd material using any terrain shader which supports dx9 like the built in ones or lux (which at least supports snow and simple wetness as well). then detect the used api and swap out the materials using a (sorry) little script.
    but i guess that your project needs some coding anyway - so writing that simple script should not be an issue...
     
  20. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    Thank you lars, Ok Iwill find some programmer who will code for me that script ;) I bought your shader few minutes ago it is really simple to configurate and use :) I will use parralax instead of tessellation. Parralax isnt in beta yes? It is working well? Thank you for great work
     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    parallax works well, yes.
     
  22. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    Ok thank, Have one more wuestion because I changed to test downgrade, material from your ultra shader to standard unity terrain shader, and what I see is: upload_2017-3-20_19-9-9.png

    Why terrain in standard is blury etc? I notice that with your shader it needs to update arrays before updating, but now I have standard terrain shader Why it is blurry not looking as normal terrain shader?
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    sorry, i did forget to mention that: cmu needs to lower the "basemap distance" to 0.
    when changing the material you also have to set the basemap distance to a reasonable value.
     
  24. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    Thank you it works ;) My last question because I cant find info, what with directX10 because I don see info about this in shader 3.0 or 2.5

    ALso Why when I'm importing Ultra Color MapShader 3.0 I have this exceptions (oly when importing package in game no expections) is that normal ? image below
     
    Last edited: Mar 21, 2017
  25. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    unity has no dedicated dx10 target, only dx9, dx11 or dx11_9x.

    those are not normal. but you should update to the latest version anyway (nolod is depricated).
     
  27. Bezoro

    Bezoro

    Joined:
    Mar 16, 2015
    Posts:
    133
    As someone who is interested in buying this and can't find the answer anywhere I'd like to ask.
    Are the terrain holes just visual or does the asset come with a way to resolve the collisions and lets the players go into them, such as a cave.
    I tried Google, the documentation and searching this thread but I couldn't find an answer.
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    the holes are only "visual". but all you need to resolve collision would be a trigger which disables collision "OnTriggerEnter" using "Physics.IgnoreCollision".
     
  29. Bezoro

    Bezoro

    Joined:
    Mar 16, 2015
    Posts:
    133
    Noted, thank you very much.
     
  30. RemexChris

    RemexChris

    Joined:
    Aug 4, 2015
    Posts:
    16
    Hi lars,
    My terrain is made up of multiple stitched tiles. I would like to quickly copy Color Map Ultra to all tiles. (They are all configured in the same way with the same prototypes.) The only difference is the BaseMap. Is there a nice way I can automatically copy these across? Happy to get my hands dirty with code but early attempts at ensuring all terrains are using the CMU material and copying the components across results in all of my tiles disappearing. I welcome any suggestions you may have.
    Cheers,
    Chris
     
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi chris,
    in fact i haven't tried that myself so far.
    so here are just 2 untested suggestions:

    1) as cmu is material driven you do not need the setup script on all tiles.
    simply copy the material, assign the new color or basemap. then assign that material to the new tile.
    finally you will have to set the basemap distance to 0 on that tile.
    you may even add the setup script afterwards and assign the new material to it: the script should recognize, that there has been a new material assign and should offer a function to read the values stores in that material.

    2) you may also switch to debug mode and copy the values from the setup script. switch to the new tile with a setup script attached and paste the values from your original terrain.
    then assign the new color map.

    but as i said: untested.
     
  32. PerunCreative

    PerunCreative

    Joined:
    Nov 2, 2015
    Posts:
    113
    Hi,

    is this shader going to work with custom mesh? Until now I was using my own splat map shader based on Lux
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    it should.
    however in case you want to use to use the color map ultra editor to setup the material you will have to that on a "real" terrain. then assign the material to your mesh.
     
  34. Darko9221

    Darko9221

    Joined:
    Oct 4, 2013
    Posts:
    2
    screenshot_1.png

    This is just something i am working on, this is based of real Lidar data point cloud that was processed to
    heightmap along with the colormap overhead photos.

    Anyway, my question is, when i add script to the terrain to configure, i have no way to preview the texture array,
    it always just shows the first image in the array, what am i missing, i did update the arrays and save before play and everything works great with a lot of hit and miss due to not able to preview the full blended arrays, i must add, i only use 0-3, the 4-7 is open, is that maybe a prob? I also then i need to delete the script from terrain afterwards to be able to apply my custom splat map made in worldmachine otherwise i cant change anything, thats also the reason i only see one texture in the array, any tips would be appreciated.
     
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    that looks pretty nice!
    i am not sure if i got you right: cmu does not offer any possibility to preview the generated texture arrays – except from using them on the terrain :)
    as far as the splat maps are concerned: you could grab a script from here: https://www.world-machine.com/learn.php?page=workflow&workflow=wfunity which would you let write your custom splat maps to the terrain data – so updating values in the setup script should not overwrite the splat maps in the material.
     
  36. Andit

    Andit

    Joined:
    Feb 27, 2015
    Posts:
    6
    Hi. I have recently started using this asset and have tried to import a splat map. This has been said before, but every time I press apply splat maps I recieve the message "Splat map 1 must be in ARBG 32 format. Please fix this in the import settings".
    I have tried many different things to fix this. Firstly by overriding the standalone import settings and forcing the format to be RGBA 32 bit, when is didnt work I tried ARBG 16 bit and this didnt work either. No format with the exact name ARGB 32 bit seems to exist... Also the image below shows that for some reson by default format is grayed out and set to auto:
    splatHelp.PNG
     
  37. Darko9221

    Darko9221

    Joined:
    Oct 4, 2013
    Posts:
    2
    My friend, i had the same problem, you can either just remove the If statement in the Splatmap coding that stated if it is not that format then display the error, then force it with a "RGBA Compressed DXT5" format texture and enable transparency and readable checkbox, or you can use this splatmap replacer that guides you through the whole process and helps you save the texture in the right format and everything. here is a replaced splatmap done with this which i prefer myself in the attached screenshot, the ".js" file must be in /assets/Editor (same location as the splatmap converter that doesnt work). Here is the website of the guy who coded the Splatmap Helper - https://mattgadient.com/2014/09/28/unity3d-a-free-script-to-convert-a-splatmap-to-a-png/

    The one you used broke when Unity decided to remove the format support that was always used for the old converter, and the plugin is not at fault, but still, would be nice to have that functionality added to ATS itself.
     

    Attached Files:

    Andit likes this.
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
  39. Andit

    Andit

    Joined:
    Feb 27, 2015
    Posts:
    6
  40. AlbertoMastretta

    AlbertoMastretta

    Joined:
    Jan 1, 2015
    Posts:
    71
    Hi larsbertram1!

    I had bought Colormap Ultra 3 a while ago, but only recently started using it. It has been a lot of fun! I'm only using it for the heightblending right now, and I really like it.

    I have found just 1 problem so far, which has do do with baked lighting using enlighten. I'm using a very warm light for my scene, but when i bake it, it seems to me that the color of that light is ignored. It could be something else, but that's my best guess.

    Here is how it looks with default terrain shader: 6549a4b3a74ce0f23d921cfe8c0badad.jpg

    and here is how it looks with Colormap Ultra 3 3fea5a85ebdb830aff9efeea915c0d63.jpg

    Its particularly noticeable because I'm using a material on that staircase that has the same texture and normal as the terrain.

    Is there anything I should check for baking light in a way that this doesn't occur?

    Thanks in advance, I'm loving it so far!

    Alberto.
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    from the docs:
    The tessellation shader family currently does not support GI or light mapping by default due to performance considerations. Please contact me if you need these features to be enabled.
    does this explain your problem?

    you may simply change to "Parallax" to check it out.
     
  42. AlbertoMastretta

    AlbertoMastretta

    Joined:
    Jan 1, 2015
    Posts:
    71
    Thanks for the reply!

    I'm using parallax at the moment. That is the one with the lighter color result. Tessellation I didn't try because of that note. Here is my bake on both ColorMap Ultra 3 (top) and Unity's Default (bottom). I moved the staircase to show the baked shadow.

    It is baking properly a lot of the info, but the light color is not correct on my scene. My scene has only 1 directional light and it is very warm. The terrain looks out of place at the moment with this shader, so I'd like to know if there is anything else I could try in order to fix it!


    ba9c2e0970bb338418b3ef3ffe5c07c3.png af191ef2250ba57a515ce487362528b6.png
     
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    i did a quick test with the demo terrain and low and warm lighting.

    this is with "lightmap static" enabled but the sun is set to "real time lighting" (so only GI gets applied):
    Bildschirmfoto 2017-06-20 um 20.36.56.png

    if i set the sun to "baked" and use "directionla specular" mode (General GI) the result looks like this:
    Bildschirmfoto 2017-06-20 um 20.36.26.png

    more or less the same.
    to me it looks as if the shader behave properly as far as baked lighting is concerned.
    which makes sense because it is a surface shader and all lighting functions are the built in ones.

    so my first idea is that albedo and normal may be the same, but what is about specular and gloss?
    you showed images comparing cmu vs. built in terrain shader. what is about real time lit and baked?
    i case you get the same difference when using real time lighting i think the different shading of the stairs and the terrain are caused by the fact that the cmu shader does a lot of work to shade the pixels which the built in one does not do, e.g.:
    - it applies a colormap
    - it calculates wetness

    if however you get no difference between the stairs and the terrain when using real time lighting i would need more information about your lighting setup and the unity version you are on.
     
  44. AlbertoMastretta

    AlbertoMastretta

    Joined:
    Jan 1, 2015
    Posts:
    71
    Yep, no difference when there are no lightmaps, only when baked.

    I'll do my best to give you the info I'm working with.

    I'm using forward rendering, with linear color space.

    here are my bake settings right now.
    e7ab25e7da2ffa093aab82f47e33cef8.png

    This is my light
    d0c421e11e4db6c932c25841ac3e8b82.png

    And here is my terrain, unbaked, using CMU and Default 719e69a7ce973a5b5cb3605760685e8f.jpg

    032c2cef990382cb554f9e76e6dab3b1.jpg
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hmm, already the unbaked version does not match, right?
     
  46. AlbertoMastretta

    AlbertoMastretta

    Joined:
    Jan 1, 2015
    Posts:
    71
    I think they look the same when unbaked. At least I don't notice any difference. It should, I have wetness and snow and mostly everything turned off. I only wanted heightblending, so I is set-up as simple as I could.
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    please check, if perlin strength is set to 0.0 on the layer which should match your mesh (detail setttings -> per layer settings).
    but in fact i was able to reproduce your problem – and found a bug.
    lighting is customized – at least a little bit in order to free one texture sampler which usually is taken by the lightmap proxy volume although we can not use it on a terrain.
    so the shader does its own ambient lighting based on spherical harmonics – even if gi is enabled which makes the terrain look too bright as it gets double the amount of ambient lighting. sorry.

    in order to fix this bug you have to edit the "CMU-Core.cginc" file.
    at the very bottom find:
    Code (csharp):
    1. half3 eAlbedo = 0.0;
    2. #if UNITY_CONSERVE_ENERGY_MONOCHROME
    3. eAlbedo = o.Albedo * (1.0 - SpecularStrength(o.Specular));
    4. #else
    5. eAlbedo = o.Albedo * (half3(1.0, 1.0, 1.0) - specColor);
    6. #endif
    7.  //    Completely per-pixel
    8. half3 ambient = ShadeSH9( half4(WorldNormalVector(IN, o.Normal), 1.0));
    9. ambient = max(half3(0.0, 0.0, 0.0), ambient);
    10. o.Emission = eAlbedo * ambient * o.Occlusion;
    and wrap it with a condition so it looks like this:
    Code (csharp):
    1. #if !defined(DYNAMICLIGHTMAP_ON)
    2. half3 eAlbedo = 0.0;
    3. #if UNITY_CONSERVE_ENERGY_MONOCHROME
    4. eAlbedo = o.Albedo * (1.0 - SpecularStrength(o.Specular));
    5. #else
    6. eAlbedo = o.Albedo * (half3(1.0, 1.0, 1.0) - specColor);
    7. #endif
    8. //    Completely per-pixel
    9. half3 ambient = ShadeSH9( half4(WorldNormalVector(IN, o.Normal), 1.0));
    10. ambient = max(half3(0.0, 0.0, 0.0), ambient);
    11. o.Emission = eAlbedo * ambient * o.Occlusion;
    12. #endif
    then you have to reimport all cmu shaders.


    cmu_fix.jpg
     
    Last edited: Jun 21, 2017
  48. AlbertoMastretta

    AlbertoMastretta

    Joined:
    Jan 1, 2015
    Posts:
    71
    Thank you for your help, and the thorough check you've done!

    I added the condition encapsulation and re imported the CMU Shaders by doing right click -> remport on the folders, and then I tried on each individual shader.

    I couldn't get it to work yet. I can't keep testing today, so I'll probably give it another go tomorrow.
    If I can't get it to work tomorrow, I'll let you know.

    Thank you for helping! I'll let you know how It goes tomorrow.

    Cheers!
     
  49. Veteran66

    Veteran66

    Joined:
    Jul 12, 2015
    Posts:
    50
    will ats colormap ultra 3.0 work with Unity Version 5.6?
    i get some errors after install
     
  50. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    which errors? and whicjh version, 2.5 or 3.0?