Changeset 2819 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Timestamp:
- 07/07/08 15:11:03 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp
r2818 r2819 8 8 namespace CHCDemoEngine 9 9 { 10 11 CGparameter Material::sDiffuseParam; 12 CGparameter Material::sDiffuseTexParam; 10 13 11 14 RgbaColor RandomColor(float a, float b) … … 60 63 61 64 if (mTexture) 65 { 62 66 mTexture->Bind(); 67 cgGLSetParameter4f(sDiffuseTexParam, mDiffuseColor.r, mDiffuseColor.g, mDiffuseColor.b, mDiffuseColor.a); 68 } 63 69 else 70 { 71 cgGLSetParameter4f(sDiffuseParam, mDiffuseColor.r, mDiffuseColor.g, mDiffuseColor.b, mDiffuseColor.a); 64 72 glBindTexture(GL_TEXTURE_2D, 0); 73 } 65 74 66 75 glMaterialfv(GL_FRONT, GL_AMBIENT, (float *)&mAmbientColor.r); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.h
r2795 r2819 2 2 #define __MATERIAL_H 3 3 4 #include "glInterface.h" 5 #include <Cg/cg.h> 6 #include <Cg/cgGL.h> 4 7 #include "common.h" 5 8 … … 69 72 void InitMaterial(); 70 73 74 static CGparameter sDiffuseParam; 75 static CGparameter sDiffuseTexParam; 71 76 72 77 protected: -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp
r2805 r2819 63 63 64 64 // test if entity 65 if (mat->IsAlphaTestEnabled() != mBuckets[idx]->mAlphaTestEnabled) 66 return false; 65 //if (mat->IsAlphaTestEnabled() != mBuckets[idx]->mAlphaTestEnabled) return false; 67 66 68 67 const bool hasTexture = (mat->GetTexture() != NULL); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
r2818 r2819 9 9 CGprofile RenderState::sCgFragmentProfile; 10 10 CGprofile RenderState::sCgVertexProfile; 11 12 CGprogram RenderState::sCgMrtFragmentProgram = NULL; 13 CGprogram RenderState::sCgMrtFragmentTexProgram = NULL; 11 14 12 15 … … 84 87 { 85 88 mTexturesEnabled = false; 89 90 cgGLBindProgram(sCgMrtFragmentProgram); 91 86 92 glDisable(GL_TEXTURE_2D); 87 93 glDisableClientState(GL_TEXTURE_COORD_ARRAY); … … 92 98 { 93 99 mTexturesEnabled = true; 100 101 cgGLBindProgram(sCgMrtFragmentTexProgram); 102 94 103 glEnable(GL_TEXTURE_2D); 95 104 glEnableClientState(GL_TEXTURE_COORD_ARRAY); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h
r2818 r2819 57 57 static CGprofile sCgVertexProfile; 58 58 59 static CGprogram sCgMrtFragmentProgram; 60 static CGprogram sCgMrtFragmentTexProgram; 61 59 62 60 63 protected: -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h
r2818 r2819 3 3 4 4 #include "glInterface.h" 5 #include <Cg/cg.h> 6 #include <Cg/cgGL.h> 5 7 #include "common.h" 6 8 #include "AxisAlignedBox3.h" 7 9 #include "Triangle3.h" 8 #include <Cg/cg.h> 9 #include <Cg/cgGL.h> 10 10 11 11 12 namespace CHCDemoEngine -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2818 r2819 23 23 #include "SceneQuery.h" 24 24 #include "RenderQueue.h" 25 #include "Material.h" 25 26 #include <Cg/cg.h> 26 27 #include <Cg/cgGL.h> … … 144 145 bool eightKeyPressed = false; 145 146 146 147 147 static Vector3 samples[32]; 148 148 GLubyte *randomNormals; 149 150 PerfTimer frameTimer, algTimer; 151 149 152 150 153 // function forward declarations … … 207 210 static CGprogram sCgMrtVertexProgram = NULL; 208 211 static CGprogram sCgSSAOProgram = NULL; 209 static CGprogram sCgMrtFragmentProgram = NULL; 212 210 213 211 214 static CGparameter sColorsTexParam; … … 217 220 //static CGparameter sModelMatrixParam; 218 221 static CGparameter sMaxDepthParam; 222 static CGparameter sMaxDepthParamTex; 219 223 220 224 const static float radius = 1e-3f; … … 394 398 } 395 399 396 sCgMrtFragmentProgram = 400 RenderState::sCgMrtFragmentTexProgram = 401 cgCreateProgramFromFile(sCgContext, 402 CG_SOURCE, 403 "src/shaders/mrt.cg", 404 RenderState::sCgFragmentProfile, 405 "fragtex", 406 NULL); 407 408 if (RenderState::sCgMrtFragmentTexProgram != NULL) 409 { 410 cgGLLoadProgram(RenderState::sCgMrtFragmentTexProgram); 411 412 sMaxDepthParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "maxDepth"); 413 Material::sDiffuseTexParam = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "diffuse"); 414 415 cgGLSetParameter1f(sMaxDepthParamTex, 10.0f / myfar); 416 } 417 else 418 cerr << "fragment tex program failed to load" << endl; 419 420 RenderState::sCgMrtFragmentProgram = 397 421 cgCreateProgramFromFile(sCgContext, 398 422 CG_SOURCE, … … 402 426 NULL); 403 427 404 if(sCgMrtFragmentProgram != NULL) 405 { 406 cgGLLoadProgram(sCgMrtFragmentProgram); 407 408 sMaxDepthParam = cgGetNamedParameter(sCgMrtFragmentProgram, "maxDepth"); 428 if (RenderState::sCgMrtFragmentProgram != NULL) 429 { 430 cgGLLoadProgram(RenderState::sCgMrtFragmentProgram); 431 432 sMaxDepthParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "maxDepth"); 433 Material::sDiffuseParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "diffuse"); 409 434 410 435 cgGLSetParameter1f(sMaxDepthParam, 10.0f / myfar); 411 436 } 412 437 else 413 cerr << " test program failed to load" << endl;438 cerr << "fragment program failed to load" << endl; 414 439 415 440 PrintGLerror("test"); … … 814 839 815 840 816 817 841 void Display() 818 842 { 819 PerfTimer frameTimer, algTimer; 843 // take time from last frame 844 elapsedTime = frameTimer.Elapsed(); 820 845 frameTimer.Start(); 821 846 … … 848 873 849 874 cgGLEnableProfile(RenderState::sCgFragmentProfile); 850 cgGLBindProgram( sCgMrtFragmentProgram);875 cgGLBindProgram(RenderState::sCgMrtFragmentProgram); 851 876 852 877 cgGLEnableProfile(RenderState::sCgVertexProfile); … … 861 886 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 862 887 888 // render without shading 889 if (depthPass) 890 { 891 state.SetDepthPass(true); 892 glDisable(GL_LIGHTING); 893 } 894 else 895 { 896 state.SetDepthPass(false); 897 glEnable(GL_LIGHTING); 898 } 899 900 901 // bring eye modelview matrix up-to-date 902 SetupEyeView(); 903 863 904 // set modelview matrix for shaders 864 905 cgGLSetStateMatrixParameter(sModelViewProjMatrixParam, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY); 865 866 // render without shading867 if (depthPass)868 {869 state.SetDepthPass(true);870 glDisable(GL_LIGHTING);871 }872 else873 {874 state.SetDepthPass(false);875 glEnable(GL_LIGHTING);876 }877 906 878 907 static Matrix4x4 identity = IdentityMatrix(); 879 880 908 cgGLSetMatrixParameterfc(SceneEntity::sModelMatrixParam, (const float *)identity.x); 881 // bring eye modelview matrix up-to-date 882 SetupEyeView(); 909 883 910 884 911 // actually render the scene geometry using one of the specified algorithms … … 931 958 932 959 glutSwapBuffers(); 933 934 elapsedTime = frameTimer.Elapsed();935 960 } 936 961 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2818 r2819 152 152 float diffuse = diffuseLight + diffuseLight2; 153 153 154 float ao = ssao(IN, positions, normals, noiseTexture); 154 //float ao = ssao(IN, positions, normals, noiseTexture); 155 float ao = 1.0f; 155 156 //OUT.color = ao; 156 157 OUT.color = ao * (ambient + diffuse) * color; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r2818 r2819 63 63 } 64 64 65 /*struct Material 66 { 67 float4 diffuse; 68 }*/ 65 69 66 pixel frag(fragin IN, uniform sampler2D tex, uniform float maxDepth) 70 71 pixel fragtex(fragin IN, uniform sampler2D tex, uniform float maxDepth, uniform float4 diffuse) 67 72 { 68 73 pixel pix; 69 74 70 pix.col = tex2D(tex, IN.texCoord.xy);75 pix.col = diffuse * tex2D(tex, IN.texCoord.xy); 71 76 pix.pos = IN.worldPos * maxDepth; 72 77 pix.norm = IN.normal; … … 75 80 return pix; 76 81 } 82 83 84 pixel frag(fragin IN, uniform float maxDepth, uniform float4 diffuse) 85 { 86 pixel pix; 87 88 pix.col = diffuse; 89 pix.pos = IN.worldPos * maxDepth; 90 pix.norm = IN.normal; 91 pix.pos.w = IN.projPos.w; 92 93 return pix; 94 }
Note: See TracChangeset
for help on using the changeset viewer.