SSAO use of getMappedDepth instead of getDepth inside normal evaluation
giagitom opened this issue · comments
What kind of differences? Is it faster? The main reason for getMappedDepth is to get depth from a lower resolution texture when further away from a pixel to be more cache friendly. However in viewNormalAtPixelPositionAccurate the texture accesses are all very close to the pixel.
Thanks for the explanation. I didn't checked about performances, but I think It would not change anything from this point of view.
Also regarding the difference I noticed before I'm unable to reproduce it. It was probably due to something else.
About performances, I tried to substitute distance()
with distSquared()
in order to avoid square root calculation
Surprisingly for me, it seems this change leads to a slight worsening in frame rate. Any Idea why?
#define dQuarterThreshold 0.01 // 0.1 squared
#define dHalfThreshold 0.0025 // 0.05 squared
float distSquared(const in vec2 coords1, const in vec2 coords2 ) {
vec2 sub = coords1 - coords2;
return dot( sub, sub );
}
float getMappedDepth(const in vec2 coords, const in vec2 selfCoords) {
vec2 c = vec2(clamp(coords.x, uBounds.x, uBounds.z), clamp(coords.y, uBounds.y, uBounds.w));
float d = distSquared(coords, selfCoords);
...