- Timestamp:
- 10/01/08 17:39:41 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r2986 r2987 85 85 static CGparameter sPositionsTexCombinedSsaoParam; 86 86 87 static CGparameter sTLParam; 88 static CGparameter sTRParam; 89 static CGparameter sBRParam; 90 static CGparameter sBLParam; 87 91 88 92 //////////// … … 352 356 sOldTexParam = cgGetNamedParameter(sCgSsaoProgram, "oldTex"); 353 357 sSamplesParam = cgGetNamedParameter(sCgSsaoProgram, "samples"); 358 359 sTLParam = cgGetNamedParameter(sCgSsaoProgram, "bl"); 360 sTRParam = cgGetNamedParameter(sCgSsaoProgram, "br"); 361 sBRParam = cgGetNamedParameter(sCgSsaoProgram, "tl"); 362 sBLParam = cgGetNamedParameter(sCgSsaoProgram, "tr"); 354 363 } 355 364 else … … 691 700 ComputeViewVectors(tl, tr, bl, br); 692 701 702 cgGLSetParameter3f(sTLParam, tl.x, tl.y, tl.z); 703 cgGLSetParameter3f(sBLParam, bl.x, bl.y, bl.z); 704 cgGLSetParameter3f(sBRParam, br.x, br.y, br.z); 705 cgGLSetParameter3f(sTRParam, tr.x, tr.y, tr.z); 706 707 693 708 glBegin(GL_QUADS); 694 709 … … 750 765 } 751 766 767 768 Vector3 Interpol(float wx, float wy, Vector3 bl, Vector3 br, Vector3 tl, Vector3 tr) 769 { 770 //float3 x1 = lerp(oldColor.w, logLumScaled, 0.1f); 771 Vector3 x1 = bl * (1.0f - wx) + br * wx; 772 Vector3 x2 = tl * (1.0f - wx) + tr * wx; 773 774 Vector3 v = x1 * (1.0f - wy) + x2 * wy; 775 776 return v; 777 } 778 779 752 780 void DeferredRenderer::ComputeViewVectors(Vector3 &tl, Vector3 &tr, Vector3 &bl, Vector3 &br) 753 781 { … … 761 789 tr = Normalize(ntr - ftr); 762 790 763 const float y_angle = 0.43633231299858239423092269212215; 764 const float x_angle = 0.58177641733144319230789692282954; 765 766 const Vector3 view = mCamera->GetBaseDirection(); 767 768 Vector3 rotView1 = RotateZ(-view, x_angle); 769 Vector3 rotView = RotateX(rotView1, y_angle); 770 771 cout << "view: " << -view << endl; 772 Matrix4x4 mat; 773 774 mCamera->GetViewOrientationMatrix(mat); 775 rotView = mat * rotView; 776 777 cout << "x: " << rotView1 << " y: " << rotView << " " << tr << endl; 778 779 cout << "x: " << Magnitude(rotView1) << " y: " << Magnitude(rotView) << endl; 780 cout << "here3: " << acos(DotProd(rotView1, -view)) << " " << acos(DotProd(rotView, rotView1)) << endl; 781 } 782 791 792 Vector3 dummy = Normalize(Interpol(0, 0, bl, br, tl, tr)); 793 Vector3 dummy2 = Normalize(Interpol(0.5f, 0.5f, bl, br, tl, tr)); 794 795 cout << "here3: " << dummy2 << " " << -mCamera->GetDirection() << endl; 796 } 783 797 784 798 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r2986 r2987 53 53 54 54 return r; 55 } 56 57 float3 Interpol(float2 w, float3 bl, float3 br, float3 tl, float3 tr) 58 { 59 //float3 x1 = lerp(oldColor.w, logLumScaled, 0.1f); 60 float3 x1 = bl * (1.0f - w.x) + br * w.x; 61 float3 x2 = tl * (1.0f - w.x) + tr * w.x; 62 63 float3 v = x1 * (1.0f - w.y) + x2 * w.y; 64 65 return v; 55 66 } 56 67 … … 70 81 uniform float3 br, 71 82 uniform float3 tl, 72 uniform float3 tr 83 uniform float3 tr, 84 uniform float maxDepth 73 85 ) 74 86 { … … 105 117 float eyeSpaceDepth = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).w; 106 118 107 float rotx = offsetTransformed.x * -x_angle; 108 float roty = offsetTransformed.y * -y_angle; 109 110 float3 rotView_x = RotateY(viewDir, x_angle); 111 float3 rotView = RotateX(rotView_x, y_angle); 112 113 float3 sample_position = eyePos - rotView * eyeSpaceDepth; 119 float newOffs = 0.5f + offsetTransformed * 0.5f; 120 121 float3 rotView = normalize(Interpol(newOffs, bl, br, tl, tr)); 122 float3 sample_position = (eyePos - rotView * eyeSpaceDepth) / maxDepth; 114 123 //float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).xyz; 115 124 … … 177 186 float3 viewDir = normalize(IN.view); 178 187 179 /*const float eyeSpaceDepth = tex2D(colors, IN.texCoord.xy).w;188 /* const float eyeSpaceDepth = tex2D(colors, IN.texCoord.xy).w; 180 189 181 190 float3 sample_position = eyePos - viewDir * eyeSpaceDepth; 182 191 183 OUT.illum_col.xyz = centerPosition.xyz -sample_position;192 OUT.illum_col.xyz = centerPosition.xyz * maxDepth - sample_position; 184 193 OUT.illum_col.w = currentDepth; 185 return OUT; */186 194 return OUT; 195 */ 187 196 //const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos); 188 197 const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos, positions, 189 uniform float3 bl, 190 uniform float3 br, 191 uniform float3 tl, 192 uniform float3 tr); 198 bl, br, tl, tr, maxDepth); 193 199 194 200
Note: See TracChangeset
for help on using the changeset viewer.