- Timestamp:
- 09/19/08 23:13:47 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
r2957 r2959 11 11 camPosition=483.398f 242.364f 186.078f 12 12 camDirection=1 0 0 13 #lightDirection=-0.8f 1.0f -0.7f 14 #lightDirection=0.2f -1.0f -.5f 15 lightDirection=0.0f 0.0f -1.0f 13 lightDirection=-0.8f 1.0f -0.7f 14 #lightDirection=0.0f 0.0f -1.0f 16 15 useFullScreen=0 17 16 useLODs=1 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp
r2955 r2959 28 28 29 29 mAmbientColor = RgbaColor(0.2f, 0.2f, 0.2f, 1.0f); 30 //mAmbientColor = RgbaColor(1.0f, 1.0f, 1.0f, 1.0f); 30 31 mDiffuseColor = RgbaColor(1.0f, 1.0f, 1.0f, 1.0f); 31 32 mSpecularColor = RgbaColor(.0f, .0f, .0f, 1.0f); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ObjConverter.cpp
r2958 r2959 114 114 mat->SetAmbient(RgbaColor(0, 0, 0, 0)); 115 115 mat->SetDiffuse(RgbaColor(0, 0, 0, 0)); 116 116 mat->SetCullFaceEnabled(false); 117 117 Geometry *geom = new Geometry(_vertices, _normals, _texcoords, numElements, false); 118 118 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp
r2958 r2959 13 13 14 14 static CGprogram sCgSkyProgram = NULL; 15 static CGprogram sCgMrtFragmentSkyDomeProgram = NULL; 16 17 15 18 static CGparameter sLightDirParam; 16 19 static CGparameter sThetaSunParam; … … 60 63 else 61 64 cerr << "sky program failed to load" << endl; 65 66 sCgMrtFragmentSkyDomeProgram = 67 cgCreateProgramFromFile(context, 68 CG_SOURCE, 69 "src/shaders/sky_preetham.cg", 70 RenderState::sCgFragmentProfile, 71 "frag_skydome", 72 NULL); 73 74 if (sCgMrtFragmentSkyDomeProgram != NULL) 75 { 76 cgGLLoadProgram(sCgMrtFragmentSkyDomeProgram); 77 78 /*sMaxDepthParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "maxDepth"); 79 Material::sDiffuseParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "diffuse"); 80 Material::sAmbientParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "ambient"); 81 82 cgGLSetParameter1f(sMaxDepthParam, MAX_DEPTH_CONST / farDist); 83 */ 84 } 85 else 86 cerr << "fragment skyprogram failed to load" << endl; 62 87 } 63 88 … … 127 152 Vector3 position = camera->GetPosition(); 128 153 129 const float scaleFactor = 100.0f;130 131 position.z -= 10* scaleFactor;154 const float scaleFactor = 80.0f; 155 156 position.z -= 3 * scaleFactor; 132 157 Matrix4x4 m = TranslationMatrix(position); 133 158 … … 147 172 cgGLEnableProfile(RenderState::sCgVertexProfile); 148 173 cgGLBindProgram(sCgSkyProgram); 149 150 174 175 176 if (state->GetRenderPassType() == RenderState::DEFERRED) 177 { 178 cgGLEnableProfile(RenderState::sCgFragmentProfile); 179 cgGLBindProgram(sCgMrtFragmentSkyDomeProgram); 180 } 151 181 152 182 // Render sky dome. … … 155 185 // Render additively blended sun disc. 156 186 //RenderSunDisk(sunDir, camera); 187 188 cgGLDisableProfile(RenderState::sCgFragmentProfile); 157 189 } 158 190 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2958 r2959 273 273 static CGparameter sMaxDepthParamTex; 274 274 static Matrix4x4 oldViewProjMatrix; 275 static CGprogram sCgMrtFragmentSkyDomeProgram = NULL;276 275 277 276 … … 547 546 cerr << "fragment tex program failed to load" << endl; 548 547 549 sCgMrtFragmentSkyDomeProgram =548 RenderState::sCgMrtFragmentProgram = 550 549 cgCreateProgramFromFile(sCgContext, 551 550 CG_SOURCE, 552 "src/shaders/ sky_preetham.cg",551 "src/shaders/mrt.cg", 553 552 RenderState::sCgFragmentProfile, 554 "frag _skydome",553 "frag", 555 554 NULL); 556 555 557 if ( sCgMrtFragmentSkyDomeProgram != NULL)558 { 559 cgGLLoadProgram( sCgMrtFragmentSkyDomeProgram);560 561 /*sMaxDepthParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "maxDepth");556 if (RenderState::sCgMrtFragmentProgram != NULL) 557 { 558 cgGLLoadProgram(RenderState::sCgMrtFragmentProgram); 559 560 sMaxDepthParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "maxDepth"); 562 561 Material::sDiffuseParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "diffuse"); 563 562 Material::sAmbientParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "ambient"); 564 563 565 564 cgGLSetParameter1f(sMaxDepthParam, MAX_DEPTH_CONST / farDist); 566 */567 565 } 568 566 else 569 cerr << "fragment skyprogram failed to load" << endl; 567 cerr << "fragment program failed to load" << endl; 568 570 569 571 570 PrintGLerror("init"); … … 618 617 void InitGLstate() 619 618 { 620 glClearColor(0. 3f, 0.3f, 0.4f, 1.0f);619 glClearColor(0.4f, 0.4f, 0.4f, 1.0f); 621 620 622 621 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); … … 643 642 glDisable(GL_TEXTURE_2D); 644 643 645 GLfloat ambientColor[] = {0. 5, 0.5, 0.5, 1.0};644 GLfloat ambientColor[] = {0.2, 0.2, 0.2, 1.0}; 646 645 GLfloat diffuseColor[] = {1.0, 0.0, 0.0, 1.0}; 647 646 GLfloat specularColor[] = {0.0, 0.0, 0.0, 1.0}; … … 671 670 if (!skyDome) cerr << "loadig plane failed" << endl; 672 671 673 preetham = new SkyPreetham(3.0f, skyDome); 672 const float turbitiy = 3.0f; 673 preetham = new SkyPreetham(turbitiy, skyDome); 674 674 675 675 676 676 ////////////////////////////// 677 677 678 //GLfloat lmodel_ambient[] = { 0.5f, 0.5f, 0.5f, 1.0f};679 GLfloat lmodel_ambient[] = { 1.0f, 1.0f, 1.0f, 1.0f};678 //GLfloat lmodel_ambient[] = {1.0f, 1.0f, 1.0f, 1.0f}; 679 GLfloat lmodel_ambient[] = {0.7f, 0.7f, 0.8f, 1.0f}; 680 680 681 681 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); 682 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); 682 //glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); 683 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE); 683 684 glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, GL_SINGLE_COLOR_EXT); 684 685 } … … 795 796 void SetupLighting() 796 797 { 797 //glEnable(GL_LIGHTING);798 798 glEnable(GL_LIGHT0); 799 glDisable(GL_LIGHT1); 799 800 800 801 Vector3 lightDir = -light->GetDirection(); … … 807 808 GLfloat diffuse[] = {1.0f, 0.95f, 0.85f, 1.0f}; 808 809 GLfloat specular[] = {1.0f, 1.0f, 1.0f, 1.0f}; 810 //GLfloat specular[] = {0.0f, 0.0f, 0.0f, 1.0f}; 809 811 810 812 Vector3 sunAmbient; … … 832 834 diffuse[1] = sunDiffuse.y; 833 835 diffuse[2] = sunDiffuse.z; 834 836 835 837 //cout<< "sunambient: " << sunAmbient << endl; 836 838 //cout<< "sundiffuse: " << sunDiffuse << endl; … … 1101 1103 RenderSky(); 1102 1104 1103 1104 1105 1105 1106 if ((renderMethod == RENDER_DEFERRED) || … … 1960 1961 void RenderSky() 1961 1962 { 1962 glEnable(GL_LIGHTING);1963 //glEnable(GL_LIGHTING); 1963 1964 cgGLEnableProfile(RenderState::sCgVertexProfile); 1964 1965 1965 if (state.GetRenderPassType() == RenderState::DEFERRED) 1966 { 1967 cgGLEnableProfile(RenderState::sCgFragmentProfile); 1968 cgGLBindProgram(sCgMrtFragmentSkyDomeProgram); 1969 } 1966 if ((renderMethod == RENDER_DEFERRED) || (renderMethod == RENDER_DEPTH_PASS_DEFERRED)) 1967 state.SetRenderPassType(RenderState::DEFERRED); 1970 1968 1971 1969 SceneEntityContainer::const_iterator sit, sit_end = skyGeometry.end(); … … 1976 1974 //cube->Render(&state); 1977 1975 //aeroplane->Render(&state); 1978 glDisable(GL_CULL_FACE); 1976 //glEnable(GL_LIGHTING); 1977 1979 1978 preetham->Compute(-light->GetDirection(), camera, &state); 1980 glEnable(GL_CULL_FACE); 1981 1979 1982 1980 cgGLDisableProfile(RenderState::sCgVertexProfile); 1983 1981 cgGLDisableProfile(RenderState::sCgFragmentProfile); … … 2034 2032 2035 2033 glDepthFunc(GL_LESS); 2034 state.Reset(); 2036 2035 2037 2036 PrintGLerror("visibleobjects"); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2954 r2959 33 33 uniform float4 position, 34 34 uniform float3 normal, 35 uniform float amb,35 uniform float emmisive, 36 36 float3 lightDir) 37 37 { … … 50 50 const float4 ambient = glstate.light[0].ambient; 51 51 52 return (ambient + diffuse) * color * (1.0f - amb) + amb * color; 52 //return (saturate(((ambient + diffuse))) * (1.0f - emmisive) + emmisive) * color; 53 return saturate((((ambient + diffuse)) * (1.0f - emmisive) + emmisive) * color); 53 54 } 54 55 … … 152 153 const float angle = saturate(dot(normal, lightDir)); 153 154 //float4 lightDiffuse = float4(1.0f, 1.0f, 0.9f, 1.0f); 154 float4 lightDiffuse = glstate.light[0].diffuse;155 const float4 lightDiffuse = glstate.light[0].diffuse; 155 156 //float4(1.0f, 1.0f, 0.9f, 1.0f); 156 157 … … 178 179 179 180 // base lighting 180 OUT.color = ( ambient + diffuse) * color * (1.0f - emmisive) + emmisive *color;181 OUT.color = (emmisive < 0.95) ? (ambient + diffuse) * color : color; 181 182 182 183 // also write out depth component -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/sky_preetham.cg
r2958 r2959 27 27 28 28 29 struct PixelOutput 29 30 struct pixel 30 31 { 31 float4 color: SV_TARGET0; 32 float4 col: COLOR0; 33 float4 pos: COLOR1; 34 float4 norm: COLOR2; 32 35 }; 33 36 37 // fragment input 38 struct fragin 39 { 40 float4 color: COLOR0; 41 float4 position: POSITION; // eye space 42 float4 texCoord: TEXCOORD0; 34 43 35 44 float4 projPos: WPOS; 45 float4 worldPos: TEXCOORD1; // world position 46 float3 normal: TEXCOORD2; 47 float4 mypos: TEXCOORD3; 48 }; 36 49 //-------------------------------------------------------------------------------------- 37 50 // Vertex Shaders … … 91 104 92 105 93 pixel frag_skydome(fragin IN, 94 uniform float maxDepth) 106 pixel frag_skydome(fragin IN) 95 107 { 96 108 pixel pix; 97 109 98 110 pix.col = IN.color; 99 pix.pos = IN.worldPos ;// * maxDepth;111 pix.pos = IN.worldPos * 1e20;// * maxDepth; 100 112 101 113 pix.norm.xyz = IN.normal; 102 114 103 115 // hack: squeeze some information about the ambient term into the target 104 pix.norm.w = 0;116 pix.norm.w = 1; 105 117 pix.pos.w = IN.mypos.w; 106 118
Note: See TracChangeset
for help on using the changeset viewer.