Changeset 2988 for GTP/trunk/App
- Timestamp:
- 10/02/08 10:05:06 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp
r2986 r2988 162 162 const Vector3 fc = pos + view * z_far; 163 163 164 cout << "fovx: " << 0.5f * mFovy * aspectRatio << " " << mFovy * 0.5f << endl;165 166 164 Vector3 t1, t2; 167 165 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r2987 r2988 357 357 sSamplesParam = cgGetNamedParameter(sCgSsaoProgram, "samples"); 358 358 359 sTLParam = cgGetNamedParameter(sCgSsaoProgram, " bl");360 sTRParam = cgGetNamedParameter(sCgSsaoProgram, " br");361 sBRParam = cgGetNamedParameter(sCgSsaoProgram, " tl");362 sBLParam = cgGetNamedParameter(sCgSsaoProgram, " tr");359 sTLParam = cgGetNamedParameter(sCgSsaoProgram, "tl"); 360 sTRParam = cgGetNamedParameter(sCgSsaoProgram, "tr"); 361 sBRParam = cgGetNamedParameter(sCgSsaoProgram, "br"); 362 sBLParam = cgGetNamedParameter(sCgSsaoProgram, "bl"); 363 363 } 364 364 else … … 676 676 cgGLSetParameter1f(sMaxDepthParam, mScaleFactor); 677 677 678 Vector3 pos = mCamera->GetPosition() ;678 Vector3 pos = mCamera->GetPosition() / mScaleFactor; 679 679 cgGLSetParameter3f(sEyePosParam, pos.x, pos.y, pos.z); 680 680 … … 700 700 ComputeViewVectors(tl, tr, bl, br); 701 701 702 cgGLSetParameter3f(sTLParam, tl.x, tl.y, tl.z);703 702 cgGLSetParameter3f(sBLParam, bl.x, bl.y, bl.z); 704 703 cgGLSetParameter3f(sBRParam, br.x, br.y, br.z); 704 cgGLSetParameter3f(sTLParam, tl.x, tl.y, tl.z); 705 705 cgGLSetParameter3f(sTRParam, tr.x, tr.y, tr.z); 706 706 … … 730 730 } 731 731 732 Vector3 RotateY(Vector3 v, float a)733 {734 Vector3 r;735 736 r.z = v.z * cos(a) - v.x * sin(a);737 r.x = v.z * sin(a) + v.x * cos(a);738 r.y = v.y;739 740 return r;741 }742 743 744 Vector3 RotateX(Vector3 v, float a)745 {746 Vector3 r;747 748 r.y = v.y * cos(a) - v.z * sin(a);749 r.z = v.y * sin(a) + v.z * cos(a);750 r.x = v.x;751 752 return r;753 }754 755 756 Vector3 RotateZ(Vector3 v, float a)757 {758 Vector3 r;759 760 r.x = v.x * cos(a) - v.y * sin(a);761 r.y = v.x * sin(a) + v.y * cos(a);762 r.z = v.z;763 764 return r;765 }766 767 732 768 733 Vector3 Interpol(float wx, float wy, Vector3 bl, Vector3 br, Vector3 tl, Vector3 tr) … … 788 753 tl = Normalize(ntl - ftl); 789 754 tr = Normalize(ntr - ftr); 790 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 755 } 797 756 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2986 r2988 83 83 OUT.color = col; 84 84 85 OUT.color.xyz = color.w / 1e3f;85 OUT.color.xyz = color.w; 86 86 87 87 #if 1 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r2984 r2988 95 95 // hack: squeeze some information about ambient into the texture 96 96 //pix.col.w = glstate.material.emission.x; 97 pix.col.w = length( currentPos - IN.worldPos);97 pix.col.w = length((currentPos - IN.worldPos) * maxDepth); 98 98 99 99 return pix; … … 118 118 // hack: squeeze some information about the ambient term into the target 119 119 //pix.col.w = glstate.material.emission.x; 120 pix.col.w = length( currentPos - IN.worldPos);120 pix.col.w = length((currentPos - IN.worldPos) * maxDepth); 121 121 122 122 return pix; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r2987 r2988 55 55 } 56 56 57 57 58 float3 Interpol(float2 w, float3 bl, float3 br, float3 tl, float3 tr) 58 59 { 59 60 //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;61 float3 x1 = lerp(bl, tl, w.y); //bl * (1.0f - w.x) + br * w.x; 62 float3 x2 = lerp(br, tr, w.y); //tl * (1.0f - w.x) + tr * w.x; 63 64 float3 v = lerp(x1, x2, w.x); //x1 * (1.0f - w.y) + x2 * w.y; 64 65 65 66 return v; 66 67 } 68 69 70 float2 Interpol2(float2 w, float2 bl, float2 br, float2 tl, float2 tr) 71 { 72 //float3 x1 = lerp(oldColor.w, logLumScaled, 0.1f); 73 float2 x1 = lerp(bl, tl, w.y); //bl * (1.0f - w.x) + br * w.x; 74 float2 x2 = lerp(br, tr, w.y); //tl * (1.0f - w.x) + tr * w.x; 75 76 float2 v = lerp(x1, x2, w.x); //x1 * (1.0f - w.y) + x2 * w.y; 77 78 return v; 79 } 80 67 81 68 82 /** The ssao shader returning the an intensity value between 0 and 1 … … 81 95 uniform float3 br, 82 96 uniform float3 tl, 83 uniform float3 tr, 84 uniform float maxDepth 97 uniform float3 tr 85 98 ) 86 99 { … … 92 105 float numSamples = 0; 93 106 94 const float y_angle = 0.43633231299858239423092269212215;95 const float x_angle = 0.58177641733144319230789692282954;96 107 97 108 for (int i = 0; i < NUM_SAMPLES; ++ i) … … 117 128 float eyeSpaceDepth = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).w; 118 129 119 float newOffs = 0.5f + offsetTransformed * 0.5f;130 float2 newOffs = 0.5f + offsetTransformed * 0.5f; 120 131 121 132 float3 rotView = normalize(Interpol(newOffs, bl, br, tl, tr)); 122 float3 sample_position = (eyePos - rotView * eyeSpaceDepth) / maxDepth;133 float3 sample_position = eyePos - rotView * eyeSpaceDepth; 123 134 //float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).xyz; 124 135 … … 180 191 // the current world position 181 192 const float4 centerPosition = tex2D(positions, IN.texCoord.xy); 182 // the current color 193 194 const float eyeDepth = tex2D(colors, IN.texCoord.xy).w; 195 float3 view2 = normalize(Interpol(IN.texCoord.xy, bl, br, tl, tr)); 196 197 float4 centerPosition2; 198 centerPosition2.xyz = eyePos - view2 * eyeDepth; 199 // the current depth 183 200 const float currentDepth = centerPosition.w; 184 201 … … 186 203 float3 viewDir = normalize(IN.view); 187 204 188 /* const float eyeSpaceDepth = tex2D(colors, IN.texCoord.xy).w;189 190 float3 sample_position = eyePos - viewDir * eyeSpaceDepth;191 192 OUT.illum_col.xyz = centerPosition.xyz * maxDepth - sample_position;193 OUT.illum_col.w = currentDepth;194 return OUT;195 */196 205 //const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos); 197 const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition , w, viewDir, eyePos, positions,198 bl, br, tl, tr , maxDepth);206 const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition2, w, viewDir, eyePos, positions, 207 bl, br, tl, tr); 199 208 200 209
Note: See TracChangeset
for help on using the changeset viewer.