mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
Updating some comments and removing unnecessary code
This commit is contained in:
parent
708190bfd6
commit
81ea8e8874
2 changed files with 28 additions and 35 deletions
|
@ -219,22 +219,26 @@ void AmbientOcclusion::run(const render::SceneContextPointer& sceneContext, cons
|
|||
batch._glUniform1f(_gSampleRadiusLoc, g_sample_rad);
|
||||
batch._glUniform1f(_gIntensityLoc, g_intensity);
|
||||
|
||||
// setup uniforms for extracting depth from the depth buffer and
|
||||
// converting that depth to a camera-space position, same as DeferredLightingEffect.cpp
|
||||
// setup uniforms for unpacking a view-space position from the depth buffer
|
||||
// This is code taken from DeferredLightEffect.render() method in DeferredLightingEffect.cpp.
|
||||
// DeferredBuffer.slh shows how the unpacking is done and what variables are needed.
|
||||
|
||||
// initialize the view-space unpacking uniforms using frustum data
|
||||
float left, right, bottom, top, nearVal, farVal;
|
||||
glm::vec4 nearClipPlane, farClipPlane;
|
||||
|
||||
args->_viewFrustum->computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
|
||||
|
||||
batch._glUniform1f(_nearLoc, nearVal);
|
||||
|
||||
float depthScale = (farVal - nearVal) / farVal;
|
||||
batch._glUniform1f(_depthScaleLoc, depthScale);
|
||||
|
||||
float nearScale = -1.0f / nearVal;
|
||||
float depthTexCoordScaleS = (right - left) * nearScale / sWidth;
|
||||
float depthTexCoordScaleT = (top - bottom) * nearScale / tHeight;
|
||||
float depthTexCoordOffsetS = left * nearScale - sMin * depthTexCoordScaleS;
|
||||
float depthTexCoordOffsetT = bottom * nearScale - tMin * depthTexCoordScaleT;
|
||||
|
||||
// now set the position-unpacking unforms
|
||||
batch._glUniform1f(_nearLoc, nearVal);
|
||||
batch._glUniform1f(_depthScaleLoc, depthScale);
|
||||
batch._glUniform2f(_depthTexCoordOffsetLoc, depthTexCoordOffsetS, depthTexCoordOffsetT);
|
||||
batch._glUniform2f(_depthTexCoordScaleLoc, depthTexCoordScaleS, depthTexCoordScaleT);
|
||||
|
||||
|
|
|
@ -52,19 +52,8 @@ uniform vec2 renderTargetResInv;
|
|||
|
||||
const float PI = 3.14159265;
|
||||
|
||||
// const vec2 FocalLen = vec2(1.0, 1.0);
|
||||
// const vec2 LinMAD = vec2(0.1-10.0, 0.1+10.0) / (2.0*0.1*10.0);
|
||||
|
||||
// const vec2 AORes = vec2(1024.0, 768.0);
|
||||
// const vec2 InvAORes = vec2(1.0/1024.0, 1.0/768.0);
|
||||
// const vec2 NoiseScale = vec2(1024.0, 768.0) / 4.0;
|
||||
|
||||
const float AOStrength = 1.9;
|
||||
|
||||
// const float R = 0.3;
|
||||
// const float R2 = 0.3*0.3;
|
||||
// const float NegInvR2 = - 1.0 / (0.3*0.3);
|
||||
|
||||
const float R = 0.01;
|
||||
const float R2 = 0.01*0.01;
|
||||
const float NegInvR2 = - 1.0 / (0.01*0.01);
|
||||
|
@ -80,38 +69,38 @@ const int NumSamples = 4;
|
|||
|
||||
out vec4 outFragColor;
|
||||
|
||||
// float ViewSpaceZFromDepth(float d){
|
||||
// // [0,1] -> [-1,1] clip space
|
||||
// d = d * 2.0 - 1.0;
|
||||
|
||||
// // Get view space Z
|
||||
// return -1.0 / (LinMAD.x * d + LinMAD.y);
|
||||
// }
|
||||
|
||||
// vec3 UVToViewSpace(vec2 uv, float z){
|
||||
// //uv = UVToViewA * uv + UVToViewB;
|
||||
// return vec3(uv * z, z);
|
||||
// }
|
||||
|
||||
// vec3 GetViewPos(vec2 uv){
|
||||
// float z = ViewSpaceZFromDepth(texture(depthTexture, uv).r);
|
||||
// return UVToViewSpace(uv, z);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Gets the normal in view space from a normal texture.
|
||||
* uv: the uv texture coordinates to look up in the texture at.
|
||||
*/
|
||||
vec3 GetViewNormalFromTexture(vec2 uv) {
|
||||
// convert [0,1] -> [-1,1], note: since we're normalizing
|
||||
// we don't need to do v*2 - 1.0, we can just do a v-0.5
|
||||
return normalize(texture(normalTexture, uv).xyz - 0.5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the linearized depth in view space.
|
||||
* d: the depth value [0-1], usually from a depth texture to convert.
|
||||
*/
|
||||
float ViewSpaceZFromDepth(float d){
|
||||
return near / (d * depthScale - 1.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a uv coordinate and depth value into a 3D view space coordinate.
|
||||
* uv: the uv coordinates to convert
|
||||
* z: the view space depth of the uv coordinate.
|
||||
*/
|
||||
vec3 UVToViewSpace(vec2 uv, float z){
|
||||
return vec3((depthTexCoordOffset + varTexcoord * depthTexCoordScale) * z, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a uv coordinate into a 3D view space coordinate.
|
||||
* The depth of the uv coord is determined from the depth texture.
|
||||
* uv: the uv coordinates to convert
|
||||
*/
|
||||
vec3 GetViewPos(vec2 uv){
|
||||
float z = ViewSpaceZFromDepth(texture(depthTexture, uv).r);
|
||||
return UVToViewSpace(uv, z);
|
||||
|
|
Loading…
Reference in a new issue