I was toying with the idea of making a SSAO shader when I realised that most adaptations of these have a faulty way of determining normals (as far as I can tell anyway - perhaps it's a performance thing?). Either way, since I love trigonometry and a challenge, I decided to try to figure out the math.
This resultet in this little thing - a normal vector inspector - that might not have overly much practical use, but I thought it worth sharing anyway, if nothing else then to give a hint of what we can do with shaders (once we have mipmaps/lod for the FBO *nagging @niv
In it's basic form, all it does is render a normal vector of the current surface that the mouse is hovering. There's also an option of rendering the depth buffer of the entire view and alternatively the normal vectors of the entire screen (see below)
You can get it here: download
Put in your Neverwinter Nights override folder (the one under "My Documents") and enable the Depth of Field shader in game. It'll overwrite that, so once you are done toying with it, simply remove the file again to revert to normal.
Here's some screenshots:
To render the entire scene as depth, remove the "//" from "//color = Depth(color);" near the end of the file.
To render the entire scene as normals, remove the "//" from "//color = NormalVectors(color);" near the end of the file.
Mind you, it's not perfect
- certain things were omitted because the impact it was minimal (like projecting back from focal point to screen). Still, any suggestions for improving the math is highly welcome!