Changeset 2952 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
- Timestamp:
- 09/16/08 16:03:01 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2951 r2952 184 184 185 185 ShadowMap *shadowMap = NULL; 186 Light *light = NULL;186 DirectionalLight *light = NULL; 187 187 DeferredRenderer *ssaoShader = NULL; 188 188 189 189 190 … … 242 243 static CGprogram sCgMrtVertexProgram = NULL; 243 244 244 static CGparameter sModelViewProjMatrixParam;245 245 static CGparameter sMaxDepthParam; 246 246 static CGparameter sMaxDepthParamTex; 247 248 247 static Matrix4x4 oldViewProjMatrix; 249 248 … … 284 283 Vector3 camPos(.0f, .0f, .0f); 285 284 Vector3 camDir(.0f, 1.0f, .0f); 285 Vector3 lightDir(-0.8f, 1.0f, -0.7f); 286 286 287 287 cout << "=== reading environment file ===" << endl << endl; … … 308 308 env.GetVectorParam(string("camPosition"), camPos); 309 309 env.GetVectorParam(string("camDirection"), camDir); 310 env.GetVectorParam(string("lightDirection"), lightDir); 310 311 311 312 env.GetBoolParam(string("useLODs"), useLODs); … … 345 346 346 347 visCamera = new Camera(winWidth, winHeight, fov); 347 348 348 visCamera->SetNear(0.0f); 349 349 visCamera->Yaw(.5 * M_PI); 350 351 // create a new light 352 light = new DirectionalLight(lightDir, RgbaColor(1, 1, 1, 1)); 353 350 354 351 355 renderQueue = new RenderQueue(&state, camera); … … 449 453 sceneQuery = new SceneQuery(bvh->GetBox(), traverser); 450 454 451 //Vector3 lightDir = Normalize(Vector3(0.2, -0.8, -1));452 Vector3 lightDir = Normalize(-Vector3(0.8f, -1.0f, 0.7f));453 454 light = new Light(lightDir, RgbaColor(1, 1, 1, 1));455 456 457 455 // frame time is restarted every frame 458 456 frameTimer.Start(); … … 495 493 cgGLLoadProgram(sCgMrtVertexProgram); 496 494 497 Transform3::sModelMatrixParam = cgGetNamedParameter(sCgMrtVertexProgram, "ModelMatrix");498 sModelViewProjMatrixParam = cgGetNamedParameter(sCgMrtVertexProgram, "ModelViewProj");495 //sInvViewProjParam = cgGetNamedParameter(sCgMrtVertexProgram, "InvViewProj"); 496 Transform3::sModelMatrixParam = cgGetNamedParameter(sCgMrtVertexProgram, "ModelView"); 499 497 } 500 498 … … 757 755 glLightfv(GL_LIGHT0, GL_SPECULAR, specular); 758 756 759 GLfloat position[] = {0.8f, -1.0f, 0.7f, 0.0f}; 757 Vector3 lightDir = -light->GetDirection(); 758 GLfloat position[] = {lightDir.x, lightDir.y, lightDir.z, 0.0f}; 760 759 glLightfv(GL_LIGHT0, GL_POSITION, position); 761 760 … … 802 801 glMatrixMode(GL_PROJECTION); 803 802 glLoadIdentity(); 804 805 803 gluPerspective(fov, winAspectRatio, nearDist, farDist); 806 804 … … 823 821 if ((renderType == RenderState::DEFERRED) || (renderType == RenderState::DEPTH_PASS_DEFERRED)) 824 822 { 825 // set modelview matrix for shaders 826 cgGLSetStateMatrixParameter(sModelViewProjMatrixParam, 827 CG_GL_MODELVIEW_PROJECTION_MATRIX, 828 CG_GL_MATRIX_IDENTITY); 829 830 static Matrix4x4 identity = IdentityMatrix(); 831 cgGLSetMatrixParameterfc(Transform3::sModelMatrixParam, (const float *)identity.x); 832 } 823 cgGLSetMatrixParameterfc(Transform3::sModelMatrixParam, (const float *)IdentityMatrix().x); 824 } 833 825 } 834 826 … … 1012 1004 1013 1005 // set up lights 1014 GLfloat position[] = {0.8f, -1.0f, 0.7f, 0.0f}; 1015 glLightfv(GL_LIGHT0, GL_POSITION, position); 1016 1017 #if 0 1018 GLfloat position1[] = {-0.5f, 0.5f, 0.4f, 0.0f}; 1019 glLightfv(GL_LIGHT1, GL_POSITION, position1); 1020 #endif 1006 Vector3 lightDir = -light->GetDirection(); 1007 GLfloat lightPos[] = {lightDir.x, lightDir.y, lightDir.z, 0.0f}; 1008 glLightfv(GL_LIGHT0, GL_POSITION, lightPos); 1009 1010 // second light 1011 //GLfloat lightPos1[] = {-0.5f, 0.5f, 0.4f, 0.0f}; 1012 //glLightfv(GL_LIGHT1, GL_POSITION, lightPos1); 1013 1021 1014 1022 1015 if (renderLightView) … … 1090 1083 1091 1084 ShadowMap *sm = showShadowMap ? shadowMap : NULL; 1092 ssaoShader->Render(fbo, oldViewProjMatrix, matProjectionView, ssaoTempCohFactor, sm);1085 ssaoShader->Render(fbo, oldViewProjMatrix, matProjectionView, ssaoTempCohFactor, light, sm); 1093 1086 } 1094 1087
Note: See TracChangeset
for help on using the changeset viewer.