Changeset 2931 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
- Timestamp:
- 09/11/08 17:31:36 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2930 r2931 100 100 static int winHeight = 768; 101 101 102 const float shadowSize = 4096; 102 103 103 104 static float winAspectRatio = 1.0f; … … 179 180 180 181 static Matrix4x4 matProjectionView = IdentityMatrix(); 182 183 bool renderLightView = false; 184 181 185 182 186 … … 873 877 874 878 875 // render without shading 879 880 if ((!shadowMap || !shadowTraverser) && (showShadowMap || renderLightView)) 881 { 882 if (!shadowMap) 883 shadowMap = new ShadowMap(light, shadowSize, bvh->GetBox(), camera); 884 885 if (!shadowTraverser) 886 shadowTraverser = CreateTraverser(shadowMap->GetShadowCamera()); 887 888 } 889 890 // hack 891 int oldRenderType = renderType; 892 893 if (renderLightView) 894 renderType = RenderState::FIXED; 895 896 897 // render with the specified method (forward rendering, forward + depth, deferred) 876 898 switch (renderType) 877 899 { … … 909 931 case RenderState::DEFERRED: 910 932 911 if (showShadowMap )// && shadowChanged)933 if (showShadowMap && !renderLightView)// && shadowChanged) 912 934 { 913 if (!shadowMap)914 {915 const float shadowSize = 4096;916 //const float shadowSize = 512;917 shadowMap = new ShadowMap(light, shadowSize, bvh->GetBox(), camera);918 }919 920 // change CHC state (must be done for each change of camera)921 BvhNode::SetCurrentState(1);922 923 if (!shadowTraverser)924 shadowTraverser = CreateTraverser(shadowMap->GetShadowCamera());925 926 935 shadowChanged = false; 927 928 #if 0929 state.SetRenderType(RenderState::DEFERRED);930 931 fbo->Bind();932 933 glPushAttrib(GL_VIEWPORT_BIT);934 glViewport(0, 0, texWidth, texHeight);935 936 cgGLEnableProfile(RenderState::sCgFragmentProfile);937 cgGLBindProgram(RenderState::sCgMrtFragmentProgram);938 939 cgGLEnableProfile(RenderState::sCgVertexProfile);940 cgGLBindProgram(sCgMrtVertexProgram);941 #else942 936 943 937 cgGLDisableProfile(RenderState::sCgFragmentProfile); … … 945 939 946 940 state.SetRenderType(RenderState::DEPTH_PASS); 947 #endif 941 942 // change CHC++ set of state variables (must be done for each change of camera because 943 // otherwise the temporal coherency is broken 944 BvhNode::SetCurrentState(1); 945 948 946 // the scene is rendered withouth any shading 949 947 shadowMap->ComputeShadowMap(shadowTraverser, matProjectionView); … … 1002 1000 glLightfv(GL_LIGHT1, GL_POSITION, position1); 1003 1001 1004 // actually render the scene geometry using the specified algorithm 1005 traverser->RenderScene(); 1002 1003 if (renderLightView) 1004 { 1005 // change CHC++ set of state variables (must be done for each change of camera because 1006 // otherwise the temporal coherency is broken 1007 BvhNode::SetCurrentState(1); 1008 shadowMap->RenderShadowView(shadowTraverser, matProjectionView); 1009 BvhNode::SetCurrentState(0); 1010 } 1011 else 1012 // actually render the scene geometry using the specified algorithm 1013 traverser->RenderScene(); 1006 1014 1007 1015 … … 1068 1076 glDisableClientState(GL_VERTEX_ARRAY); 1069 1077 glDisableClientState(GL_NORMAL_ARRAY); 1070 1078 1079 renderType = oldRenderType; 1071 1080 1072 1081 … … 1114 1123 traverser = CreateTraverser(camera); 1115 1124 1116 if (shadowTraverser && shadowMap)1125 if (shadowTraverser) 1117 1126 { 1127 // shadow traverser has to be recomputed (this is done on demand) 1118 1128 DEL_PTR(shadowTraverser); 1119 //shadowTraverser = CreateTraverser(shadowMap->GetShadowCamera());1120 1129 } 1121 1130 … … 1202 1211 case 'a': 1203 1212 case 'A': 1204 1213 leftKeyPressed = true; 1205 1214 break; 1206 1215 case 'd': 1207 1216 case 'D': 1208 1217 rightKeyPressed = true; 1209 1218 break; 1210 1219 case 'w': 1211 1220 case 'W': 1212 1221 upKeyPressed = true; 1213 1222 break; 1214 1223 case 's': 1215 1224 case 'S': 1216 1225 downKeyPressed = true; 1217 1226 break; 1218 1227 case 'r': 1219 1228 case 'R': 1220 { 1221 useRenderQueue = !useRenderQueue; 1222 traverser->SetUseRenderQueue(useRenderQueue); 1223 } 1229 useRenderQueue = !useRenderQueue; 1230 traverser->SetUseRenderQueue(useRenderQueue); 1231 1224 1232 break; 1225 1233 case 'b': 1226 1234 case 'B': 1227 { 1228 useTightBounds = !useTightBounds; 1229 traverser->SetUseTightBounds(useTightBounds); 1230 } 1235 useTightBounds = !useTightBounds; 1236 traverser->SetUseTightBounds(useTightBounds); 1237 break; 1238 case 'l': 1239 case 'L': 1240 renderLightView = !renderLightView; 1231 1241 break; 1232 1242 default:
Note: See TracChangeset
for help on using the changeset viewer.