- Timestamp:
- 09/15/08 01:43:13 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
r2901 r2945 10 10 winHeight=768 11 11 camPosition=483.398f 242.364f 186.078f 12 camDirection= 0 1012 camDirection=1 0 0 13 13 useFullScreen=0 14 14 useLODs=1 15 shadowSize=2048 15 16 #modelPath=data/city/model/ 16 17 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Plane3.cpp
r2944 r2945 121 121 mD = -w / mag; 122 122 123 /* 123 124 // find point on plane 124 /*const Vector3 pt = mNormal * -mD;125 const Vector3 pt = mNormal * -mD; 125 126 126 127 // transform point 127 128 const Vector3 newPt = m * pt; 129 128 130 // transform normal 129 const Vector3 newNormal = TransformNormal(m, newPt);131 nNormal = Normalize(TransformNormal(m, newPt)); 130 132 131 const float mag = Magnitude(newNormal); 132 133 return Plane3(newNormal / mag, newPt / mag);*/ 133 mD = -DotProd(mNormal, newPt); 134 */ 134 135 } 135 136 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp
r2944 r2945 282 282 //-- first find the free parameter values n, and P (the projection center), and the projection depth 283 283 284 //const float n = ComputeN(bounds_ls); 285 const float n = ComputeNOpt(lightSpace, extremalPoints, body); 286 287 cout << "n: " << n << endl; 284 const float n = ComputeN(bounds_ls); 285 //const float n = ComputeNOpt(lightSpace, extremalPoints, body); cout << "n: " << n << endl; 288 286 289 287 if (n >= 1e6f) // light direction nearly parallel to view => switch to uniform -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2944 r2945 100 100 static int winHeight = 768; 101 101 102 //const float shadowSize = 4096; 103 const float shadowSize = 2048; 102 int shadowSize = 2048; 104 103 105 104 static float winAspectRatio = 1.0f; … … 313 312 314 313 env.GetBoolParam(string("useLODs"), useLODs); 314 env.GetIntParam(string("shadowSize"), shadowSize); 315 315 316 316 //env.GetStringParam(string("modelPath"), model_path); … … 330 330 cout << "camPosition: " << camPos << endl; 331 331 cout << "temporal coherence: " << ssaoTempCohFactor << endl; 332 cout << "shadow size: " << shadowSize << endl; 332 333 333 334 //cout << "model path: " << model_path << endl; … … 747 748 glEnable(GL_LIGHTING); 748 749 glEnable(GL_LIGHT0); 749 glEnable(GL_LIGHT1); 750 751 GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0}; 750 751 /////////// 752 //-- first light: sunlight 753 754 //GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0}; 755 GLfloat ambient[] = {0.5, 0.5, 0.5, 1.0}; 752 756 GLfloat diffuse[] = {1.0, 1.0, 1.0, 1.0}; 753 757 GLfloat specular[] = {1.0, 1.0, 1.0, 1.0}; 754 755 GLfloat lmodel_ambient[] = {0.3f, 0.3f, 0.3f, 1.0f};756 758 757 759 glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); … … 759 761 glLightfv(GL_LIGHT0, GL_SPECULAR, specular); 760 762 763 GLfloat position[] = {0.8f, -1.0f, 0.7f, 0.0f}; 764 glLightfv(GL_LIGHT0, GL_POSITION, position); 765 766 #if 0 761 767 762 768 //////////// 763 769 //-- second light 770 771 // physically incorrect to have second directional light, 772 // but gives nicer shading for fixed function 773 774 glEnable(GL_LIGHT1); 764 775 765 776 GLfloat ambient1[] = {0.2, 0.2, 0.2, 1.0}; 766 777 GLfloat diffuse1[] = {1.0, 1.0, 1.0, 1.0}; 767 //GLfloat diffuse1[] = {0.5, 0.5, 0.5, 1.0};768 778 GLfloat specular1[] = {0.0, 0.0, 0.0, 1.0}; 769 779 … … 772 782 glLightfv(GL_LIGHT1, GL_SPECULAR, specular1); 773 783 774 775 //////////////////////////////776 777 GLfloat position[] = {0.8f, -1.0f, 0.7f, 0.0f};778 glLightfv(GL_LIGHT0, GL_POSITION, position);779 780 784 GLfloat position1[] = {-0.5f, 0.5f, 0.4f, 0.0f}; 781 785 glLightfv(GL_LIGHT1, GL_POSITION, position1); 786 787 //GLfloat lmodel_ambient[] = {0.3f, 0.3f, 0.3f, 1.0f}; 788 789 #endif 790 791 ////////////////////////////// 792 793 GLfloat lmodel_ambient[] = {0.5f, 0.5f, 0.5f, 1.0f}; 782 794 783 795 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); … … 1006 1018 glLightfv(GL_LIGHT0, GL_POSITION, position); 1007 1019 1020 #if 0 1008 1021 GLfloat position1[] = {-0.5f, 0.5f, 0.4f, 0.0f}; 1009 1022 glLightfv(GL_LIGHT1, GL_POSITION, position1); 1010 1023 #endif 1011 1024 1012 1025 if (renderLightView) -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2944 r2945 35 35 uniform float amb) 36 36 { 37 float4 lightDir = float4(0.8f, -1.0f, 0.7f, 0.0f); 38 //float4 lightDir = float4(0.0f, 1.0f, 0.0f, 0.0f); 37 const float4 lightDir = float4(0.8f, -1.0f, 0.7f, 0.0f); 38 const float3 light = normalize(lightDir.xyz); 39 const float diffuseLight = saturate(dot(normal, light)); 40 41 /* 39 42 float4 lightDir2 = float4(-0.5f, 0.5f, 0.4f, 0.0f); 43 float3 light2 = normalize(lightDir2.xyz); 44 float diffuseLight2 = saturate(dot(normal, light2)); 45 */ 46 float diffuse = diffuseLight;// + diffuseLight2; 40 47 41 48 // global ambient 42 49 const float4 ambient = 0.25f; 43 44 // float3 L = normalize(lightPosition - position); 45 float3 light = normalize(lightDir.xyz); 46 float3 light2 = normalize(lightDir2.xyz); 47 48 float diffuseLight = saturate(dot(normal, light)); 49 float diffuseLight2 = saturate(dot(normal, light2)); 50 51 float diffuse = diffuseLight + diffuseLight2; 50 //const float4 ambient = 0.0f; 52 51 53 52 return (ambient + diffuse) * color * (1.0f - amb) + amb * color; … … 73 72 float amb = norm.w; 74 73 75 // expand normal 76 float3 normal = normalize(norm.xyz);// * 2.0f - float4(1.0f)); 74 float3 normal = normalize(norm.xyz); 77 75 78 76 float4 col = shade(IN, color, position, normal, amb); … … 95 93 ) 96 94 { 97 float s;98 99 95 float total_d = 0.0; 100 //float total_d = tex2D(shadowMap, lightSpacePos).x;101 96 102 97 for (int i = 0; i < NUM_SAMPLES; ++ i) … … 118 113 float shadowDepth = tex2D(shadowMap, texcoord).x; 119 114 120 total_d += step(shadowDepth, depth); 121 //total_d += length(offsetTransformed); 115 total_d += step(depth, shadowDepth); 122 116 } 123 117 … … 199 193 200 194 /* 201 195 // hard shadows 202 196 float shadowDepth = tex2D(shadowMap, lightSpacePos.xy).x; 203 197 … … 212 206 return OUT; 213 207 } 208 214 209 #else 210 215 211 216 212 pixel main_shadow(fragment IN, … … 231 227 float4 color = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 232 228 float4 position = tex2D(positions, IN.texCoord.xy); 233 234 235 // an ambient color term 236 float amb = norm.w; 237 238 float3 normal = normalize(norm.xyz); 239 float4 col = shade(IN, color, position, normal, amb); 240 241 position *= maxDepth; 242 position.w = 1.0f; 243 244 float4 lightSpacePos = mul(shadowMatrix, position); 245 lightSpacePos /= lightSpacePos.w; 246 247 OUT.color = col; 248 249 float shadowTerm = CalcShadowTerm(IN, shadowMap, sampleWidth, lightSpacePos.xy, lightSpacePos.z, samples, noiseTexture); 250 251 if (amb < 0.9f) // hack: prevent shadowing the sky 252 { 253 // base lighting 254 const float baseLighting = 0.3f; 255 OUT.color *= baseLighting + (1.0f - baseLighting) * (1.0f - shadowTerm); 256 } 257 229 230 const float3 normal = normalize(norm.xyz); 231 const float3 lightDir = normalize(float3(0.8f, -1.0f, 0.7f)); 232 233 // hack: an emmisive color term 234 float emmisive = norm.w; 235 236 // diffuse intensity 237 const float angle = saturate(dot(normal, lightDir)); 238 float diffuse = angle; 239 240 // calc diffuse illumination + shadow term 241 if ((emmisive < 0.95f) // hack: prevent shadowing the sky 242 && (angle > 1e-3f) 243 ) 244 { 245 position *= maxDepth; 246 position.w = 1.0f; 247 248 float4 lightSpacePos = mul(shadowMatrix, position); 249 lightSpacePos /= lightSpacePos.w; 250 251 float shadowTerm = CalcShadowTerm(IN, shadowMap, sampleWidth, lightSpacePos.xy, lightSpacePos.z, samples, noiseTexture); 252 253 diffuse *= shadowTerm; 254 } 255 256 // global ambient 257 const float4 ambient = 0.25f; 258 259 // base lighting 260 OUT.color = (ambient + diffuse) * color * (1.0f - emmisive) + emmisive * color; 261 258 262 // also write out depth component 259 263 OUT.color.w = color.w;
Note: See TracChangeset
for help on using the changeset viewer.