Hey all…
In my spare time, I’ve been working on a deferred rendering implementation and I’m hitting a snag, that (from what I can tell) everyone else has hit as well (whether or not they realized it).
I’m having trouble correctly reconstructing the position from depth.
Let me start with an example of how position from depth should be constructed (in all examples I have found):
[java]
// Depth in this case, is non-linear
vec4 position = ProjMatInv*vec4(texCoord, depth, 1.0);
position.xyz /= position.w;
[/java]
One thing that is not clear from the examples is the use of the inverse projection matrix… every topic/paper I have read on the subject says using the inverse of the current projection matrix. Which one?
I’m not so sure this is what I am looking for as it is completely unusable for everything from Parallax mapping to SSAO. Though seems to do fine for lighting.
Sooo… the question is:
- Does the above reconstruct the position in View Space? Or World Space?
I can not track down a definitive answer, though I would have to assume that since it is starting in screen space, using the inverse projection matrix would result in view space. However, no matter which is the case, the results are unusable unless you comment out the second line. Which makes little sense, as every example I can find uses the above.
The results are clearly wrong, if you output them to the screen.
I guess, one of the biggest problems I am having is:
- There is NO comprehensive list of global variables that JME will pass to shaders (though the documentation has said this will be added for over 3.5 years now).
- Why, oh why did someone decide to replace the word Model with World? /cry This has been the bane of my existence for… well… since I started writing custom shaders for JME. Though may have been easier to deal with if that illusive comprehensive list of globals had been added to the docs.
Soooo… aside from the single question above (which I would REALLY appreciate some insight into), is there any chance we could finally get that comprehensive list of globals? please please please please please?
There is actually more to this… but this would be a stellar start!