Search Unity

Light at end of tunnel effect?

Discussion in 'Shaders' started by VileGoo, Sep 11, 2019.

  1. VileGoo

    VileGoo

    Joined:
    Apr 29, 2017
    Posts:
    220
    I want to create a shader I can apply to a flat plane that will give off the effect of a light at the end of a tunnel, where moving from side to side will create the illusion of the plane having depth. I'm fairly certain I need to use depth to achieve this effect, but I have never used depth before in shaders so I'm not sure what to do. Some help would be appreciated, thanks.
     
  2. mouurusai

    mouurusai

    Joined:
    Dec 2, 2011
    Posts:
    350
    You can use some post effect like bloom or god rays.
    Put a quad with unlit shader on the end of tunnel and assign hdr color in material.
     
  3. VileGoo

    VileGoo

    Joined:
    Apr 29, 2017
    Posts:
    220
    This is what I tried at first, but it did not give off the illusion of depth I'm hoping to get.
     
  4. mouurusai

    mouurusai

    Joined:
    Dec 2, 2011
    Posts:
    350
    Share some screenshots with what you get so far, and some references what you want to achieve.
     
  5. VileGoo

    VileGoo

    Joined:
    Apr 29, 2017
    Posts:
    220


    Did this in photoshop as a quick example of the sort of effect I want, which is to create the illusion of a tunnel on a flat plane.
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Depending on how complicated you want to get with this, you can use a basic box projection like an interior mapping shader uses.

    See the SimCity 5 example I posted here:
    https://forum.unity.com/threads/interior-mapping.424676/#post-2751518

    Beyond that you're getting into slightly more complex raytracing / raymarching setups to get the curved top. See these two examples from ShaderToy:
    https://www.shadertoy.com/view/Ms2SWW
    https://www.shadertoy.com/view/ltXGW4

    Basically you'd have to figure out a way to merge those two shaders (a not entirely trivial task) so the top half is an arch, and the bottom is the box.