Search Unity

A blended mesh and terrain texture shader with detail normals and displacement maps

Discussion in 'Works In Progress - Archive' started by Deleted User, Jan 13, 2012.

  1. Deleted User

    Deleted User

    Guest

    I've been working on a shader that uses blended splatmaps (like Unity's terrain) for any mesh, but also has normal mapping, detail normal textures and displacement mapping (Parallax or Relief) for as much realism as possible. All of the options can be turned on or off, so that the one shader can be used on a wide range of desktop hardware, as well as fallbacks for PS2.0 capable hardware, and even a very basic version (blended textures only) that'll work on flash in 3.5. At the moment it works on arbitary meshes, and I'm working on a version (mainly the scripting side) that'll work with Unity terrain. Hopefully, when it's ready, I'll put it on the Asset Store.

    In a state of flux at the mo, so the old info isn't accurate anymore. I'll edit this when it changes.
     
    Last edited by a moderator: Feb 20, 2012
  2. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    My friend, you just saved my life... :) I created a material that has nearly everything I want on it... but I hope this will allow me to paint textures directly in Unity on the terrain meshes and have a GREAT looking mountain... Do you use Vue or Zbrush to design your mountains or caves?
     
  3. Deleted User

    Deleted User

    Guest

    I use L3DT for the terrain meshes as it allows you to export a splatmap, and a mixture of L3DT and Silo3D for the caves. When I complete the Unity terrain version, I'll put up a webplayer of that too, so you can see if it meets your needs!
     
  4. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    That is cool...I just do my terrains in Vue, export the super high res version of and detail it some more in Zbrush... I am not used to terrain painting in Unity...
     
  5. Deleted User

    Deleted User

    Guest

    Here's the 3.5 flash fallback shader, which is the equivalent of Unity's terrain shader ,running those two scenes. As Unity Flash doesn't work with terrain at the moment, I might write an obj exporter for it, so that you can decimate the terrain in something like MeshLab and reimport it, then render it with this shader. I'm not sure about Unity Technologies' stance on exporting terrain meshes though.

    In a state of flux at the mo, so the old info isn't accurate anymore. I'll edit this when it changes.
     
    Last edited by a moderator: Feb 20, 2012
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    it seems as if it doesn’t work on os x. but even if it would i do not see the point of this shader for chris morris has already brought bump and paralax mapping to the built in terrain. in spite of all its limitations using the built in terrain engine i think gives you a lot of advantages as long as you are targeting desktop devices and do not need cliffs and overhangs: automatic LOD, grass, trees.

    lars
     
  7. Deleted User

    Deleted User

    Guest

    New webplayers up (see OP) with more sensible normal maps and tiling.

    larsbertram:

    This will work with the built in terrain too (am finishing up the scripting), and provides support for relief mapping at reasonable frame rates on modern hardware, an overarching normal map for the entire terrain that can be blended with the splat maps, per splat map detail normal mapping (as in a second set of normal maps blended at a higher tiling), per splat mono specular maps which can be coloured in forward rendering and per splat displacement levels (although the demo doesn't show that, for simplicity). This is in a single shader that takes a different pathway depending on which form of displacement mappng you choose. Also, for performance reasons, you can set the displacement and detail normals to cut off depending on the distance of the pixel from the camera.

    As for OSX, try the latest version of the webplayers (same link as in the OP) - they work on my iMac as well as they do on Windows machines. Also I'm working to get the PS2.0 fallback to work on iOS devices.

    Hopefully this helps show why I'm doing this.
     
  8. Deleted User

    Deleted User

    Guest

    After doing some testing after larsbertram's comment, it doesn't seem to work correctly on OSX Leopard with Intel GMA 950 graphics. It does however work on Windows with the same card (in fallback mode, obviously), I suppose due to the use of DirectX over OpenGL. I cannot see how to solve this at the moment.

    I have got it to work on iOS, albeit not at interactive framerate., I'm seeing if the fallback shader can be simplified further for iOS only.
     
  9. Deleted User

    Deleted User

    Guest

    Sorry it's taken so long to continue, but I've been in and out of hospital for the last few weeks, which has been rather annoying;)
    As for this shader, I worked out the problem that affected a lot of cards, but then Unity 3.5 broke it, even though it worked on the beta. When I can get it stable, I'll post again.
     
  10. Deleted User

    Deleted User

    Guest

    As there have been problems getting the terrain replacement part of this shader working on 3.5(see here), I'm thinking about just releasing the mesh version of the shader, if anyone is interested.
    It's a shame, but can't be helped.
     
  11. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Wow, this kind of stuff should be built in out of the box from Unity. We really need updated terrain engine.
     
  12. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Interested!
    What will you take for it on the store?
     
  13. Deleted User

    Deleted User

    Guest

    Here's a demo - please tell me if you have any problems (note, as said above this is a mesh, rather than a Unity Terrain, and also the displacement level is per splat as opposed to a single level, as in the demo):
    (Webplayer Demo)

    Screenshot:


    How much would you suggest?
     
  14. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    I could say between $50-100... Unity DEFINITELY needs a mesh based terrain shader...and even be able to use your own shaders for it...
     
  15. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
    The textures used aren't the best to display relief/parallax mapping. Maybe you should try something with a different distribution of high frequency details.
     
  16. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
    The textures used aren't the best to display relief/parallax mapping. Maybe you should try something with a different distribution of high frequency details.
     
  17. Deleted User

    Deleted User

    Guest

    Right - I've decided to write a manual, as I think it needs one, plus it can also outline a pipeline for transferring Unity Terrains into a useable mesh.

    When I've completed that, I'll decide on a price.

    koyima - I agree completely - I'll also stick up a demo which shows off the features better - starting with better textures :)
     
  18. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,208
    Well, I definitely wouldn't suggest that amount, it seems to unfinished. Too much shimmer everywhere, etc. Would be interested in experimenting, but not for that.
     
  19. Deleted User

    Deleted User

    Guest

    How much would you suggest - it's up in the air at the moment?

    Also, if you don't mind, could so tell me what GPU you get shimmer on? I've seen it on some nVidia cards(and am working on fixing it asap), but not on AMD ones so far.

    Also in regards to writing the manual, that might take some time, for the same health reasons mentioned earlier.
     
  20. DaneC020

    DaneC020

    Joined:
    Mar 19, 2010
    Posts:
    191
    I would be interested in the mesh shader. I am currently looking at writing my own splatmap shader for custom terrain in my game but haven't had any luck/time to really get into it. I personally value a non-unity terrain shader more than a unity terrain shader.

    -Dane
     
  21. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,208
    I guess it depends on the workflow and toolset. If you have some way of painting, etc, then maybe that price was worth it. But if it's just a shader, and all the work has to be done in blender or max (etc), then somewhere south of $50 might put it into my "buy it and try it" range. I can't really say without knowing more about what you put into it.
    The shimmer I saw was on an AMD 6750M, with 1GB of video ram (on my Macbook Pro).
     
  22. Deleted User

    Deleted User

    Guest

    The problem with the shader causing the shimmering seems to be a problem with the cg compiler trying to be clever and avoid a branch (and maybe combining registers), running the detail mapping twice, once without the distance limitation on certain GPUs, causing bright shimmer. This makes fixing it complicated, so I might have to send it off to Unity Support as a bug.

    Jaimi: it is mainly a shader, with extra tools to help the construction of displacement heightmap combination and tools to convert a Unity terrain to a usable mesh w/splatmaps. Painting would be impractical, as it works on a arbitary mesh, so painting with the texture map would make more sense.

    It wouldn't take much to write a vertex colour splat version though, which could be painted with the vertex painter on the Asset Store though, but fixing the shimmer comes first.
     
  23. Deleted User

    Deleted User

    Guest

    Bug report sent :)
     
  24. Deleted User

    Deleted User

    Guest

    While I wait for a reply, I've removed the detail map functionality, as that was what was causing the problem. The new webplayer is here.

    At the same time, I rebuilt it for android, and found that the fallback shader (coloured specular maps, whole mesh normal map, no displacement or per-splat normals) with fog worked fine. I didn't change the assets, so it was running with a 20k triangle mesh and 1k x 1k textures and normals, and it ran at 6.5-12.5fps on a 1st gen HTC Desire, which was surprisingly smooth.

    Next thing is to get better textures for the demo :)
     
  25. DaneC020

    DaneC020

    Joined:
    Mar 19, 2010
    Posts:
    191
    Unfortunately it looks like the link is currently down for me. I will try again in a few, but just wanted to give you a heads up in case you see an issue with it.

    Looking forward to seeing the progress made,
    Dane
     
  26. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    951
    Now I get the shimmering.
    OSX, Chrome, GeForce 320M.

    I would be interested in this shader, but I wouldn't pay until it's less buggy. And even then not more than €10.
     
  27. Deleted User

    Deleted User

    Guest

    That is very strange. What does this shimmer look like? If it's like this:

    then it's just the crappy normal maps I'm using(and am replacing). Otherwise, I'm not sure. It's strange that it mainly seems to be people using OSX on nVidia mobile GPUs. I can't reproduce it on PCs with nVidia cards and it doesn't show up on my Mac with an AMD card. Does it look anything like the screenshots posted on the last page or is the shimmer very obvious?
     
  28. Deleted User

    Deleted User

    Guest

    Please note - I am still alive! As mentioned earlier, I have been in and out of hospital and seeing an awful lot of specialists, so I haven't been around recently. Now they've worked out the problem, I should be around a lot more :)

    I have been working on this, and taking into account the criticism, so I'll probably open a new thread when I have something to show.
     
  29. Deleted User

    Deleted User

    Guest

    Just a note to say the new thread is here:D