- Timestamp:
- 10/09/08 11:48:06 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3017 r3018 898 898 cgGLSetParameter3f(sLightDirParam, lightDir.x, lightDir.y, lightDir.z); 899 899 900 901 glColor3f(1.0f, 1.0f, 1.0f); 902 900 Vector3 tl, tr, bl, br; 901 ComputeViewVectors(tl, tr, bl, br); 902 903 // note: slightly larger texture could hide ambient occlusion error on border but costs resolution 903 904 const float offs = 0.5f; 904 905 905 906 glBegin(GL_QUADS); 906 907 907 glTexCoord2f(0, 0); gl Vertex3f(-offs, -offs, -0.5f);908 glTexCoord2f(1, 0); gl Vertex3f( offs, -offs, -0.5f);909 glTexCoord2f(1, 1); gl Vertex3f( offs, offs, -0.5f);910 glTexCoord2f(0, 1); gl Vertex3f(-offs, offs, -0.5f);908 glTexCoord2f(0, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, bl.x, bl.y, bl.z); glVertex3f(-offs, -offs, -0.5f); 909 glTexCoord2f(1, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, br.x, br.y, br.z); glVertex3f( offs, -offs, -0.5f); 910 glTexCoord2f(1, 1); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, tr.x, tr.y, tr.z); glVertex3f( offs, offs, -0.5f); 911 glTexCoord2f(0, 1); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, tl.x, tl.y, tl.z); glVertex3f(-offs, offs, -0.5f); 911 912 912 913 glEnd(); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3017 r3018 273 273 static CGparameter sEyePosParam; 274 274 275 static CGparameter sTLParam;276 static CGparameter sTRParam;277 static CGparameter sBRParam;278 static CGparameter sBLParam;279 280 static CGparameter sTLParamTex;281 static CGparameter sTRParamTex;282 static CGparameter sBRParamTex;283 static CGparameter sBLParamTex;284 285 275 static Matrix4x4 viewProjMat = IdentityMatrix(); 286 276 static Matrix4x4 oldViewProjMat = IdentityMatrix(); … … 566 556 sEyePosParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "eyePos"); 567 557 RenderState::sTexParam = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "tex"); 568 569 sTLParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "tl");570 sTRParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "tr");571 sBRParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "br");572 sBLParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "bl");573 558 } 574 559 else … … 588 573 589 574 sEyePosParam = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "eyePos"); 590 591 sTLParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "tl");592 sTRParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "tr");593 sBRParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "br");594 sBLParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "bl");595 575 } 596 576 else … … 939 919 cgGLSetParameter3f(sEyePosParamTex, pos.x, pos.y, pos.z); 940 920 941 Vector3 tl, tr, bl, br;942 ComputeViewVectors(tl, tr, bl, br);943 944 cgGLSetParameter3f(sBLParam, bl.x, bl.y, bl.z);945 cgGLSetParameter3f(sBRParam, br.x, br.y, br.z);946 cgGLSetParameter3f(sTLParam, tl.x, tl.y, tl.z);947 cgGLSetParameter3f(sTRParam, tr.x, tr.y, tr.z);948 949 //cout<<bl << " " << br << endl;950 cgGLSetParameter3f(sBLParamTex, bl.x, bl.y, bl.z);951 cgGLSetParameter3f(sBRParamTex, br.x, br.y, br.z);952 cgGLSetParameter3f(sTLParamTex, tl.x, tl.y, tl.z);953 cgGLSetParameter3f(sTRParamTex, tr.x, tr.y, tr.z);954 955 921 956 922 // draw to 3 color buffers -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r3017 r3018 78 78 79 79 OUT.color = col; 80 OUT.color.w = color.w; 80 81 // store scaled view vector from now on so wie don't have to normalize for e.g., ssao 82 float3 viewDir = IN.view; 83 const float lenView = length(viewDir); 84 85 OUT.color.w = color.w / lenView; 81 86 82 87 return OUT; … … 160 165 /// reconstruct position from the eye space depth 161 166 float3 viewDir = IN.view; 167 const float lenView = length(viewDir); 168 viewDir /= lenView; 169 162 170 const float eyeDepth = tex2Dlod(colors, float4(IN.texCoord, 0, 0)).w; 163 171 … … 195 203 OUT.color = useShading ? (ambient + diffuse) * color : color; 196 204 197 OUT.color.w = color.w; 205 // store scaled view vector from now on so wie don't have to normalize for e.g., ssao 206 OUT.color.w = color.w / lenView; 198 207 199 208 return OUT; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r3017 r3018 17 17 float4 worldPos: TEXCOORD1; // world position 18 18 float3 normal: TEXCOORD2; 19 float4 projPos: TEXCOORD3;20 19 }; 21 20 … … 31 30 float4 worldPos: TEXCOORD1; // world position 32 31 float3 normal: TEXCOORD2; 33 float4 projPos: TEXCOORD3;34 32 }; 35 33 … … 59 57 60 58 OUT.normal = IN.normal; 61 OUT.projPos = OUT.position;62 59 63 60 return OUT; … … 104 101 105 102 // compute eye linear depth 106 const float4 projPos = IN.projPos / IN.projPos.w; 107 108 float2 screenCoord = projPos.xy * 0.5f + 0.5f; 109 110 const float3 viewVec = Interpol(screenCoord, bl, br, tl, tr); 111 const float invMagView = 1.0f / length(viewVec); 112 // note: has to done in this order, otherwise strange precision problems! 113 pix.col.w = invMagView * length(eyePos - IN.worldPos.xyz); 103 pix.col.w = length(eyePos - IN.worldPos.xyz); 114 104 115 105 return pix; … … 133 123 // hack: squeeze some information about the ambient term into the target 134 124 //pix.col.w = glstate.material.emission.x; 135 136 // compute eye linear depth and scale with lenght to avoid sqr root in pixel shader 137 const float4 projPos = IN.projPos / IN.projPos.w; 138 139 float2 screenCoord = projPos.xy * 0.5f + 0.5f; 140 const float magView = length(Interpol(screenCoord, bl, br, tl, tr)); 141 pix.col.w = length(eyePos - IN.worldPos.xyz) / magView; 125 pix.col.w = length(eyePos - IN.worldPos.xyz); 142 126 143 127 return pix;
Note: See TracChangeset
for help on using the changeset viewer.