- Timestamp:
- 09/01/08 18:33:14 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
r2888 r2892 10 10 winHeight=768 11 11 camPosition=483.398f 242.364f 186.078f 12 camDirection=0 1 0 13 //camDirection=1 0 0 12 camDirection=1 0 0 14 13 useFullScreen=0 15 14 useLODs=1 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredShader.cpp
r2879 r2892 2 2 #include "FrameBufferObject.h" 3 3 #include "RenderState.h" 4 #include "ShadowMapping.h" 4 5 5 6 … … 28 29 29 30 static CGprogram sCgDeferredProgram; 31 static CGprogram sCgDeferredShadowProgram; 30 32 static CGprogram sCgAntiAliasingProgram; 31 33 … … 37 39 static CGparameter sColorsTexAntiAliasingParam; 38 40 static CGparameter sNormalsTexAntiAliasingParam; 41 42 static CGparameter sShadowMapParam; 43 static CGparameter sPositionsTexShadowParam; 44 static CGparameter sColorsTexShadowParam; 45 static CGparameter sNormalsTexShadowParam; 46 47 static CGparameter sShadowMatrixParam; 48 49 39 50 40 51 … … 96 107 cerr << "antialiasing program failed to load" << endl; 97 108 109 sCgDeferredShadowProgram = 110 cgCreateProgramFromFile(context, 111 CG_SOURCE, 112 "src/shaders/deferred.cg", 113 RenderState::sCgFragmentProfile, 114 "main_shadow", 115 NULL); 116 117 if (sCgDeferredShadowProgram != NULL) 118 { 119 cgGLLoadProgram(sCgDeferredShadowProgram); 120 121 // we need size of texture for scaling 122 sPositionsTexShadowParam = cgGetNamedParameter(sCgDeferredShadowProgram, "positions"); 123 sColorsTexShadowParam = cgGetNamedParameter(sCgDeferredShadowProgram, "colors"); 124 sNormalsTexShadowParam = cgGetNamedParameter(sCgDeferredShadowProgram, "normals"); 125 sShadowMapParam = cgGetNamedParameter(sCgDeferredShadowProgram, "shadowMap"); 126 127 sShadowMatrixParam = cgGetNamedParameter(sCgDeferredShadowProgram, "shadowMatrix"); 128 } 129 else 130 cerr << "deferred program failed to load" << endl; 98 131 99 132 PrintGLerror("init"); … … 103 136 void DeferredShader::Render(FrameBufferObject *fbo) 104 137 { 138 cgGLEnableProfile(RenderState::sCgFragmentProfile); 139 140 glDisable(GL_ALPHA_TEST); 141 glDisable(GL_TEXTURE_2D); 142 glDisable(GL_LIGHTING); 143 144 glPushAttrib(GL_VIEWPORT_BIT); 145 glViewport(0, 0, mWidth, mHeight); 146 147 glMatrixMode(GL_PROJECTION); 148 glPushMatrix(); 149 glLoadIdentity(); 150 151 glMatrixMode(GL_MODELVIEW); 152 glPushMatrix(); 153 glLoadIdentity(); 154 155 const float offs = 0.5f; 156 glOrtho(-offs, offs, -offs, offs, 0, 1); 157 158 105 159 FirstPass(fbo); 106 160 AntiAliasing(fbo); 161 162 glEnable(GL_LIGHTING); 163 glDisable(GL_TEXTURE_2D); 164 165 glMatrixMode(GL_PROJECTION); 166 glPopMatrix(); 167 168 glMatrixMode(GL_MODELVIEW); 169 glPopMatrix(); 170 171 glPopAttrib(); 172 173 cgGLDisableProfile(RenderState::sCgFragmentProfile); 174 } 175 176 177 void DeferredShader::Render(FrameBufferObject *fbo, 178 const Matrix4x4 &matViewing, 179 ShadowMapping *shadowMapping) 180 { 181 cgGLEnableProfile(RenderState::sCgFragmentProfile); 182 183 glDisable(GL_ALPHA_TEST); 184 glDisable(GL_TEXTURE_2D); 185 glDisable(GL_LIGHTING); 186 187 glPushAttrib(GL_VIEWPORT_BIT); 188 glViewport(0, 0, mWidth, mHeight); 189 190 glMatrixMode(GL_PROJECTION); 191 glPushMatrix(); 192 glLoadIdentity(); 193 194 glMatrixMode(GL_MODELVIEW); 195 glPushMatrix(); 196 glLoadIdentity(); 197 198 const float offs = 0.5f; 199 glOrtho(-offs, offs, -offs, offs, 0, 1); 200 201 FirstPassShadow(fbo, matViewing, shadowMapping); 202 AntiAliasing(fbo); 203 204 glEnable(GL_LIGHTING); 205 glDisable(GL_TEXTURE_2D); 206 207 glMatrixMode(GL_PROJECTION); 208 glPopMatrix(); 209 210 glMatrixMode(GL_MODELVIEW); 211 glPopMatrix(); 212 213 glPopAttrib(); 214 215 cgGLDisableProfile(RenderState::sCgFragmentProfile); 107 216 } 108 217 … … 117 226 glDrawBuffers(1, mymrt + 3); 118 227 119 120 glPushAttrib(GL_VIEWPORT_BIT);121 glViewport(0, 0, mWidth, mHeight);122 123 glDisable(GL_ALPHA_TEST);124 glDisable(GL_TEXTURE_2D);125 glDisable(GL_LIGHTING);126 127 glMatrixMode(GL_PROJECTION);128 glPushMatrix();129 glLoadIdentity();130 131 glMatrixMode(GL_MODELVIEW);132 glPushMatrix();133 glLoadIdentity();134 135 const float offs = 0.5f;136 137 glOrtho(-offs, offs, -offs, offs, 0, 1);138 228 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 139 229 140 230 cgGLEnableProfile(RenderState::sCgFragmentProfile); 141 142 231 cgGLBindProgram(sCgDeferredProgram); 143 232 … … 170 259 cgGLDisableProfile(RenderState::sCgFragmentProfile); 171 260 172 glEnable(GL_LIGHTING);173 glDisable(GL_TEXTURE_2D);174 175 glMatrixMode(GL_PROJECTION);176 glPopMatrix();177 178 glMatrixMode(GL_MODELVIEW);179 glPopMatrix();180 181 glPopAttrib();182 183 261 FrameBufferObject::Release(); 184 262 … … 207 285 GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 208 286 209 glPushAttrib(GL_VIEWPORT_BIT); 210 glViewport(0, 0, mWidth, mHeight); 211 212 glDisable(GL_ALPHA_TEST); 213 glDisable(GL_TEXTURE_2D); 214 glDisable(GL_LIGHTING); 215 216 glMatrixMode(GL_PROJECTION); 217 glPushMatrix(); 218 glLoadIdentity(); 219 220 glMatrixMode(GL_MODELVIEW); 221 glPushMatrix(); 222 glLoadIdentity(); 223 224 const float offs = 0.5f; 225 226 glOrtho(-offs, offs, -offs, offs, 0, 1); 287 227 288 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 228 289 … … 258 319 259 320 cgGLDisableProfile(RenderState::sCgFragmentProfile); 260 261 glEnable(GL_LIGHTING); 262 glDisable(GL_TEXTURE_2D); 263 264 glMatrixMode(GL_PROJECTION); 265 glPopMatrix(); 266 267 glMatrixMode(GL_MODELVIEW); 268 glPopMatrix(); 269 270 glPopAttrib(); 321 322 PrintGLerror("antialiasing"); 323 } 324 325 326 void DeferredShader::FirstPassShadow(FrameBufferObject *fbo, 327 const Matrix4x4 &matViewing, 328 ShadowMapping *shadowMapping) 329 { 330 GLuint colorsTex = fbo->GetColorBuffer(0)->GetTexture(); 331 GLuint positionsTex = fbo->GetColorBuffer(1)->GetTexture(); 332 GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 333 GLuint shadowMap = shadowMapping->mFbo->GetDepthTex(); 334 335 static Matrix4x4 biasMatrix(0.5f, 0.0f, 0.0f, 0.0f, 336 0.0f, 0.5f, 0.0f, 0.0f, 337 0.0f, 0.0f, 0.5f, 0.0f, 338 0.5f, 0.5f, 0.5f, 1.0f); //bias from [-1, 1] to [0, 1] 339 340 Matrix4x4 inverseView = matViewing; 341 inverseView.Invert(); 342 343 Matrix4x4 lightProjView = shadowMapping->mLightViewMatrix * shadowMapping->mLightProjectionMatrix; 344 345 //cout << "matview:\n" << matViewing << endl; 346 //cout << "proj:\n" << shadowMapping->mLightProjectionMatrix << endl; 347 //cout << "view:\n" << shadowMapping->mLightViewMatrix << endl; 348 349 // compute combined matrix that transforms pixels into light texture space 350 /*Matrix4x4 shadowMatrix = biasMatrix * 351 shadowMapping->mLightProjectionMatrix * 352 shadowMapping->mLightViewMatrix * 353 inverseView; 354 */ 355 Matrix4x4 shadowMatrix = //inverseView * 356 lightProjView * 357 biasMatrix; 358 /* 359 Matrix4x4 shadowMatrix = biasMatrix * 360 lightProjView; 361 //inverseView; 362 */ 363 cout << "combined:\n" << shadowMatrix << endl; 364 365 fbo->Bind(); 366 glDrawBuffers(1, mymrt + 3); 367 368 369 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 370 371 cgGLEnableProfile(RenderState::sCgFragmentProfile); 372 373 cgGLBindProgram(sCgDeferredShadowProgram); 374 375 cgGLSetTextureParameter(sColorsTexShadowParam, colorsTex); 376 cgGLEnableTextureParameter(sColorsTexShadowParam); 377 378 cgGLSetTextureParameter(sPositionsTexShadowParam, positionsTex); 379 cgGLEnableTextureParameter(sPositionsTexShadowParam); 380 381 cgGLSetTextureParameter(sNormalsTexShadowParam, normalsTex); 382 cgGLEnableTextureParameter(sNormalsTexShadowParam); 383 384 cgGLSetTextureParameter(sShadowMapParam, shadowMap); 385 cgGLEnableTextureParameter(sShadowMapParam); 386 387 cgGLSetMatrixParameterfc(sShadowMatrixParam, (const float *)shadowMatrix.x); 388 389 glColor3f(1.0f, 1.0f, 1.0f); 390 391 glBegin(GL_QUADS); 392 393 float offs2 = 0.5f; 394 395 glTexCoord2f(0, 0); glVertex3f(-offs2, -offs2, -0.5f); 396 glTexCoord2f(1, 0); glVertex3f( offs2, -offs2, -0.5f); 397 glTexCoord2f(1, 1); glVertex3f( offs2, offs2, -0.5f); 398 glTexCoord2f(0, 1); glVertex3f(-offs2, offs2, -0.5f); 399 400 glEnd(); 401 402 cgGLDisableTextureParameter(sColorsTexShadowParam); 403 cgGLDisableTextureParameter(sPositionsTexShadowParam); 404 cgGLDisableTextureParameter(sNormalsTexShadowParam); 405 cgGLDisableTextureParameter(sShadowMapParam); 406 407 cgGLDisableProfile(RenderState::sCgFragmentProfile); 408 409 FrameBufferObject::Release(); 271 410 272 411 PrintGLerror("deferred shading"); … … 274 413 275 414 415 276 416 } // namespace -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredShader.h
r2879 r2892 12 12 13 13 class FrameBufferObject; 14 class ShadowMapping; 15 class Matrix4x4; 14 16 15 17 … … 36 38 37 39 40 void Render(FrameBufferObject *fbo, 41 const Matrix4x4 &matViewing, 42 ShadowMapping *shadowMapping); 43 38 44 protected: 39 45 40 46 void FirstPass(FrameBufferObject *fbo); 47 void FirstPassShadow(FrameBufferObject *fbo, 48 const Matrix4x4 &matViewing, 49 ShadowMapping *shadowMapping); 50 41 51 void AntiAliasing(FrameBufferObject *fbo); 52 53 54 ////////////////// 42 55 43 56 int mWidth; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RndGauss.h
r2886 r2892 43 43 xf = 1e-20f; 44 44 assert( xf <= 1.0f); 45 assert( (input.y y >= 0.f) && (input.yy <= 1.0f));45 assert( (input.y >= 0.f) && (input.y <= 1.0f)); 46 46 47 47 // Here we have to use natural logarithm function ! -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp
r2889 r2892 166 166 glPushMatrix(); 167 167 168 169 168 glOrtho(+xlen, -xlen, ylen, -ylen, 0.0f, mSceneBox.Size().z); 170 169 … … 188 187 189 188 GrabDepthBuffer(mDepth, fbo->GetDepthTex()); 190 ExportDepthBuffer(mDepth); PrintGLerror("grab");189 //ExportDepthBuffer(mDepth); PrintGLerror("grab"); 191 190 192 191 DEL_PTR(fbo); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp
r2891 r2892 93 93 ShadowMapping::~ShadowMapping() 94 94 { 95 if (sCgShadowProgram) 96 cgDestroyProgram(sCgShadowProgram); 97 95 //if (sCgShadowProgram) cgDestroyProgram(sCgShadowProgram); 98 96 DEL_PTR(mFbo); 99 97 } … … 126 124 mLight = light; 127 125 128 const float xlen = Magnitude(mSceneBox.Diagonal() * 0.5f);129 const float ylen = Magnitude(mSceneBox.Diagonal() * 0.5f);126 const float xlen = Magnitude(mSceneBox.Diagonal());// * 0.5f); 127 const float ylen = Magnitude(mSceneBox.Diagonal());// * 0.5f); 130 128 131 129 mShadowCam->SetDirection(light->GetDirection()); … … 138 136 139 137 mFbo->Bind(); 140 138 141 139 glDrawBuffers(1, mrt); 142 140 … … 150 148 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 151 149 152 glPolygonOffset(1.0f, 40 00.0f);153 //glEnable(GL_POLYGON_OFFSET_FILL);150 glPolygonOffset(1.0f, 40.0f); 151 glEnable(GL_POLYGON_OFFSET_FILL); 154 152 155 153 glShadeModel(GL_FLAT); … … 158 156 glMatrixMode(GL_PROJECTION); 159 157 glPushMatrix(); 160 161 glOrtho(+xlen, -xlen, ylen, -ylen, 0.0f, Magnitude(mSceneBox.Diagonal())); 158 glLoadIdentity(); 159 160 glOrtho(+xlen, -xlen, +ylen, -ylen, 0.0f, 100);//Magnitude(mSceneBox.Diagonal())); 161 162 162 163 163 glMatrixMode(GL_MODELVIEW); 164 164 glPushMatrix(); 165 165 166 glLoadIdentity(); 167 168 166 169 mShadowCam->SetupCameraView(); 167 168 mShadowCam->GetModelViewMatrix(mShadowMatrix); 170 mShadowCam->GetModelViewMatrix(mLightViewMatrix); 171 172 mShadowCam->GetProjectionMatrix(mLightProjectionMatrix); 173 //glGetFloatv(GL_MODELVIEW_MATRIX, (float *)mLightProjectionMatrix.x); 169 174 170 175 traverser->RenderScene(); 171 176 172 177 glDisable(GL_POLYGON_OFFSET_FILL); 173 178 glMatrixMode(GL_MODELVIEW); 174 179 glPopMatrix(); 175 180 … … 184 189 ExportDepthBuffer(data, mSize); 185 190 186 delete [] data;*/ 191 delete [] data; 192 */ 193 PrintGLerror("shadow map"); 187 194 188 195 FrameBufferObject::Release(); … … 270 277 0.5f, 0.5f, 0.5f, 1.0f); //bias from [-1, 1] to [0, 1] 271 278 272 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);279 /*glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 273 280 274 281 // update the camera, so that the user can have a free look … … 280 287 281 288 cam->SetupCameraView(); 282 289 */ 283 290 // store the inverse of the resulting modelview matrix for the shadow computation 284 291 glGetFloatv(GL_MODELVIEW_MATRIX, (float *)cam_inverse_modelview.x); … … 287 294 // bind shadow map 288 295 glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, mFbo->GetDepthTex()); 289 290 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);291 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);292 293 PrintGLerror("texture");294 296 295 297 // compute a matrix that transforms from camera eye space to light clip space … … 300 302 301 303 glLoadMatrixf((float *)biasMatrix.x); 302 glMultMatrixf((float *)m ShadowMatrix.x);304 glMultMatrixf((float *)mLightViewMatrix.x); 303 305 304 306 // multiply the light's (bias * crop * proj * modelview) by the inverse camera modelview … … 308 310 RgbaColor white(1, 1, 1, 0); 309 311 RgbaColor dark(0.2, 0.2, 0.2, 0); 312 313 glDisable(GL_LIGHTING); 314 315 /*glDisable(GL_LIGHT0); 316 glDisable(GL_LIGHT1); 310 317 311 318 //Use dim light to represent shadowed areas … … 315 322 //glLightfv(GL_LIGHT1, GL_SPECULAR, black); 316 323 glEnable(GL_LIGHT1); 317 glEnable(GL_LIGHTING); 318 319 324 glEnable(GL_LIGHTING);*/ 325 326 PrintGLerror("firstpass"); 327 320 328 // finally, draw the scene 321 329 traverser->RenderScene(); 322 330 323 331 332 glEnable(GL_LIGHTING); 333 324 334 325 335 //3rd pass 326 336 //Draw with bright light 327 glLightfv(GL_LIGHT1, GL_DIFFUSE, (float *)&white.r); 328 glLightfv(GL_LIGHT1, GL_SPECULAR, (float *)&white.r); 329 330 Matrix4x4 textureMatrix;// = biasMatrix * mLightProjectionMatrix * mLightViewMatrix; 337 //glLightfv(GL_LIGHT1, GL_DIFFUSE, (float *)&white.r); 338 //glLightfv(GL_LIGHT1, GL_SPECULAR, (float *)&white.r); 339 340 Matrix4x4 textureMatrix = biasMatrix * mLightProjectionMatrix * mLightViewMatrix; 341 342 Matrix4x4 texMatT = Transpose(textureMatrix); 331 343 332 344 //Set up texture coordinate generation. 333 345 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); 334 //glTexGenfv(GL_S, GL_EYE_PLANE, textureMatrix.GetRow(0));346 glTexGenfv(GL_S, GL_EYE_PLANE, texMatT.x[0]); 335 347 glEnable(GL_TEXTURE_GEN_S); 336 348 337 349 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); 338 //glTexGenfv(GL_T, GL_EYE_PLANE, textureMatrix.GetRow(1));350 glTexGenfv(GL_T, GL_EYE_PLANE, texMatT.x[1]); 339 351 glEnable(GL_TEXTURE_GEN_T); 340 352 341 353 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); 342 //glTexGenfv(GL_R, GL_EYE_PLANE, textureMatrix.GetRow(2));354 glTexGenfv(GL_R, GL_EYE_PLANE, texMatT.x[2]); 343 355 glEnable(GL_TEXTURE_GEN_R); 344 356 345 357 glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); 346 //glTexGenfv(GL_Q, GL_EYE_PLANE, textureMatrix.GetRow(3));358 glTexGenfv(GL_Q, GL_EYE_PLANE, texMatT.x[3]); 347 359 glEnable(GL_TEXTURE_GEN_Q); 348 360 … … 363 375 glAlphaFunc(GL_GEQUAL, 0.99f); 364 376 glEnable(GL_ALPHA_TEST); 377 378 PrintGLerror("texture"); 365 379 366 380 traverser->RenderScene(); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.h
r2891 r2892 42 42 void ComputeShadowMap(Light *light, RenderTraverser *traverser); 43 43 44 protected:44 //protected: 45 45 46 46 FrameBufferObject *mFbo; … … 52 52 Camera *mShadowCam; 53 53 54 Matrix4x4 mShadowMatrix; 54 Matrix4x4 mLightViewMatrix; 55 Matrix4x4 mLightProjectionMatrix; 55 56 56 57 Light *mLight; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2891 r2892 94 94 static int winWidth = 1024; 95 95 static int winHeight = 768; 96 97 //static int winWidth = 512; 98 //static int winHeight = 512; 99 100 96 101 static float winAspectRatio = 1.0f; 97 102 … … 107 112 static int texHeight = 768; 108 113 109 //static int texWidth = 512;110 //static int texHeight = 384;111 112 //static int texWidth = 2048;113 //static int texHeight = 2048;114 114 115 115 int renderedObjects = 0; … … 175 175 176 176 static Matrix4x4 matProjectionView = IdentityMatrix(); 177 static Matrix4x4 matViewing = IdentityMatrix(); 177 178 178 179 ShadowMapping *shadowMapping = NULL; … … 434 435 ShadowMapping::Init(sCgContext); 435 436 436 //deferredShader = new DeferredShader(texWidth, texHeight);437 //ssaoShader = new SsaoShader(texWidth, texHeight, camera, myfar / 10.0f);438 439 437 440 438 // initialize the render traverser … … 448 446 449 447 shadowMapping = new ShadowMapping(bvh->GetBox(), 512); 450 shadowMapping->ComputeShadowMap(light, traverser); 451 448 452 449 // frame time is restarted every frame 453 450 frameTimer.Start(); … … 795 792 camera->SetupCameraView(); 796 793 797 // set lights 798 GLfloat position[] = {0.8f, -1.0f, 0.7f, 0.0f}; 799 glLightfv(GL_LIGHT0, GL_POSITION, position); 800 801 GLfloat position1[] = {-0.5f, 0.5f, 0.4f, 0.0f}; 802 glLightfv(GL_LIGHT1, GL_POSITION, position1); 803 804 794 805 795 ///////////////// 806 796 807 Matrix4x4 mat Viewing, matProjection;797 Matrix4x4 matProjection; 808 798 809 799 camera->GetModelViewMatrix(matViewing); … … 876 866 } 877 867 878 879 //shadowMapping->ComputeShadowMap(light, traverser);880 881 882 883 868 // render without shading 884 869 switch (renderType) … … 918 903 case RenderState::DEFERRED: 919 904 905 shadowMapping->ComputeShadowMap(light, traverser); 906 920 907 if (!fbo) InitFBO(); 921 908 … … 958 945 SetupEyeView(); 959 946 960 // actually render the scene geometry using one of the specified algorithms 947 // set up lights 948 GLfloat position[] = {0.8f, -1.0f, 0.7f, 0.0f}; 949 glLightfv(GL_LIGHT0, GL_POSITION, position); 950 951 GLfloat position1[] = {-0.5f, 0.5f, 0.4f, 0.0f}; 952 glLightfv(GL_LIGHT1, GL_POSITION, position1); 953 954 // actually render the scene geometry using the specified algorithm 961 955 traverser->RenderScene(); 962 963 956 964 957 … … 999 992 { 1000 993 if (!ssaoShader) ssaoShader = new SsaoShader(texWidth, texHeight, camera, myfar / 10.0f); 1001 //DEL_PTR(deferredShader);1002 994 ssaoShader->Render(fbo, oldViewProjMatrix, ssaoExpFactor); 1003 995 … … 1006 998 { 1007 999 if (!deferredShader) deferredShader = new DeferredShader(texWidth, texHeight); 1008 //DEL_PTR(ssaoShader); 1009 deferredShader->Render(fbo); 1000 1001 //deferredShader->Render(fbo); 1002 deferredShader->Render(fbo, matViewing, shadowMapping); 1010 1003 } 1011 1004 } 1012 else 1013 { 1014 /*DEL_PTR(fbo); 1015 DEL_PTR(ssaoShader); 1016 DEL_PTR(deferredShader); 1017 */ 1018 } 1005 1019 1006 1020 1007 /////////// … … 1498 1485 const float offs = box.Size().x * 0.3f; 1499 1486 1500 //Vector3 vizpos = Vector3(box.Min().x, box.Min().y + box.Size().y * 0.5f, box.Min().z + box.Size().z * 50);1501 1487 Vector3 vizpos = Vector3(box.Min().x, box.Min().y - box.Size().y * 0.35f, box.Min().z + box.Size().z * 50); 1502 1488 1503 1489 visCamera->SetPosition(vizpos); 1504 1490 visCamera->ResetPitchAndYaw(); 1505 //visCamera->Pitch(M_PI); 1506 1491 1507 1492 glPushAttrib(GL_VIEWPORT_BIT); 1508 1493 glViewport(winWidth - winWidth / 3, winHeight - winHeight / 3, winWidth / 3, winHeight / 3); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
r2891 r2892 9 9 #define SAMPLE_INTENSITY 0.28f 10 10 11 //#define AREA_SIZE 50e-1f 11 12 #define AREA_SIZE 5e-1f 12 //#define AREA_SIZE 3e-1f13 13 14 14 #define VIEW_CORRECTION_SCALE 0.0f 15 15 //#define VIEW_CORRECTION_SCALE 0.1f 16 16 17 //#define DISTANCE_SCALE 1e-6f 17 18 #define DISTANCE_SCALE 1e-6f 18 19 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2887 r2892 49 49 uniform sampler2D colors, 50 50 uniform sampler2D positions, 51 uniform sampler2D normals 51 uniform sampler2D normals 52 52 ) 53 53 { … … 72 72 return OUT; 73 73 } 74 75 /** The mrt shader for standard rendering 76 */ 77 pixel main_shadow(fragment IN, 78 uniform sampler2D colors, 79 uniform sampler2D positions, 80 uniform sampler2D normals, 81 uniform sampler2D shadowMap, 82 uniform float4x4 shadowMatrix 83 ) 84 { 85 pixel OUT; 86 87 float4 norm = tex2D(normals, IN.texCoord.xy); 88 float4 color = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 89 float4 position = tex2D(positions, IN.texCoord.xy); 90 91 float4 lightSpacePos = mul(shadowMatrix, position); 92 93 float shadowDepth = tex2D(shadowMap, IN.texCoord.xy); 94 95 // an ambient color term 96 float amb = norm.w; 97 98 float3 normal = normalize(norm.xyz); 99 float4 col = shade(IN, color, position, normal, amb); 100 101 OUT.color = col; 102 103 if (lightSpacePos.z / lightSpacePos.w < shadowDepth) 104 { 105 OUT.color *= 0.1f; 106 } 107 108 //OUT.color = float4(lightSpacePos.z / lightSpacePos.w); 109 //OUT.color = float4(shadowDepth); 110 OUT.color.w = color.w; 111 112 return OUT; 113 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg
r2891 r2892 13 13 float3 view: COLOR0; 14 14 }; 15 16 15 17 16 … … 67 66 for (int i = 0; i < NUM_SAMPLES; i ++) 68 67 { 69 //float2 offset = samples[i];70 float3 offset = float3(samples[i], 0);68 float2 offset = samples[i]; 69 //float3 offset = float3(samples[i], 0); 71 70 72 71 //sample noisetex; r stores costheta, g stores sintheta 73 //float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy;74 float3 mynoise = float3(tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy, 0);75 76 // r otation77 float2 offsetTransformed = reflect(offset, mynoise);72 float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy; 73 //float3 mynoise = float3(tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy, 0); 74 75 // reflect sampling using the noise texture 76 float2 offsetTransformed = myreflect(offset, mynoise); 78 77 79 78 // weight with projected coordinate to reach similar kernel size for near and far -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r2891 r2892 56 56 for (int i = 0; i < NUM_SAMPLES; ++ i) 57 57 { 58 //const float2 offset = samples[i];59 const float3 offset = float3(samples[i], 0);58 const float2 offset = samples[i]; 59 //const float3 offset = float3(samples[i], 0); 60 60 61 61 //////////////////// … … 63 63 64 64 //const float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f; 65 //float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy;66 float3 mynoise = float3(tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy,0);65 float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy; 66 //float3 mynoise = float3(tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy,0); 67 67 68 const float2 offsetTransformed = reflect(offset, mynoise);68 const float2 offsetTransformed = myreflect(offset, mynoise); 69 69 70 70 // weight with projected coordinate to reach similar kernel size for near and far
Note: See TracChangeset
for help on using the changeset viewer.