Search Unity

Advaced Triplanar shader

Discussion in 'Made With Unity' started by tomaszek, Jul 31, 2013.

  1. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Hi,

    Maybe sound a bit bold, but truly - I'd like to present the most advanced triplanar shader available (as far as I know) at the moment. The shader will be part of the new RTP2.5 release (asset store link) where I'm on the finish stage (current version is 2.1).

    User will be able to use it on any mesh, including existing VoxelTerrain solutions that encodes splat coverage using vertex color.

    It handles up to 4 layers blended via vertex color and will have all the new RTP shader features availabe (might be adjusted to tweak it against performance), so:

    1. Parallax Mapped triplanar (in local or world space)
    2. UV blend for depatternize
    3. Perlin noise normalmap (to boost up details at far distance)
    4. Dynamic snow (dynamicaly covers flat top surfaces here)
    5. Advance dynamic water (with slope driven and flowmap driections, water level, rain drops - reflective / refractive)
    6. Reflection (fresnel - view angle dependent) - static reflection map
    7. Vertical texturing
    8. Global colormap (textured w/o triplanar using uv model coors set)

    In screenshots below we've got UV blend, perlin, snow, reflection enabled. Works @7ms per frame (forward one pass) on GT240 / 1280x900 - model panned at fullscreen. With snow, reflection and perlin disabled works @3ms per frame.



     
    Last edited: Jul 31, 2013
    Farelle likes this.
  2. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Lovely. Add some optional DX11 tesselation subdivision with procedural roughness/triangle smoothing and it'll be even more awesome for terrains! How do the reflections work, like lightmapping but with a reflection map? For shiny terrain metals or something?
     
  3. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    DX11 - nice, but not in this release :)

    Shiny terrain metals or shiny rocks - exactly. Reflection map is grayscale texture. Reflection is used on the surface water or w/o - controlled per layer. Reflectivity is taken from view angle (fresnel like) and from detail texture specularity (alpha channel of texture). It can be damped to 0 or boosted up for layers that has low specularity defined in their alpha channel. I don't use cubemap, but regular texture. Where it's white we choose colorA (emissive), where it's black we choose colorB (Albedo). So - for example - your layers can reflect "sky" (define colorA white, colorB - blue). For rainy sky colorA could be grey and colorB could be dark grey.

    Package consists of a few sample reflection maps, so that user can easily figure out how does it work.
     
  4. nipoco

    nipoco

    Joined:
    Sep 1, 2011
    Posts:
    2,008
    Nice work Tomaszek :)
     
  5. DesertRaven

    DesertRaven

    Joined:
    Jul 15, 2012
    Posts:
    137
    Hey, what ever happened to #5? The advanced dynamic water with the slope driven flowmap???? I want it.
     
  6. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    DesertRaven likes this.
  7. DesertRaven

    DesertRaven

    Joined:
    Jul 15, 2012
    Posts:
    137
  8. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    For triplanar shader it would be tricky to use flow direction map. For uv mapped meshes (let's say top planar mapped plane) you can use flowmaps. Link to the tool (free) I used for flowmap generation is provided with RTP package. Here how it can look like:



    I don't have separate tutorial on flowing water, but you can see how does it look like on my shocase island video (refer to my assetstore product page). If you open first page of this thread there are also links to demos where kind of stream and puddles are placed. Water flows there ased on slope only (no flowmap) though + we have rain droplets simulated at shader level.

    Tom