Search Unity

Terrain Engine: Shader for groundplants supporting wind

Discussion in 'Made With Unity' started by larsbertram1, May 28, 2011.

  1. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi there,

    after having been asked several times for the shader i usually use on my terrain groundplants i have started to clean it up and prepare it for publishing.

    it replaces the built in vertexLit shader for detail meshes used within the terrain engine but also can be used on manually placed game objects.

    it supports "wind" – at least bending as it neither takes any wind zone nor the terrain’s wind settings into account, but can be fully controlled via the mesh main color or the dry and healthy color values.

    features

    terrain engine:
    - bending controlled individualy for each different mesh model via terrain engine --> dry and healthy color
    - receive shadows
    - some "basic" translucency [forward rendering only]
    - low cost rendering due to the terrain engine

    game objects:
    - bending controlled individualy for each different mesh model via material --> color
    - receive shadows
    - cast shadows
    - some "basic" translucency [forward rendering only]
    - low cost rendering due to the ability of beeing batched as static object


    my lighting models for forward rendering and deferred rendering are pretty much different from each other as deferred rendering doesn’t support "wrap around diffuse" lighting. so have tried to mimic this as good as i could. but just have a look:

    webplayer: http://bit.ly/lDoB7R

    it would be great to get some feedback before i release the final version.

    lars
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
  3. cupsster

    cupsster

    Joined:
    Apr 14, 2009
    Posts:
    363
    looking for public release.. :) you can pm me if you release this public if I overlook this somehow.
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    webplayer updated as i have seen that lighting on the terrain is totally corrupted. sorry about that.

    lars
     
  5. online|offworld

    online|offworld

    Joined:
    Nov 17, 2009
    Posts:
    85
    Hey lars, that looks great :)

    (too bad I only got unity free, I don't think the nice shadows would work for me :( )
     
  6. chadchat

    chadchat

    Joined:
    Apr 5, 2008
    Posts:
    154
    Looking good
     
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    hi there,

    the package is ready to download:
    http://bit.ly/iUzbnw

    please let me know if you have any problems and give me your feedback.

    lars
     
  8. cupsster

    cupsster

    Joined:
    Apr 14, 2009
    Posts:
    363
    thank you I will test it. are there some restrictions for using this?
     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    what kind of restriction do you mean?
     
  10. cupsster

    cupsster

    Joined:
    Apr 14, 2009
    Posts:
    363
    If this is free to use, modify, build on or redistribute.. Is there licence included? I din't opened it yet. Doing other things right now :)
     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    it is free to use. but of course it would be nice if you shared your modifications/improvements with the community…
    and you may redistribute it with your models as long as it is clear that your customers pay for the models not for the shader. may be you icould nclude some credits.

    lars
     
    Last edited: May 29, 2011
  12. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Hey lars,

    Are those plants detail meshes that are also accepting normal and specular textures?
     
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    @janpec: it is not possible to pass more than just one texture to the terrain engine which is diffuse. but if you just use the shader on manually placed models it is pretty easy to add support for normal and spec textures. the modified shader should also work with the terrain engine but won’t show up any normal/spec textures one plants within the terrain engine.

    lars
     
  14. Pixero

    Pixero

    Joined:
    Dec 10, 2009
    Posts:
    130
    Great. Thanks a lot!
    In the webplayer, why is the manually placed plants deforming more than the ones planted as detail mesh?
     
    Last edited: May 29, 2011
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    @pixero: bending looks different because i did not spend enough time on adjusting the dry and healthy colors. it is a bit tricky as i have written in the documentation.
     
  16. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Ah i thougt that your version is supporting normals on details meshes for terrain. I really hate that Unity engine doesnt handle that. Dammit its 2011 UT not 90s!
     
  17. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    let us hope for an update on the terrain engine as it has been announced.
     
  18. Samsson

    Samsson

    Joined:
    Oct 12, 2010
    Posts:
    165
    As the as i import your package, the occlusion culling doesn't work any more.
     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    @xoart: wow, it is just a shader and a pretty simple script! i can't imagine that this would stop the occlusion culling from working correctly.
    may be getting the official package from the asset store will solve your problem… (btw it comes with some more features)
    just get it here for free: http://u3d.as/content/forst/advanced-terrain-shaders/1WJ

    lars
     
  20. Samsson

    Samsson

    Joined:
    Oct 12, 2010
    Posts:
    165
    Hi larsbertram,

    Yes it impress me too ! I use the official pakage. I made 2 tests, new project, i import your package and the a made an occlusion culling on a new scene with a new default terrain. In the second i do the same without import your package.

    The first scene says "error PVS compilation".
    The second works.

    Strange isn't it ?
     
  21. Westmark

    Westmark

    Joined:
    Nov 1, 2009
    Posts:
    187
    Hey Lars
    Sent you a PM :)
     
  22. Santokes

    Santokes

    Joined:
    Oct 26, 2011
    Posts:
    11
    Um, surface shader FTL

    Doesn't anyone write real shaders in Unity?
     
  23. wolga2

    wolga2

    Joined:
    Jul 4, 2012
    Posts:
    6
    thank you very much for this shader!! i used it with an manually placed plant. my "real" mesh is still showed and the animated comes sort out of it. is this changeable or can i just ajust the values on red, green, blue and alpha?
     
  24. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    Hey Larsbertram1,
    Great work as always! I am definitely interesed and put it in my next to buy list.
    Just a suggestion, you should link images directly in your original post - so people can see what it looks like before having to load up the webplayer example.