- Timestamp:
- 10/01/08 00:40:59 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
r2959 r2982 23 23 24 24 # ssao temporal coherence factor 25 tempCohFactor= 100.0f25 tempCohFactor=50.0f -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r2981 r2982 164 164 str.read(reinterpret_cast<char *>(&texId), sizeof(int)); 165 165 166 if ( 0)//texId >= 0)166 if (texId >= 0) 167 167 mat->SetTexture(mTextureTable[texId]); 168 168 … … 182 182 str.read(reinterpret_cast<char *>(&mat->mEmmisiveColor), sizeof(Vector3)); 183 183 str.read(reinterpret_cast<char *>(&mat->mSpecularColor), sizeof(Vector3)); 184 185 mat->mAmbientColor = RandomColor();186 mat->mDiffuseColor = RgbaColor(0,0,0,1);187 184 } 188 185 … … 228 225 } 229 226 230 //return new Geometry(vertices, normals, texcoords, vertexCount, true);231 return new Geometry(vertices, normals, texcoords, vertexCount, false);227 return new Geometry(vertices, normals, texcoords, vertexCount, true); 228 //return new Geometry(vertices, normals, texcoords, vertexCount, false); 232 229 } 233 230 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp
r2981 r2982 24 24 static CGparameter sDColorParam; 25 25 static CGparameter sEColorParam; 26 static CGparameter sMultiplierParam; 27 26 28 27 29 … … 60 62 sDColorParam = cgGetNamedParameter(sCgSkyProgram, "dColor"); 61 63 sEColorParam = cgGetNamedParameter(sCgSkyProgram, "eColor"); 64 65 sMultiplierParam = cgGetNamedParameter(sCgSkyProgram, "multiplier"); 62 66 } 63 67 else … … 75 79 { 76 80 cgGLLoadProgram(sCgMrtFragmentSkyDomeProgram); 77 78 /* 79 cgGLSetParameter1f(sMaxDepthParam, MAX_DEPTH_CONST / farDist); 80 */ 81 //cgGLSetParameter1f(sMaxDepthParam, MAX_DEPTH_CONST / farDist); 81 82 } 82 83 else … … 129 130 cgGLSetParameter3f(sEColorParam, ABCDE[4].x, ABCDE[4].y, ABCDE[4].z); 130 131 131 cgGLEnableProfile(RenderState::sCgVertexProfile);132 cgGLBindProgram(sCgSkyProgram);133 134 135 132 if (state->GetRenderPassType() == RenderState::DEFERRED) 136 133 { 137 134 cgGLEnableProfile(RenderState::sCgFragmentProfile); 138 135 cgGLBindProgram(sCgMrtFragmentSkyDomeProgram); 136 137 // can use tone mapping 138 cgGLSetParameter1f(sMultiplierParam, 1.0f); 139 139 } 140 else 141 { 142 // no tone mapping => scale 143 cgGLSetParameter1f(sMultiplierParam, 8e-5f); 144 } 145 146 cgGLEnableProfile(RenderState::sCgVertexProfile); 147 cgGLBindProgram(sCgSkyProgram); 140 148 141 149 // Render sky dome. … … 258 266 259 267 260 void SkyPreetham::ComputeSunColor(const Vector3 &sunDir, Vector3 &ambient, Vector3 &diffuse ) const268 void SkyPreetham::ComputeSunColor(const Vector3 &sunDir, Vector3 &ambient, Vector3 &diffuse, bool scaleToRange) const 261 269 { 262 270 // sunDir is sun direction … … 280 288 281 289 // downscale ambient color 282 if ( 1)283 ambient *= 5e-5f;290 if (scaleToRange) 291 ambient *= 2e-5f; 284 292 else 285 293 ambient *= 1e-1f; … … 320 328 321 329 // Calculate final sun diffuse color. 322 if ( 1)323 diffuse = color * 1.7e-4f;330 if (scaleToRange) 331 diffuse = color * 5e-2f; 324 332 else 325 333 diffuse = color * 3e-1f; 326 334 327 335 diffuse *= (2.0f - 1.0f * DotProd(sunDir, Vector3::UNIT_Z())); 328 329 336 330 337 //cout << "diffuse: " << Magnitude(diffuse) << " ambient: " << Magnitude(ambient) << endl; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.h
r2960 r2982 31 31 std::pair<float, float> &sunThetha) const; 32 32 33 void ComputeSunColor(const CHCDemoEngine::Vector3 &sunDir, CHCDemoEngine::Vector3 &ambient, CHCDemoEngine::Vector3 &diffuse) const; 33 void ComputeSunColor(const CHCDemoEngine::Vector3 &sunDir, 34 CHCDemoEngine::Vector3 &ambient, 35 CHCDemoEngine::Vector3 &diffuse, 36 bool scaleToRange) const; 34 37 35 38 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2981 r2982 455 455 456 456 SceneEntity *oldEnt = NULL; 457 457 #if 0 458 458 cout << "merging entities .. " << endl; 459 459 … … 489 489 490 490 cout << "merged " << merged << " of " << (int)sceneEntities.size() << " entities " << endl; 491 491 #endif 492 492 // set far plane based on scene extent 493 493 farDist = 10.0f * Magnitude(bvh->GetBox().Diagonal()); … … 502 502 503 503 Vector3 cubeCenter(470.398f, 240.364f, 182.5f); 504 /*AxisAlignedBox3 box(cubeCenter - Vector3(2.0f), cubeCenter + Vector3(2.0f)); 505 506 Material *mat = new Material(RgbaColor(1, 0.4, 0.4, 0)); 507 Transform3 *tf = new Transform3(); 508 cube = SceneEntityConverter().ConvertBox(box, mat, tf); 509 */ 510 504 511 505 Matrix4x4 transl = TranslationMatrix(cubeCenter); 512 506 513 //const string aeroplaneStr = model_path + "toyplane.dem";514 //const string aeroplaneStr = model_path + "city_full.dem";515 507 516 508 SceneEntityContainer dummy; 517 518 509 519 510 string skyDomeStr(model_path + "sky.dem"); … … 532 523 533 524 534 /*if (loader->Load(aeroplaneStr, dummy)) 535 cout << "successfully loaded " << dummy.size() << " scene entities" << endl; 536 else 537 { 538 cerr << "loading file " << aeroplaneStr << " failed" << endl; 539 540 CleanUp(); 541 exit(0); 542 } 543 544 aeroplane = dummy[1]; 545 546 aeroplane->GetTransform()->MultMatrix(transl); 547 */ 548 const float turbitiy = 3.0f; 525 const float turbitiy = 9.0f; 549 526 preetham = new SkyPreetham(turbitiy, skyDome); 550 527 … … 859 836 GLfloat diffuse[] = {1.0f, 0.95f, 0.85f, 1.0f}; 860 837 GLfloat specular[] = {1.0f, 1.0f, 1.0f, 1.0f}; 861 //GLfloat specular[] = {0.0f, 0.0f, 0.0f, 1.0f}; 838 839 840 const bool useToneMapping = 841 (renderMethod == RENDER_DEPTH_PASS_DEFERRED) || 842 (renderMethod == RENDER_DEFERRED); 862 843 863 844 Vector3 sunAmbient; 864 845 Vector3 sunDiffuse; 865 846 866 preetham->ComputeSunColor(lightDir, sunAmbient, sunDiffuse); 867 868 const float maxComponent = sunDiffuse.MaxComponent(); 869 //cout<< "sunambient: " << sunAmbient << " mag " << Magnitude(sunDiffuse) << " max: " << maxComponent << endl; 847 preetham->ComputeSunColor(lightDir, sunAmbient, sunDiffuse, !useToneMapping); 870 848 871 849 ambient[0] = sunAmbient.x; … … 873 851 ambient[2] = sunAmbient.z; 874 852 875 //sunDiffuse /= maxComponent; 853 854 // no tone mapping => scale 855 if (!useToneMapping) 856 { 857 const float maxComponent = sunDiffuse.MaxComponent(); 858 //cout<< "sunambient: " << sunAmbient << " mag " << Magnitude(sunDiffuse) << " max: " << maxComponent << endl; 859 sunDiffuse /= maxComponent; 860 } 876 861 877 862 diffuse[0] = sunDiffuse.x; 878 863 diffuse[1] = sunDiffuse.y; 879 864 diffuse[2] = sunDiffuse.z; 880 881 //cout<< "sunambient: " << sunAmbient << endl;882 //cout<< "sundiffuse: " << sunDiffuse << endl;883 865 884 866 glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); … … 1103 1085 1104 1086 glEnableClientState(GL_NORMAL_ARRAY); 1105 1106 1087 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 1107 1088 … … 1133 1114 { 1134 1115 // actually render the scene geometry using the specified algorithm 1135 //traverser->RenderScene();1136 1116 traverser->RenderScene(); 1117 /* 1137 1118 #if 0 1138 1119 SceneEntityContainer::const_iterator sit, sit_end = sceneEntities.end(); … … 1147 1128 renderQueue->Enqueue(*sit); 1148 1129 #endif 1149 1130 */ 1150 1131 renderQueue->Apply(); 1151 1132 } … … 2063 2044 2064 2045 InitDeferredRendering(); 2065 2066 glClear(GL_COLOR_BUFFER_BIT);2067 2046 } 2068 2047 else … … 2078 2057 glDepthFunc(GL_LEQUAL); 2079 2058 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 2059 2060 glClear(GL_COLOR_BUFFER_BIT); 2080 2061 2081 2062 state.SetUseAlphaToCoverage(true); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
r2978 r2982 28 28 //#define ILLUM_INTENSITY 9e-1f; 29 29 30 #define SSAO_MIPMAP_LEVEL 0//130 #define SSAO_MIPMAP_LEVEL 1 31 31 #define GI_MIPMAP_LEVEL 0//2 32 32 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2978 r2982 98 98 99 99 if (oldColor.w > 0) 100 OUT.color.w = lerp(oldColor.w, logLumScaled, 0. 2f);100 OUT.color.w = lerp(oldColor.w, logLumScaled, 0.1f); 101 101 else 102 102 OUT.color.w = logLumScaled; … … 217 217 218 218 if (oldColor.w > 0) 219 OUT.color.w = lerp(oldColor.w, logLumScaled, 0. 2f);219 OUT.color.w = lerp(oldColor.w, logLumScaled, 0.1f); 220 220 else 221 221 OUT.color.w = logLumScaled; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r2974 r2982 94 94 // hack: squeeze some information about ambient into the texture 95 95 pix.col.w = glstate.material.emission.x; 96 //pix.col.w = length(currentPos - IN.worldPos) 96 97 97 98 return pix; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/sky_preetham.cg
r2974 r2982 63 63 uniform float3 dColor, 64 64 uniform float3 eColor, 65 uniform float4x4 ModelView) 65 uniform float4x4 ModelView, 66 uniform float multiplier) 66 67 { 67 68 vtxout OUT; … … 94 95 OUT.color = float4(hcol, 1.0); 95 96 96 //OUT.color.rgb *= 2e-5f;97 OUT.color.rgb *= multiplier; 97 98 98 99 OUT.color2 = OUT.color; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r2979 r2982 157 157 float newWeight; 158 158 159 float newNumSamples = ao.y; 160 159 161 if (//(temporalCoherence > 0) && 160 162 (tex.x >= 0.0f) && (tex.x < 1.0f) && 161 163 (tex.y >= 0.0f) && (tex.y < 1.0f) && 162 (abs(depthDif) < 1e- 3f)164 (abs(depthDif) < 1e-4f) 163 165 // check if visibility changed in the surrounding area: 164 166 // then we have to recompute 165 && (oldNumSamples > ao.y - 1.5f) 167 && ((newWeight < 10) || (oldNumSamples > 0.9f * newNumSamples)) 168 //&& (oldAvgDepth / newAvgDepth > 0.99) 166 169 ) 167 170 { … … 173 176 } 174 177 else 175 { 178 { 176 179 OUT.illum_col.xy = ao.xy; 177 180 newWeight = 0;
Note: See TracChangeset
for help on using the changeset viewer.