Changeset 2825 for GTP/trunk/App
- Timestamp:
- 07/09/08 03:05:23 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
r2809 r2825 216 216 </File> 217 217 <File 218 RelativePath=".\src\Environment.cpp" 219 > 220 </File> 221 <File 222 RelativePath=".\src\Environment.h" 223 > 224 </File> 225 <File 218 226 RelativePath=".\src\glInterface.h" 219 227 > -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r2802 r2825 13 13 #include "Geometry.h" 14 14 #include "RenderState.h" 15 #include "Material.h" 15 16 #include "gzstream.h" 16 17 … … 1030 1031 1031 1032 1032 void Bvh::RenderBoundsForViz(BvhNode *node, bool useTightBounds)1033 void Bvh::RenderBoundsForViz(BvhNode *node, RenderState *state, bool useTightBounds) 1033 1034 { 1034 1035 glDisable(GL_TEXTURE_2D); 1035 1036 glDisable(GL_LIGHTING); 1036 1037 glColor3f(1, 1, 1); 1037 1038 1039 // hack: for deferred shading we have to define a material 1040 static Material boxMat; 1041 boxMat.SetEmmisive(RgbaColor(1.0f, 1.0f, 1.0f, 1.0f)); 1042 1043 boxMat.Render(state); 1044 1038 1045 if (!useTightBounds) 1039 1046 { -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h
r2800 r2825 556 556 /** Render wireframe bvh for visualization purpose. 557 557 */ 558 void RenderBoundsForViz(BvhNode *node, bool useTightBounds);558 void RenderBoundsForViz(BvhNode *node, RenderState *state, bool useTightBounds); 559 559 560 560 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp
r2822 r2825 60 60 61 61 62 //void Material::Render(RenderState *state)63 62 void Material::Render(RenderState *state) 64 63 { … … 68 67 { 69 68 mTexture->Bind(); 70 71 cgGLSetParameter4f(sAmbientTexParam,72 mEmmisiveColor.r,73 mEmmisiveColor.g,74 mEmmisiveColor.b,75 mEmmisiveColor.a);76 77 cgGLSetParameter4f(sDiffuseTexParam, mDiffuseColor.r, mDiffuseColor.g, mDiffuseColor.b, mDiffuseColor.a);78 69 } 79 70 else 80 71 { 81 cgGLSetParameter4f(sAmbientParam,82 mEmmisiveColor.r,83 mEmmisiveColor.g,84 mEmmisiveColor.b,85 mEmmisiveColor.a);86 87 cgGLSetParameter4f(sDiffuseParam, mDiffuseColor.r, mDiffuseColor.g, mDiffuseColor.b, mDiffuseColor.a);88 89 72 glBindTexture(GL_TEXTURE_2D, 0); 90 73 } 91 74 92 glMaterialfv(GL_FRONT, GL_AMBIENT, (float *)&mAmbientColor.r); 93 glMaterialfv(GL_FRONT, GL_DIFFUSE, (float *)&mDiffuseColor.r); 94 glMaterialfv(GL_FRONT, GL_EMISSION, (float *)&mEmmisiveColor.r); 95 glMaterialfv(GL_FRONT, GL_SPECULAR, (float *)&mSpecularColor.r); 75 if (state->GetRenderType() == RenderState::DEFERRED) 76 { 77 if (mTexture) 78 { 79 cgGLSetParameter4f(sAmbientTexParam, mEmmisiveColor.r, mEmmisiveColor.g, mEmmisiveColor.b, mEmmisiveColor.a); 80 cgGLSetParameter4f(sDiffuseTexParam, mDiffuseColor.r, mDiffuseColor.g, mDiffuseColor.b, mDiffuseColor.a); 81 } 82 else 83 { 84 cgGLSetParameter4f(sAmbientParam, mEmmisiveColor.r, mEmmisiveColor.g, mEmmisiveColor.b, mEmmisiveColor.a); 85 cgGLSetParameter4f(sDiffuseParam, mDiffuseColor.r, mDiffuseColor.g, mDiffuseColor.b, mDiffuseColor.a); 86 } 87 } 88 else if (state->GetRenderType() == RenderState::FIXED) 89 { 90 glMaterialfv(GL_FRONT, GL_AMBIENT, (float *)&mAmbientColor.r); 91 glMaterialfv(GL_FRONT, GL_DIFFUSE, (float *)&mDiffuseColor.r); 92 glMaterialfv(GL_FRONT, GL_EMISSION, (float *)&mEmmisiveColor.r); 93 glMaterialfv(GL_FRONT, GL_SPECULAR, (float *)&mSpecularColor.r); 94 } 96 95 } 97 96 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
r2819 r2825 14 14 15 15 16 ///////////////// 17 16 18 RenderState::RenderState(): 17 19 mAlphaTestEnabled(false), 18 20 mTexturesEnabled(false), 19 21 mMode(RENDER), 20 m IsDepthPass(false)22 mRenderType(FIXED) 21 23 { 22 24 Reset(); … … 35 37 if (mode == QUERY) 36 38 { 37 if ( !mIsDepthPass)39 if (mRenderType != DEPTH_PASS) 38 40 { 39 41 glDisable(GL_LIGHTING); 40 42 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 41 43 42 cgGLDisableProfile(sCgFragmentProfile); 43 cgGLDisableProfile(sCgVertexProfile); 44 if (mRenderType == DEFERRED) 45 { 46 cgGLDisableProfile(sCgFragmentProfile); 47 cgGLDisableProfile(sCgVertexProfile); 48 } 44 49 } 45 50 … … 53 58 //-- restore render state 54 59 55 if ( !mIsDepthPass)60 if (mRenderType != DEPTH_PASS) 56 61 { 57 62 glEnable(GL_LIGHTING); 58 63 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 59 64 60 cgGLEnableProfile(sCgFragmentProfile); 61 cgGLEnableProfile(sCgVertexProfile); 65 if (mRenderType == DEFERRED) 66 { 67 cgGLEnableProfile(sCgFragmentProfile); 68 cgGLEnableProfile(sCgVertexProfile); 69 } 62 70 } 63 71 … … 82 90 } 83 91 84 // allow only alpha textures in depth pass85 92 if (mTexturesEnabled && 86 (!texturing || mIsDepthPass&& !mAlphaTestEnabled))93 (!texturing || (mRenderType == DEPTH_PASS) && !mAlphaTestEnabled)) 87 94 { 88 95 mTexturesEnabled = false; 89 96 90 cgGLBindProgram(sCgMrtFragmentProgram); 97 if (mRenderType == DEFERRED) 98 cgGLBindProgram(sCgMrtFragmentProgram); 91 99 92 100 glDisable(GL_TEXTURE_2D); … … 95 103 else if (!mTexturesEnabled && texturing) 96 104 { 97 if (!mIsDepthPass || mAlphaTestEnabled) 105 // support only alpha textures in depth pass 106 if ((mRenderType != DEPTH_PASS) || mAlphaTestEnabled) 98 107 { 99 108 mTexturesEnabled = true; 100 109 101 cgGLBindProgram(sCgMrtFragmentTexProgram); 110 if (mRenderType == DEFERRED) 111 cgGLBindProgram(sCgMrtFragmentTexProgram); 102 112 103 113 glEnable(GL_TEXTURE_2D); … … 111 121 { 112 122 mCurrentVboId = -1; 123 113 124 SetState(false, false); 114 125 SetState(RENDER); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h
r2819 r2825 22 22 QUERY, 23 23 RENDER 24 }; 25 26 enum RenderType 27 { 28 FIXED, 29 DEPTH_PASS, 30 DEFERRED 24 31 }; 25 32 … … 51 58 inline int GetCurrentVboId() { return mCurrentVboId; } 52 59 53 void SetDepthPass(bool depthPass) { mIsDepthPass = depthPass; } 54 bool IsDepthPass() { return mIsDepthPass; } 60 void SetRenderType(RenderType type) { mRenderType = type; } 61 RenderType GetRenderType() { return mRenderType; } 62 63 64 /////////////////// 55 65 56 66 static CGprofile sCgFragmentProfile; … … 70 80 int mCurrentVboId; 71 81 72 bool mIsDepthPass;82 RenderType mRenderType; 73 83 }; 74 84 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp
r2802 r2825 78 78 79 79 if (mShowBounds) 80 mBvh->RenderBoundsForViz(node, m UseTightBounds);80 mBvh->RenderBoundsForViz(node, mRenderState, mUseTightBounds); 81 81 } 82 82 else -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r2824 r2825 48 48 { 49 49 trafo = NULL; 50 sceneGeom = new SceneEntity(geom, mat, trafo);51 50 } 52 51 else … … 55 54 str.read(reinterpret_cast<char *>(trafo->x), sizeof(Matrix4x4)); 56 55 mTrafos.push_back(trafo); 57 #if 0 // use static geometry 58 Vector3 *vertices = new Vector3[geom->mNumVertices]; 59 60 for (int i = 0; i < geom->mNumVertices; ++ i) 61 { 62 Vector3 v = geom->mVertices[i]; 63 64 v = (*trafo) * v; 65 vertices[i] = v; 66 } 67 68 Geometry *tgeom = new Geometry(vertices, geom->mNormals, geom->mTexCoords, geom->mNumVertices, false); 69 70 sceneGeom = new SceneEntity(tgeom, mat, NULL); 71 #else 72 // use instancing 73 sceneGeom = new SceneEntity(geom, mat, trafo); 74 #endif 75 } 56 } 57 58 // use instancing 59 sceneGeom = new SceneEntity(geom, mat, trafo); 76 60 77 61 return sceneGeom; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp
r2823 r2825 30 30 if (mMaterial) mMaterial->Render(state); 31 31 32 static Matrix4x4 identity = IdentityMatrix();33 34 32 if (mTransform) 35 33 { 36 cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)mTransform->x); 37 //glPushMatrix(); 38 //glMultMatrixf((float *)mTransform->x); 39 mGeometry->Render(state); 34 if (state->GetRenderType() == RenderState::DEFERRED) 35 { 36 cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)mTransform->x); 40 37 41 cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)identity.x); 42 //glPopMatrix(); 38 mGeometry->Render(state); 39 40 static Matrix4x4 identity = IdentityMatrix(); 41 cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)identity.x); 42 } 43 else 44 { 45 glPushMatrix(); 46 glMultMatrixf((float *)mTransform->x); 47 48 mGeometry->Render(state); 49 50 glPopMatrix(); 51 } 43 52 } 44 53 else -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Texture.cpp
r2817 r2825 61 61 { 62 62 glEnable(GL_TEXTURE_2D); 63 63 64 glGenTextures(1, &mTexId); 64 65 glBindTexture(GL_TEXTURE_2D, mTexId); 66 65 67 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 66 //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);67 //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);68 69 68 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 70 69 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 71 72 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);73 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);74 70 75 71 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 76 72 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 77 73 74 glTexImage2D(GL_RGBA, 0, GL_RGBA, mWidth, mHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, mImage); 78 75 gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, mWidth, mHeight, GL_RGBA, GL_UNSIGNED_BYTE, mImage); 79 //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mWidth, mHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, mImage); 76 77 glBindTexture(GL_TEXTURE_2D, 0); 80 78 } 81 79 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2823 r2825 133 133 bool useMultiQueries = true; 134 134 bool flyMode = true; 135 bool depthPass = false;136 bool useGlFinish = false;137 135 138 136 SceneEntityContainer skyGeometry; … … 150 148 151 149 PerfTimer frameTimer, algTimer; 150 151 int renderType = RenderState::FIXED; 152 152 153 153 … … 340 340 } 341 341 342 // create noise texture for ssao343 CreateNoiseTex2D();344 345 346 342 const string bvh_filename = string(model_path + "city.bvh"); 347 343 BvhLoader bvhLoader; … … 360 356 InitCg(); 361 357 358 // create noise texture for ssao 359 CreateNoiseTex2D(); 360 362 361 bvh->SetCamera(camera); 363 362 363 // init render traverser 364 364 ResetTraverser(); 365 365 … … 369 369 visualization = new Visualization(bvh, camera, NULL, &state); 370 370 371 //sceneQuery = new SceneQuery(bvh->GetBox(), traverser);371 sceneQuery = new SceneQuery(bvh->GetBox(), traverser); 372 372 373 373 … … 479 479 sNormalsTexParamSsao = cgGetNamedParameter(sCgSsaoProgram, "normals"); 480 480 sNoiseTexParamSsao = cgGetNamedParameter(sCgSsaoProgram, "noiseTexture"); 481 cgGLDisableTextureParameter(sNoiseTexParamSsao); 481 482 482 483 sSamplesParamSsao = cgGetNamedParameter(sCgSsaoProgram, "samples"); … … 792 793 traverser->SetUseMultiQueries(useMultiQueries); 793 794 traverser->SetUseTightBounds(useTightBounds); 794 traverser->SetUseDepthPass( depthPass);795 traverser->SetUseDepthPass(renderType == RenderState::DEPTH_PASS); 795 796 traverser->SetRenderQueue(renderQueue); 796 797 } … … 801 802 glEnable(GL_LIGHTING); 802 803 glEnable(GL_LIGHT0); 803 //glEnable(GL_LIGHT1); 804 glDisable(GL_LIGHT1); 805 804 glEnable(GL_LIGHT1); 805 806 806 //GLfloat ambient[] = {0.5, 0.5, 0.5, 1.0}; 807 807 GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0}; … … 809 809 GLfloat specular[] = {1.0, 1.0, 1.0, 1.0}; 810 810 811 GLfloat lmodel_ambient[] = {0.5f, 0.5f, 0.5f, 1.0f};812 //GLfloat lmodel_ambient[] = {0.2f, 0.2f, 0.2f, 1.0f};811 //GLfloat lmodel_ambient[] = {0.5f, 0.5f, 0.5f, 1.0f}; 812 GLfloat lmodel_ambient[] = {0.3f, 0.3f, 0.3f, 1.0f}; 813 813 814 814 glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); … … 816 816 glLightfv(GL_LIGHT0, GL_SPECULAR, specular); 817 817 818 GLfloat position[] = {1.0, 1.0, 1.0, 0.0};819 glLightfv(GL_LIGHT0, GL_POSITION, position);820 821 818 822 819 //////////// 823 820 //-- second light 824 821 825 GLfloat ambient1[] = {0. 5, 0.5, 0.5, 1.0};826 //GLfloat diffuse1[] = {1.0, 1.0, 1.0, 1.0};827 GLfloat diffuse1[] = {0.5, 0.5, 0.5, 1.0};828 GLfloat specular1[] = {0. 5, 0.5, 0.5, 1.0};822 GLfloat ambient1[] = {0.2, 0.2, 0.2, 1.0}; 823 GLfloat diffuse1[] = {1.0, 1.0, 1.0, 1.0}; 824 //GLfloat diffuse1[] = {0.5, 0.5, 0.5, 1.0}; 825 GLfloat specular1[] = {0.0, 0.0, 0.0, 1.0}; 829 826 830 827 glLightfv(GL_LIGHT1, GL_AMBIENT, ambient1); 831 828 glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse1); 832 829 glLightfv(GL_LIGHT1, GL_SPECULAR, specular1); 833 834 GLfloat position1[] = {0.0, 1.0, 0.0, 1.0}; 830 831 832 ////////////////////////////// 833 834 GLfloat position[] = {0.8f, -1.0f, 0.7f, 0.0f}; 835 glLightfv(GL_LIGHT0, GL_POSITION, position); 836 837 GLfloat position1[] = {-0.5f, 0.5f, 0.4f, 0.0f}; 835 838 glLightfv(GL_LIGHT1, GL_POSITION, position1); 836 839 837 840 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); 838 841 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); 839 //glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);840 //glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, GL_SEPARATE_SPECULAR_COLOR_EXT);841 842 glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, GL_SINGLE_COLOR_EXT); 842 843 } … … 854 855 camera->SetupCameraView(); 855 856 856 GLfloat position[] = {0.8f, 1.0f, 1.5f, 0.0f};857 GLfloat position[] = {0.8f, -1.0f, 0.7f, 0.0f}; 857 858 glLightfv(GL_LIGHT0, GL_POSITION, position); 858 859 859 GLfloat position1[] = { bvh->GetBox().Center().x, bvh->GetBox().Center().y, bvh->GetBox().Max().z, 1.0f};860 GLfloat position1[] = {-0.5f, 0.5f, 0.4f, 0.0f}; 860 861 glLightfv(GL_LIGHT1, GL_POSITION, position1); 862 863 864 if (renderType == RenderState::DEFERRED) 865 { 866 // set modelview matrix for shaders 867 cgGLSetStateMatrixParameter(sModelViewProjMatrixParam, 868 CG_GL_MODELVIEW_PROJECTION_MATRIX, 869 CG_GL_MATRIX_IDENTITY); 870 871 static Matrix4x4 identity = IdentityMatrix(); 872 cgGLSetMatrixParameterfc(SceneEntity::sModelMatrixParam, (const float *)identity.x); 873 } 861 874 } 862 875 … … 909 922 if (!flyMode) PlaceViewer(oldPos); 910 923 911 if (useGlFinish) glFinish();912 913 924 algTimer.Start(); 914 925 915 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo); 916 917 glPushAttrib(GL_VIEWPORT_BIT); 918 glViewport(0, 0, texWidth, texHeight); 919 920 cgGLEnableProfile(RenderState::sCgFragmentProfile); 921 cgGLBindProgram(RenderState::sCgMrtFragmentProgram); 922 923 cgGLEnableProfile(RenderState::sCgVertexProfile); 924 cgGLBindProgram(sCgMrtVertexProgram); 925 926 glDrawBuffers(3, mrt); 927 926 927 // render without shading 928 switch (renderType) 929 { 930 case RenderState::FIXED: 931 932 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 933 934 state.SetRenderType(RenderState::FIXED); 935 glEnable(GL_LIGHTING); 936 937 cgGLDisableProfile(RenderState::sCgFragmentProfile); 938 cgGLDisableProfile(RenderState::sCgVertexProfile); 939 940 glDrawBuffers(1, mrt); 941 942 break; 943 944 case RenderState::DEPTH_PASS: 945 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 946 947 state.SetRenderType(RenderState::DEPTH_PASS); 948 glDisable(GL_LIGHTING); 949 950 cgGLDisableProfile(RenderState::sCgFragmentProfile); 951 cgGLDisableProfile(RenderState::sCgVertexProfile); 952 953 glDrawBuffers(1, mrt); 954 955 break; 956 957 case RenderState::DEFERRED: 958 state.SetRenderType(RenderState::DEFERRED); 959 960 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo); 961 962 glPushAttrib(GL_VIEWPORT_BIT); 963 glViewport(0, 0, texWidth, texHeight); 964 965 cgGLEnableProfile(RenderState::sCgFragmentProfile); 966 cgGLBindProgram(RenderState::sCgMrtFragmentProgram); 967 968 cgGLEnableProfile(RenderState::sCgVertexProfile); 969 cgGLBindProgram(sCgMrtVertexProgram); 970 971 glDrawBuffers(3, mrt); 972 973 break; 974 } 975 928 976 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 929 977 930 978 glDepthFunc(GL_LESS); 979 931 980 glDisable(GL_TEXTURE_2D); 932 981 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 933 934 // render without shading 935 if (depthPass) 936 { 937 state.SetDepthPass(true); 938 glDisable(GL_LIGHTING); 939 } 940 else 941 { 942 state.SetDepthPass(false); 943 glEnable(GL_LIGHTING); 944 } 945 982 946 983 947 984 // bring eye modelview matrix up-to-date 948 985 SetupEyeView(); 949 986 950 // set modelview matrix for shaders951 cgGLSetStateMatrixParameter(sModelViewProjMatrixParam, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);952 953 static Matrix4x4 identity = IdentityMatrix();954 cgGLSetMatrixParameterfc(SceneEntity::sModelMatrixParam, (const float *)identity.x);955 956 987 957 988 // actually render the scene geometry using one of the specified algorithms … … 959 990 960 991 961 ////// 992 ///////// 962 993 //-- do the rest of the rendering 963 994 … … 967 998 968 999 // reset depth pass and render visible objects 969 if ( depthPass)1000 if (renderType == RenderState::DEPTH_PASS) 970 1001 { 971 1002 RenderVisibleObjects(); … … 983 1014 glDisableClientState(GL_NORMAL_ARRAY); 984 1015 985 986 cgGLDisableProfile(RenderState::sCgVertexProfile); 987 cgGLDisableProfile(RenderState::sCgFragmentProfile); 988 989 glPopAttrib(); 990 991 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 992 993 DisplayRenderTexture(); 994 995 if (useGlFinish) glFinish(); 1016 1017 if (renderType == RenderState::DEFERRED) 1018 { 1019 glPopAttrib(); 1020 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1021 1022 cgGLDisableProfile(RenderState::sCgVertexProfile); 1023 cgGLDisableProfile(RenderState::sCgFragmentProfile); 1024 1025 glDrawBuffers(1, mrt); 1026 1027 DisplayRenderTexture(); 1028 } 1029 996 1030 997 1031 algTime = algTimer.Elapsedms(); 998 1032 1033 999 1034 /////////// 1035 1036 state.SetRenderType(RenderState::FIXED); 1000 1037 1001 1038 if (visMode) DisplayVisualization(); … … 1188 1225 break; 1189 1226 case GLUT_KEY_F7: 1190 depthPass = !depthPass; 1191 traverser->SetUseDepthPass(depthPass); 1227 1228 renderType = (renderType + 1) % 3; 1229 traverser->SetUseDepthPass(renderType == RenderState::DEPTH_PASS); 1230 1192 1231 break; 1193 1232 case GLUT_KEY_F8: 1194 useGlFinish = !useGlFinish;1195 break;1196 case GLUT_KEY_F9:1197 1233 useSsao = !useSsao; 1198 1234 break; … … 1582 1618 sprintf(msg[i ++], "assumed visible frames: %4d, max batch size: %4d", 1583 1619 assumedVisibleFrames, maxBatchSize); 1584 1585 sprintf(msg[i ++], "multiqueries: %d, tight bounds: %d, render queue: %d, depth pass: %d, glFinish: %d", 1586 useMultiQueries, useTightBounds, useRenderQueue, depthPass, useGlFinish); 1620 1621 static char *renderTypeStr[] = {"fixed function", "fixed function + depth pass", "deferred shading"}; 1622 1623 sprintf(msg[i ++], "multiqueries: %d, tight bounds: %d, render queue: %d, render technique: %s", 1624 useMultiQueries, useTightBounds, useRenderQueue, renderTypeStr[renderType]); 1587 1625 1588 1626 sprintf(msg[i ++], "triangles per virtual leaf: %5d", trianglesPerVirtualLeaf); … … 1630 1668 void RenderVisibleObjects() 1631 1669 { 1632 state.Set DepthPass(false);1670 state.SetRenderType(RenderState::FIXED); 1633 1671 state.Reset(); 1634 1672 … … 1811 1849 void CreateNoiseTex2D() 1812 1850 { 1813 randomNormals = new GLubyte[texWidth * texHeight * 4];1814 1815 for (int i = 0; i < texWidth * texHeight * 4; i += 4)1851 randomNormals = new GLubyte[texWidth * texHeight * 3]; 1852 1853 for (int i = 0; i < texWidth * texHeight * 3; i += 3) 1816 1854 { 1817 1855 // create random samples over sphere … … 1822 1860 randomNormals[i + 1] = (GLubyte)((sin(theta) * 0.5f + 0.5f) * 255.0f); 1823 1861 randomNormals[i + 2] = 0; 1824 randomNormals[i + 3] = 255;1825 1862 } 1826 1863 … … 1828 1865 glGenTextures(1, &noiseTex); 1829 1866 glBindTexture(GL_TEXTURE_2D, noiseTex); 1830 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); 1831 1832 gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, texWidth, texHeight, GL_RGBA, GL_UNSIGNED_BYTE, randomNormals); 1867 1833 1868 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1834 1869 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); … … 1836 1871 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 1837 1872 1873 //glTexImage2D(GL_RGBA, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, randomNormals); 1874 gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, texWidth, texHeight, GL_RGB, GL_UNSIGNED_BYTE, randomNormals); 1875 1838 1876 glBindTexture(GL_TEXTURE_2D, 0); 1839 1877 glDisable(GL_TEXTURE_2D); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2823 r2825 1 1 #define NUM_SAMPLES 12 2 //#define SAMPLE_INTENSITY 0.4f3 #define SAMPLE_INTENSITY 0.7f2 #define SAMPLE_INTENSITY 1.2f 3 //#define SAMPLE_INTENSITY 0.7f 4 4 #define AREA_SIZE 5e-1f 5 5 … … 102 102 float2 offsetTransformed = rotate(offset, noise); 103 103 //float2 offsetTransformed = reflect(offset, noise); 104 105 //offsetTransformed.x = noise.r * offset.x - noise.g * offset.y; 106 //offsetTransformed.y = noise.g * offset.x + noise.r * offset.y; 107 104 108 105 // weight with projected coordinate to reach similar kernel size for near and far 109 106 float2 texcoord = IN.texCoord.xy + offsetTransformed * AREA_SIZE * w; … … 118 115 float cos_angle = dot(direction_to_sample, currentNormal); 119 116 cos_angle = max(cos_angle, 0.0f); 120 117 cos_angle *= cos_angle; 118 121 119 // distance between current position and sample position controls AO intensity. 122 //const float maxdist = 2e-1f;120 //const float maxdist = 4e-1f; 123 121 const float maxdist = 5e-1f; 124 122
Note: See TracChangeset
for help on using the changeset viewer.