- Timestamp:
- 10/01/08 16:44:23 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
r2982 r2986 10 10 winHeight=768 11 11 camPosition=483.398f 242.364f 186.078f 12 camDirection=1 0 012 #camDirection=1 0 0 13 13 lightDirection=-0.8f 1.0f -0.7f 14 14 #lightDirection=0.0f 0.0f -1.0f -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp
r2947 r2986 80 80 81 81 82 void Camera::GetProjectionMatrix(Matrix4x4 &mat) 82 void Camera::GetProjectionMatrix(Matrix4x4 &mat) const 83 83 { 84 84 glGetFloatv(GL_PROJECTION_MATRIX, (float *)mat.x); … … 86 86 87 87 88 void Camera::GetModelViewMatrix(Matrix4x4 &mat) 88 void Camera::GetModelViewMatrix(Matrix4x4 &mat) const 89 89 { 90 90 mat = mViewOrientation; … … 97 97 98 98 99 void Camera::GetViewOrientationMatrix(Matrix4x4 &mat) const 100 { 101 mat = mViewOrientation; 102 } 103 104 99 105 void Camera::CalcFrustum(Frustum &frustum) 100 106 { … … 132 138 glLoadMatrixf((float *)m.x); 133 139 } 140 134 141 135 142 … … 155 162 const Vector3 fc = pos + view * z_far; 156 163 164 cout << "fovx: " << 0.5f * mFovy * aspectRatio << " " << mFovy * 0.5f << endl; 165 157 166 Vector3 t1, t2; 158 167 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.h
r2947 r2986 72 72 /** Returns the current projection matrix. 73 73 */ 74 void GetProjectionMatrix(Matrix4x4 &mat) ;74 void GetProjectionMatrix(Matrix4x4 &mat) const; 75 75 /** Returns the current model view matrix. 76 76 */ 77 void GetModelViewMatrix(Matrix4x4 &mat); 77 void GetModelViewMatrix(Matrix4x4 &mat) const; 78 79 void GetViewOrientationMatrix(Matrix4x4 &mat) const; 78 80 /** Calculates a frustum from the projection and the modelview matrix. 79 81 */ -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r2985 r2986 715 715 } 716 716 717 Vector3 RotateY(Vector3 v, float a) 718 { 719 Vector3 r; 720 721 r.z = v.z * cos(a) - v.x * sin(a); 722 r.x = v.z * sin(a) + v.x * cos(a); 723 r.y = v.y; 724 725 return r; 726 } 727 728 729 Vector3 RotateX(Vector3 v, float a) 730 { 731 Vector3 r; 732 733 r.y = v.y * cos(a) - v.z * sin(a); 734 r.z = v.y * sin(a) + v.z * cos(a); 735 r.x = v.x; 736 737 return r; 738 } 739 740 741 Vector3 RotateZ(Vector3 v, float a) 742 { 743 Vector3 r; 744 745 r.x = v.x * cos(a) - v.y * sin(a); 746 r.y = v.x * sin(a) + v.y * cos(a); 747 r.z = v.z; 748 749 return r; 750 } 717 751 718 752 void DeferredRenderer::ComputeViewVectors(Vector3 &tl, Vector3 &tr, Vector3 &bl, Vector3 &br) … … 726 760 tl = Normalize(ntl - ftl); 727 761 tr = Normalize(ntr - ftr); 762 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; 728 781 } 729 782 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2985 r2986 83 83 OUT.color = col; 84 84 85 OUT.color.w = color.w; 86 85 OUT.color.xyz = color.w / 1e3f; 86 87 #if 1 88 89 OUT.color.w = color.w; 90 91 #else 87 92 88 93 //////////// 89 94 //-- write out logaritmic luminance for tone mapping 90 /* 95 91 96 float4 oldColor = tex2Dlod(colors, float4(IN.texCoord.xy, 0, MAX_LOD_LEVEL)); 92 97 … … 103 108 else 104 109 OUT.color.w = logLumScaled; 105 */ 110 111 #endif 112 106 113 return OUT; 107 114 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r2985 r2986 32 32 33 33 34 float3 RotateY(float3 v, float a) 35 { 36 float3 r; 37 38 r.z = v.z * cos(a) - v.x * sin(a); 39 r.x = v.z * sin(a) + v.x * cos(a); 40 r.y = v.y; 41 42 return r; 43 } 44 45 46 float3 RotateX(float3 v, float a) 47 { 48 float3 r; 49 50 r.y = v.y * cos(a) - v.z * sin(a); 51 r.z = v.y * sin(a) + v.z * cos(a); 52 r.x = v.x; 53 54 return r; 55 } 34 56 35 57 /** The ssao shader returning the an intensity value between 0 and 1 … … 43 65 uniform float scaleFactor, 44 66 uniform float3 viewDir, 45 uniform float3 eyePos 67 uniform float3 eyePos, 68 uniform sampler2D positions, 69 uniform float3 bl, 70 uniform float3 br, 71 uniform float3 tl, 72 uniform float3 tr 46 73 ) 47 74 { … … 52 79 float total_ao = 0.0; 53 80 float numSamples = 0; 81 82 const float y_angle = 0.43633231299858239423092269212215; 83 const float x_angle = 0.58177641733144319230789692282954; 54 84 55 85 for (int i = 0; i < NUM_SAMPLES; ++ i) … … 75 105 float eyeSpaceDepth = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).w; 76 106 77 float3 sample_position = eyePos - viewDir * eyeSpaceDepth; 78 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; 114 //float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).xyz; 79 115 80 116 float3 vector_to_sample = sample_position - centerPosition.xyz; … … 117 153 uniform float maxDepth, 118 154 uniform float temporalCoherence, 119 uniform float3 eyePos 155 uniform float3 eyePos, 156 uniform float3 bl, 157 uniform float3 br, 158 uniform float3 tl, 159 uniform float3 tr 120 160 ) 121 161 { … … 137 177 float3 viewDir = normalize(IN.view); 138 178 139 const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos); 179 /*const float eyeSpaceDepth = tex2D(colors, IN.texCoord.xy).w; 180 181 float3 sample_position = eyePos - viewDir * eyeSpaceDepth; 182 183 OUT.illum_col.xyz = centerPosition.xyz - sample_position; 184 OUT.illum_col.w = currentDepth; 185 return OUT;*/ 186 187 //const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos); 188 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); 140 193 141 194 … … 206 259 float4 ao = tex2D(ssaoTex, IN.texCoord.xy); 207 260 208 OUT.illum_col = col * ao.x;209 //OUT.illum_col.w = ao.w;261 //OUT.illum_col = col * ao.x; 262 OUT.illum_col = float4(ao.x,ao.x,ao.x, ao.w); 210 263 OUT.illum_col.w = col.w; 211 264
Note: See TracChangeset
for help on using the changeset viewer.