CatAtWork
08-10-2004, 09:20 PM
I'm trying to make an overlay that distorts the normal rendered image the way a gas mask might. (slightly warped near your peripheral vision.)
I noticed Doom 3 uses a normal map to perturb texture coordinates for effects such as warped glass and heat waves.
I wrote some small post process for my current application that renders the normal frame to a texture, maps the window coordinates to [0,1], and fetches a normal from a map to alter those coordinates. It basically mimics Doom 3's glprogs/heatHaze.vfp, without the scrolling and variable deformation scale.
This works fine, except for the fact that the final image isn't exactly the same as the rendered image if I use a normal map that points completely 'up.' (0,0,1) It's ever so slightly off.
I think this is because there's no way using normal GL_RGB8 textures to create a normal map that really points completely up. Without using signed or floating point textures, normal channels are scaled and biased to move them from [0,1] to [-1,1]. The problem is, there's no way to specify .5 (mapped to zero) in a channel. Neither 127/255 or 128/255 maps to .5 exactly. This results in slight perturbations where I expected none. (I am generating normal maps using Photoshop's height-map to normal map filter.)
I could use the alpha channel to mask off perturbation, but I want to make sure my thinking isn't flawed before I proceed. It's late, and maybe I'll see the error of my ways tomorrow.
Thanks.
I noticed Doom 3 uses a normal map to perturb texture coordinates for effects such as warped glass and heat waves.
I wrote some small post process for my current application that renders the normal frame to a texture, maps the window coordinates to [0,1], and fetches a normal from a map to alter those coordinates. It basically mimics Doom 3's glprogs/heatHaze.vfp, without the scrolling and variable deformation scale.
This works fine, except for the fact that the final image isn't exactly the same as the rendered image if I use a normal map that points completely 'up.' (0,0,1) It's ever so slightly off.
I think this is because there's no way using normal GL_RGB8 textures to create a normal map that really points completely up. Without using signed or floating point textures, normal channels are scaled and biased to move them from [0,1] to [-1,1]. The problem is, there's no way to specify .5 (mapped to zero) in a channel. Neither 127/255 or 128/255 maps to .5 exactly. This results in slight perturbations where I expected none. (I am generating normal maps using Photoshop's height-map to normal map filter.)
I could use the alpha channel to mask off perturbation, but I want to make sure my thinking isn't flawed before I proceed. It's late, and maybe I'll see the error of my ways tomorrow.
Thanks.