Home Technical Talk

custom refraction map?

Hi,

I'm working on a 2d project where I need to produce a refraction map for a rendered image, so that when it moves it deforms the pixels beneath it.

Say I have modelled a glass, and rendered a front view perspective view. In the project when this image is moved it needs to deform the background using a displacement calculation, and so I need to create a refraction map from this same camera.

I can sort of fake this effect with a manual normal map setup, but was hoping to go one better, and get a better effect, by mapping how the rays are affected going through the object.

any ideas how I would accomplish this?
cheers!

Replies

  • EFF
    Options
    Offline / Send Message
    EFF
    Since this is my first post here, I would like to say hello to everyone :)

    Now. Using normal maps is pretty convenient way to get reflection and refraction effects. You can cast rays in pixel shader by sampling Glass normal map and adding this vector to the final texture coordinates. To make myself clear here is the example(You weren't specific about the environment so i assume you are making a shader):
    float3 N = tex2D(GlassNormalMapSampler, texCoord);
    float2 distortion = 2.0 * N.rg - 1.0;
    finalColor = tex2D(GroundSampler, texCoord + distortion);
    
  • davivid
    Options
    Offline / Send Message
    Hi Thanks for your reply.

    Sorry I forgot to mention - I'm using 3ds max, unfortunately creating shaders are a bit beyond me at the moment, but def something I would look into if needs be.

    So I guess if normal map is the way to go - how best do I add refractions from say ice cubes inside the glass?

    cheers!
  • davivid
    Options
    Offline / Send Message
    I guess in theory if I was to create normal maps separately one for the glass. and one for the ice inside, and then combine them using the right technique (possibly this) it should produce the desired effect?
Sign In or Register to comment.