Changeset 2992
- Timestamp:
- 10/02/08 17:34:10 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r2991 r2992 34 34 static CGprogram sCgCombinedIllumProgram = NULL; 35 35 36 static CGparameter sColorsTexLogLumParam; 37 38 36 39 37 40 static CGprogram sCgInitialIntensityProgram; 38 41 static CGprogram sCgDownSampleProgram; 39 42 static CGprogram sCgToneProgram; 43 static CGprogram sCgLogLumProgram; 44 40 45 41 46 … … 143 148 int DeferredRenderer::colorBufferIdx = 0; 144 149 150 145 151 static void PrintGLerror(char *msg) 146 152 { … … 153 159 fprintf(stderr,"OpenGL ERROR: %s: %s\n", errStr, msg); 154 160 } 155 }156 157 static int computeSize(int level)158 {159 // Compute total image size.160 float w = 1024;161 float h = 768;162 163 int mipmapSize = max(1, w / (1 << level) ) *164 max(1, h / (1 << level) ) * sizeof(float) * 4;165 166 return mipmapSize;167 161 } 168 162 … … 323 317 sPositionsTexDeferredParam = cgGetNamedParameter(sCgDeferredProgram, "positions"); 324 318 sColorsTexDeferredParam = cgGetNamedParameter(sCgDeferredProgram, "colors"); 325 //sOldColorsTexDeferredParam = cgGetNamedParameter(sCgDeferredProgram, "oldColors");326 319 sNormalsTexDeferredParam = cgGetNamedParameter(sCgDeferredProgram, "normals"); 327 320 … … 492 485 sSamplesShadowParam = cgGetNamedParameter(sCgDeferredShadowProgram, "samples"); 493 486 sLightDirShadowParam = cgGetNamedParameter(sCgDeferredShadowProgram, "lightDir"); 494 //sOldColorsTexShadowParam = cgGetNamedParameter(sCgDeferredShadowProgram, "oldColors");495 496 487 497 488 PoissonDiscSampleGenerator2 poisson(NUM_PCF_TABS, 1.0f); … … 502 493 else 503 494 cerr << "deferred program failed to load" << endl; 495 496 sCgLogLumProgram = 497 cgCreateProgramFromFile(context, 498 CG_SOURCE, 499 "src/shaders/tonemap.cg", 500 RenderState::sCgFragmentProfile, 501 "CalcAvgLogLum", 502 NULL); 503 504 if (sCgLogLumProgram != NULL) 505 { 506 cgGLLoadProgram(sCgLogLumProgram); 507 sColorsTexLogLumParam = cgGetNamedParameter(sCgLogLumProgram, "colors"); 508 } 509 else 510 cerr << "avg loglum program failed to load" << endl; 511 504 512 505 513 sCgToneProgram = … … 524 532 cerr << "tone program failed to load" << endl; 525 533 534 /* 526 535 sCgInitialIntensityProgram = 527 536 cgCreateProgramFromFile(context, … … 542 551 cerr << "intensity program failed to load" << endl; 543 552 544 553 */ 545 554 546 555 PrintGLerror("init"); … … 655 664 GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 656 665 657 // generate mip map levels of position texture 658 glBindTexture(GL_TEXTURE_2D, positionsTex); 659 glGenerateMipmapEXT(GL_TEXTURE_2D); 660 661 666 // generate mip map levels of position in order to improve texture lookup performance 667 //glBindTexture(GL_TEXTURE_2D, positionsTex); glGenerateMipmapEXT(GL_TEXTURE_2D); 668 662 669 // read the second buffer, write to the first buffer 663 670 mFbo->Bind(); … … 743 750 744 751 745 Vector3 Interpol(float wx, float wy, Vector3 bl, Vector3 br, Vector3 tl, Vector3 tr)746 {747 //float3 x1 = lerp(oldColor.w, logLumScaled, 0.1f);748 Vector3 x1 = bl * (1.0f - wx) + br * wx;749 Vector3 x2 = tl * (1.0f - wx) + tr * wx;750 751 Vector3 v = x1 * (1.0f - wy) + x2 * wy;752 753 return v;754 }755 756 757 752 void DeferredRenderer::ComputeViewVectors(Vector3 &tl, Vector3 &tr, Vector3 &bl, Vector3 &br) 758 753 { … … 830 825 GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 831 826 832 //GLuint oldColorsTex = fbo->GetColorBuffer(3 - colorBufferIdx)->GetTexture();833 834 827 fbo->Bind(); 835 828 … … 845 838 cgGLSetTextureParameter(sColorsTexDeferredParam, colorsTex); 846 839 cgGLEnableTextureParameter(sColorsTexDeferredParam); 847 848 //cgGLSetTextureParameter(sOldColorsTexDeferredParam, oldColorsTex);849 //cgGLEnableTextureParameter(sOldColorsTexDeferredParam);850 840 851 841 cgGLSetTextureParameter(sPositionsTexDeferredParam, positionsTex); … … 873 863 874 864 cgGLDisableTextureParameter(sColorsTexDeferredParam); 875 //cgGLDisableTextureParameter(sOldColorsTexDeferredParam);876 865 cgGLDisableTextureParameter(sPositionsTexDeferredParam); 877 866 cgGLDisableTextureParameter(sNormalsTexDeferredParam); … … 1111 1100 GLuint shadowTex = shadowMap->GetDepthTexture(); 1112 1101 1113 //GLuint oldColorsTex = fbo->GetColorBuffer(3 - colorBufferIdx)->GetTexture();1114 1115 1102 Matrix4x4 shadowMatrix; 1116 1103 shadowMap->GetTextureMatrix(shadowMatrix); … … 1136 1123 cgGLEnableTextureParameter(sShadowMapParam); 1137 1124 1138 //cgGLSetTextureParameter(sOldColorsTexShadowParam, oldColorsTex);1139 //cgGLEnableTextureParameter(sOldColorsTexShadowParam);1140 1141 1125 cgGLSetParameter1f(sMaxDepthShadowParam, mScaleFactor); 1142 1126 1143 //cgGLSetParameter1f(sSampleWidthParam, 10.0f / shadowMap->GetSize());1144 1127 cgGLSetParameter1f(sSampleWidthParam, 2.0f / shadowMap->GetSize()); 1145 1128 … … 1172 1155 cgGLDisableTextureParameter(sShadowMapParam); 1173 1156 cgGLDisableTextureParameter(sNoiseTexShadowParam); 1174 //cgGLDisableTextureParameter(sOldColorsTexShadowParam);1175 1157 1176 1158 FrameBufferObject::Release(); … … 1218 1200 middleGrey = lightIntensity * maxKey + (1.0f - lightIntensity) * minKey; 1219 1201 1202 #if 1 1220 1203 1221 1204 ////////// … … 1223 1206 1224 1207 ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 1208 GLuint colorsTex = colorBuffer->GetTexture(); 1225 1209 1226 1210 fbo->Bind(); … … 1228 1212 colorBufferIdx = 3 - colorBufferIdx; 1229 1213 glDrawBuffers(1, mrt + colorBufferIdx); 1230 1231 GLuint colorsTex = colorBuffer->GetTexture(); 1232 1214 1215 1233 1216 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 1234 1217 1235 1218 cgGLEnableProfile(RenderState::sCgFragmentProfile); 1236 cgGLBindProgram(sCg ToneProgram);1219 cgGLBindProgram(sCgLogLumProgram); 1237 1220 1238 1221 cgGLSetTextureParameter(sColorsTexLogLumParam, colorsTex); 1239 1240 glColor3f(1.0f, 1.0f, 1.0f); 1241 1242 glBegin(GL_QUADS); 1243 1244 glColor3f(1.0f, 1.0f, 1.0f); 1245 1222 cgGLEnableTextureParameter(sColorsTexLogLumParam); 1223 1246 1224 const float offs = 0.5f; 1247 1225 … … 1261 1239 PrintGLerror("ToneMapParams"); 1262 1240 1241 #endif 1263 1242 1264 1243 /////////////////// -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2991 r2992 215 215 bool altKeyPressed = false; 216 216 217 #define USE_TONE_MAPPING 1217 #define USE_TONE_MAPPING 0 218 218 219 219 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2991 r2992 76 76 // an ambient color term 77 77 float amb = color.w; 78 79 78 float3 normal = normalize(norm.xyz); 80 81 79 float4 col = shade(IN, color, position, normal, amb, lightDir); 82 80 83 81 OUT.color = col; 84 82 85 #if 083 #if 1 86 84 87 85 OUT.color.w = color.w; … … 217 215 //-- write out logaritmic luminance for tone mapping 218 216 219 #if 0 220 217 #if 1 221 218 OUT.color.w = color.w; 222 223 219 #else 224 220 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r2991 r2992 42 42 43 43 44 // reconstruct world space position 44 45 inline float3 ReconstructSamplePosition(float3 eyePos, 45 46 uniform sampler2D colors, … … 47 48 float3 bl, float3 br, float3 tl, float3 tr) 48 49 { 49 /*float eyeSpaceDepth = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).w; 50 51 // reconstruct world space position 50 float eyeSpaceDepth = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).w; 52 51 float3 rotView = normalize(Interpol(texcoord, bl, br, tl, tr)); 53 float3 sample_position = eyePos - rotView * eyeSpaceDepth;*/ 54 float3 sample_position = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).xyz; 52 53 float3 sample_position = eyePos - rotView * eyeSpaceDepth; 54 //float3 sample_position = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).xyz; 55 55 56 56 return sample_position; … … 174 174 175 175 //const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, viewDir, eyePos); 176 const float2 ao = ssao(IN, positions, noiseTexture, samples, normal, centerPosition, w, eyePos, bl, br, tl, tr);176 const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, centerPosition, w, eyePos, bl, br, tl, tr); 177 177 178 178 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg
r2991 r2992 114 114 pixel OUT; 115 115 116 float4 color = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 117 118 OUT.col = color; 119 116 120 // the old loglum is stored in the hightest mipmap-level 117 float4 color = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0));118 121 float oldLogLum = tex2Dlod(colors, float4(IN.texCoord.xy, 0, MAX_LOD_LEVEL)).w; 119 122 … … 127 130 float logLumScaled = logLum * INV_LOGLUM_RANGE - logLumOffset; 128 131 129 OUT.color = color; 132 if (oldLogLum > 0) 133 OUT.col.w = lerp(oldLogLum, logLumScaled, 0.1f); 134 else 135 OUT.col.w = logLumScaled; 130 136 131 if (oldLogLum > 0) 132 OUT.color.w = lerp(oldLogLum, logLumScaled, 0.1f); 133 else 134 OUT.color.w = logLumScaled; 137 return OUT; 135 138 }
Note: See TracChangeset
for help on using the changeset viewer.