Search Unity

multiple planes with glass shader

Discussion in 'Shaders' started by robhuhn, Jul 13, 2009.

  1. robhuhn

    robhuhn

    Joined:
    Jun 21, 2009
    Posts:
    113
    I all,

    i had this question in another forum index before but now i am sure this issue is because of the glass shader.

    You can find the test project here:
    http://unity.webdiscdrive.com/gui/

    If you set duration top to 1 second and bottom to 10 seconds and click "tween" you may observe that the lower bar covers the upper bar and the TextMesh is not visible through the glass.


    Furthermore the Glassbar covers other glassplanes.

    Anyone knows how to get multiple planes (one behind the other) with a glass shader rendered?

    Thanks in advance!
     
  2. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Unfortunately, this isn't possible unless you set up your own intermediate RenderTexture for every stacked pane of glass. I haven't thought about how to do this, although it's probably possible. The limitation you're seeing is due to documented behaviour of the GrabPass function:

     
  3. robhuhn

    robhuhn

    Joined:
    Jun 21, 2009
    Posts:
    113
    hey thanks for the reply.

    I realy dont know much about shader and it seems that i have to learn it urgently.

    So it isnt possible to set something like a "shader render order" manually?
    Shader with grabPass in the back would grab the texture before shaders in the front will do. -just an idea.
     
  4. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    You can certainly set the render order manually (see render queues), but as the bit in the manual above states, the same source is used for every GrabPass in a given frame. This means that refractive materials cannot stack.
     
  5. robhuhn

    robhuhn

    Joined:
    Jun 21, 2009
    Posts:
    113
    ok, thanks. good to know.

    What about the 3D Text? It has no refractive material but you cant see it through the glass. Is it also because of grabPass reusing the screen texture?
     
  6. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    That sounds like it could be solved with render queues. I'm not sure exactly how it works, but my guess is that the first GrabPass defines when the screenshot for subsequent GrabPasses is taken. If you move your refractive shaders to a queue after text, then the GrabPass might include the text.
     
  7. robhuhn

    robhuhn

    Joined:
    Jun 21, 2009
    Posts:
    113
    Hi,

    i just tried to edit the shader. If i edit the original shader with "Queue" = "Geometry+1001" it works and i can see the text through the glass whether the text is in the front or in the back :)

    So i copied the shader, renamed it to "Glass-Stained-BumpDistort Text" and inserted the new Queue command. Then i created the new material with my shader. Unfortunately i didnt have the effect i had before. It seems that it still have the original shader but dont ignores the new shader completely. Looks strange to me :)