Search Unity

Flowing Lava Shader

Discussion in 'Shaders' started by kenmgrimm, Jan 21, 2017.

  1. kenmgrimm

    kenmgrimm

    Joined:
    Nov 26, 2013
    Posts:
    34
    I'm looking for some direction in creating lava flowing down a volcano. I found an asset that works pretty well on a flat plane: https://www.assetstore.unity3d.com/en/#!/content/33635
    It takes 3 textures, the rock areas with transparency where the lava would flow, the lava itself, and a distortion map that tells the lava to flow around objects. The script increments the offset of the lava texture to make it flow.



    Is it possible to use this technique to have lava flow down the side of a 3d volcano? If not, other ideas? It doesn't seem possible to use the same scrolling technique with the texture offset since the texture will be a bunch of unwrapped slices, not a flat plane.

    Thanks!
     
  2. tsangwailam

    tsangwailam

    Joined:
    Jul 30, 2013
    Posts:
    280
    You may calculate the UV via world position. Something like a triplanar shader.
     
  3. hannes-dev

    hannes-dev

    Joined:
    Apr 27, 2012
    Posts:
    132
    hello, i have done this before. You have to create a flowmap shader basewd on the normals of your object
    then you can provide a mask and whatever you have / water / lava / ... will flow down
     
  4. kenmgrimm

    kenmgrimm

    Joined:
    Nov 26, 2013
    Posts:
    34
    Right, I've looked at that but the thing that I am missing is how to deal with a map that is broken up into pieces, iow, more complex than a plane. On a plane, the flow is always in one direction so the when scrolling the texture over the flowmap the offset is just incremented in the direction of the flow. On a more complex object, wouldn't the flow map have to have each segment "flow" in a different direction depending on how the texture got unmapped? Would I have to find each piece in the map and find the direction of flow and calculate the offset individually?
     
  5. hannes-dev

    hannes-dev

    Joined:
    Apr 27, 2012
    Posts:
    132
    if you do it based on the normals of the object instead of the scrolling uv, you dont have that issue
     
  6. hannes-dev

    hannes-dev

    Joined:
    Apr 27, 2012
    Posts:
    132
    here is a image illustrating it
     

    Attached Files: