Search Unity

Distorting texture based on normal map

Discussion in 'Shaders' started by suctioncup, Apr 11, 2014.

  1. suctioncup

    suctioncup

    Joined:
    May 19, 2012
    Posts:
    273
    Hello, I am relatively new to creating shaders. I've made some rim lit shaders, followed some tutorials - I have the basics down, really.

    What I am trying to do is seen in this gif: http://www.gfycat.com/UnselfishPlayfulArrowana#

    I am aiming to get the 'smokey' effect on the lasers. I asked the developer how he generated this, and he pointed me to this: http://www.ozone3d.net/tutorials/glsl_texturing_p06.php (however his normal/displacement map is procedurally generated simplex noise). The displacement effect is applied in passes that progressively lowers that alpha.

    I'm sure it is very simple to create a shader to displace a texture based on a normal map, but how would I do it? I can't seem to find the answer through google.

    Also, as a secondary question, how would I go about applying the displaced, faded texture to the laser - which is a simple line renderer.

    Thanks in advance.

    Btw the game in question is AeroBat - we'll worth looking into. Very impressive.
     
  2. WhiskyJoe

    WhiskyJoe

    Joined:
    Aug 21, 2012
    Posts:
    143
    Everything you need is there already to be honest. The way I see it, you can get this working in 2 ways:

    1. Make the shader that you linked and alter it to your liking. The main point is that you want to distort what is behind it, so you will need to get the texture of there. There are multiple ways for that. You can either render the scene yourself once more and clip everything that's not behind the effect (check out the water pro samples of unity) or you can check out the grabpass in the shader.

    2. Make it an image effect and distort the point of impact, pretty much the same way except that you don't have to render the scene twice. You will need to calculate where in screen space the point of impact is and define how much of the screen is affected.

    Both cases will require unity pro. For your searches, try looking for water refraction or distortion effects. You will not likely found an out of the box solution, but enough info to get you started.