- Timestamp:
- 08/29/08 15:46:36 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 2 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
r2882 r2884 308 308 </File> 309 309 <File 310 RelativePath=".\src\shaderenv.h" 311 > 312 </File> 313 <File 310 314 RelativePath=".\src\ShadowMapping.cpp" 311 315 > -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.cpp
r2881 r2884 94 94 magfilterParam = GL_LINEAR; break; 95 95 case FILTER_MIPMAP_LINEAR: 96 //minfilterParam = GL_NEAREST_MIPMAP_NEAREST;97 //magfilterParam = GL_NEAREST;98 99 minfilterParam = GL_NEAREST_MIPMAP_LINEAR;100 magfilterParam = GL_LINEAR;96 minfilterParam = GL_NEAREST_MIPMAP_NEAREST; 97 magfilterParam = GL_NEAREST; 98 99 //minfilterParam = GL_LINEAR_MIPMAP_NEAREST; 100 //magfilterParam = GL_LINEAR; 101 101 break; 102 102 default: -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.cpp
r2883 r2884 5 5 #include "Vector3.h" 6 6 #include "Camera.h" 7 #include "shaderenv.h" 7 8 8 9 … … 13 14 namespace CHCDemoEngine 14 15 { 15 16 // number of ssao samples17 #define NUM_SAMPLES 1018 19 16 20 17 static CGprogram sCgSsaoProgram = NULL; … … 49 46 static CGparameter sNoiseMultiplierParam; 50 47 static CGparameter sExpFactorParam; 48 51 49 52 50 … … 137 135 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 138 136 139 //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, mWidth, mHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, randomNormals);137 //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, randomNormals); 140 138 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, w, h, 0, GL_RGB, GL_FLOAT, randomNormals); 141 139 … … 183 181 184 182 SsaoShader::~SsaoShader() 185 186 183 { 187 184 if (sCgSsaoProgram) cgDestroyProgram(sCgSsaoProgram); … … 259 256 sExpFactorParam = cgGetNamedParameter(sCgSsaoProgram, "expFactor"); 260 257 261 sSamplesParam = cgGetNamedParameter(sCgSsaoProgram, "samples");262 258 sOldTexParam = cgGetNamedParameter(sCgSsaoProgram, "oldTex"); 263 259 260 cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue(3.0f, 17.0f)); 264 261 265 262 // generate samples for ssao kernel 266 263 GenerateSamples(); 264 265 sSamplesParam = cgGetNamedParameter(sCgSsaoProgram, "samples"); 266 //cgSetArraySize(sSamplesParam, NUM_SAMPLES); 267 //cgCompileProgram(sCgSsaoProgram); 268 267 269 cgGLSetParameterArray2f(sSamplesParam, 0, NUM_SAMPLES, (const float *)samples); 268 269 cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue(3.0f, 17.0f));270 270 } 271 271 else … … 415 415 CombineIllum(fbo); 416 416 } 417 417 418 AntiAliasing(fbo); 418 419 … … 439 440 cgGLSetMatrixParameterfc(sOldModelViewProjMatrixParam, (const float *)oldProjViewMatrix.x); 440 441 441 // GLuint colorsTex = mFbo->GetColorBuffer(0)->GetTexture();442 442 GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); 443 443 GLuint positionsTex = fbo->GetColorBuffer(1)->GetTexture(); … … 577 577 void SsaoShader::AntiAliasing(FrameBufferObject *fbo) 578 578 { 579 //GLuint colorsTex = mNewFbo->GetColorBuffer(1)->GetTexture();580 579 GLuint colorsTex = fbo->GetColorBuffer(0)->GetTexture(); 581 580 GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); … … 727 726 cgGLSetParameter1f(sNoiseMultiplierGiParam, RandomValue(3.0f, 17.0f)); 728 727 cgGLSetParameter1f(sExpFactorGiParam, expFactor); 729 730 728 731 729 // q: should we generate new samples or only rotate the old ones? … … 774 772 { 775 773 GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); 774 776 775 GLuint ssaoTex = mNewFbo->GetColorBuffer(0)->GetTexture(); 777 776 GLuint illumTex = mNewFbo->GetColorBuffer(1)->GetTexture(); 778 777 779 //780 778 fbo->Bind(); 781 779 782 // write into old color texture (not needed anymore)780 // overwrite old color texture 783 781 glDrawBuffers(1, mymrt); 784 782 … … 829 827 GLuint ssaoTex = mNewFbo->GetColorBuffer(0)->GetTexture(); 830 828 831 //832 829 fbo->Bind(); 833 830 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2881 r2884 44 44 45 45 46 ///////////// 47 //-- fbos 48 46 // fbo 49 47 FrameBufferObject *fbo = NULL; 50 51 bool isFirstTexture = true;52 48 53 49 GLuint fontTex; … … 537 533 // this fbo basicly stores the scene information we get from standard rendering of a frame 538 534 // we store colors, normals, positions (for the ssao) 539 fbo = new FrameBufferObject(texWidth, texHeight, FrameBufferObject::DEPTH_ 24);535 fbo = new FrameBufferObject(texWidth, texHeight, FrameBufferObject::DEPTH_32); 540 536 541 537 // the diffuse color buffer … … 552 548 553 549 // another color buffer 554 fbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_ 16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, false);550 fbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, false); 555 551 556 552 PrintGLerror("fbo"); … … 1021 1017 } 1022 1018 1023 //glFlush();1019 glFlush(); 1024 1020 1025 1021 const bool restart = true; … … 1027 1023 1028 1024 DisplayStats(); 1029 1030 // flip textures for temporal smoothing1031 isFirstTexture = !isFirstTexture;1032 1025 1033 1026 glutSwapBuffers(); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/antialiasing.cg
r2868 r2884 11 11 12 12 // the barrier for detecting a discontinuity 13 uniform float4 e_barrier = float4(5e- 4, 5e-4, 0, 0); // x = normal, y = depth13 uniform float4 e_barrier = float4(5e-5, 5e-5, 0, 0); // x = normal, y = depth 14 14 // the weights for normal / depth discontinuity 15 //uniform float4 e_weights = float4(10.0f, 0.1f, 1.0f, 1.0f); // x = normal, y = depth 15 16 uniform float4 e_weights = float4(1.0f, 1.0f, 1.0f, 1.0f); // x = normal, y = depth 16 17 uniform float4 e_kernel = float4(0.35f, 1.0f, 1.0f, 1.0f); … … 23 24 { 24 25 //return tex2D(colors, IN.c.xy); 26 25 27 // normal discontinuity filter 26 28 float3 nc = (float3)tex2D(normals, IN.c.xy); … … 37 39 float ne = saturate(dot(nd, e_weights.x)); 38 40 39 // opposite coordinates41 // construct opposite coordinates 40 42 float4 lrr = IN.lr.wzyx; 41 43 float4 tbr = IN.tb.wzyx; … … 66 68 67 69 dd = abs(2.0f * dc - dd) - e_barrier.y; 68 dd = step(dd, 0.0f);70 dd = step(dd, (float4)0.0f); 69 71 70 72 float de = saturate(dot(dd, e_weights.y)); … … 77 79 float2 offset = IN.c.xy * (1.0f - w); 78 80 79 float4 s0 = tex2D (colors, offset + IN.lt.xy * w);80 float4 s1 = tex2D (colors, offset + IN.rb.xy * w);81 float4 s2 = tex2D (colors, offset + IN.rt.xy * w);82 float4 s3 = tex2D (colors, offset + IN.lb.xy * w);81 float4 s0 = tex2Dlod(colors, float4(offset + IN.lt.xy * w, 0, 0)); 82 float4 s1 = tex2Dlod(colors, float4(offset + IN.rb.xy * w, 0, 0)); 83 float4 s2 = tex2Dlod(colors, float4(offset + IN.rt.xy * w, 0, 0)); 84 float4 s3 = tex2Dlod(colors, float4(offset + IN.lb.xy * w, 0, 0)); 83 85 84 return (s0 + s1 + s2 + s3) / 4.0f; 86 float4 sx = tex2D(colors, IN.c.xy); 87 88 //return (sx + sx) * 0.5f; 89 90 return (s0 + s1 + s2 + s3) * 0.25f; 91 //return (s0 + s1 + s2 + s3) * 0.25f; 92 85 93 //return float4(w); 86 94 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2882 r2884 54 54 55 55 float4 norm = tex2D(normals, IN.texCoord.xy); 56 float4 color = tex2D (colors, IN.texCoord.xy);56 float4 color = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 57 57 float4 position = tex2D(positions, IN.texCoord.xy); 58 58 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg
r2882 r2884 1 1 //////////////////// 2 // S creen Spaced Ambient Occlusionshader2 // SSAO + color bleeding shader 3 3 // based on shader of Alexander Kusternig 4 4 5 #define NUM_SAMPLES 10 6 //#define NUM_SAMPLES 16 7 8 // rule of thumb: approx 1 / NUM_SAMPLES 9 //#define SAMPLE_INTENSITY 0.15f 10 #define SAMPLE_INTENSITY 0.22f 11 12 #define AREA_SIZE 7e-1f 13 //#define AREA_SIZE 3e-1f 14 #define VIEW_CORRECTION_SCALE 0.3f 15 //#define VIEW_CORRECTION_SCALE 0.5f 16 #define DISTANCE_SCALE 1e-6f 17 18 #define ILLUM_INTENSITY 5e-1f; 5 #include "../shaderenv.h" 19 6 20 7 … … 83 70 84 71 //sample noisetex; r stores costheta, g stores sintheta 72 //float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f; 85 73 float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy; 86 74 … … 210 198 211 199 OUT.illum_col = (col + illum) * ao; 200 OUT.illum_col.w = col.w; 212 201 213 202 return OUT; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r2882 r2884 1 #include "../shaderenv.h" 2 1 3 //////////////////// 2 4 // Screen Spaced Ambient Occlusion shader 3 5 // based on shader of Alexander Kusternig 4 6 5 #define NUM_SAMPLES 106 //#define NUM_SAMPLES 167 8 // rule of thumb: approx 1 / NUM_SAMPLES9 //#define SAMPLE_INTENSITY 0.15f10 #define SAMPLE_INTENSITY 0.22f11 12 #define AREA_SIZE 7e-1f13 //#define AREA_SIZE 3e-1f14 #define VIEW_CORRECTION_SCALE 0.3f15 //#define VIEW_CORRECTION_SCALE 0.5f16 #define DISTANCE_SCALE 1e-6f17 7 18 8 … … 66 56 for (int i = 0; i < NUM_SAMPLES; ++ i) 67 57 { 68 float2 offset = samples[i];58 const float2 offset = samples[i]; 69 59 70 60 //////////////////// 71 61 // add random noise: r stores costheta, g stores sintheta 72 62 73 // float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f;63 //const float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f; 74 64 float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy; 75 65 76 float2 offsetTransformed = reflect(offset, mynoise);66 const float2 offsetTransformed = reflect(offset, mynoise); 77 67 78 68 // weight with projected coordinate to reach similar kernel size for near and far … … 165 155 (abs(depthDif) < 1e-3f)) 166 156 { 167 OUT.illum_col .x =ao * expFactor + oldCol.x * (1.0f - expFactor);157 OUT.illum_col = (float4)ao * expFactor + oldCol.x * (1.0f - expFactor); 168 158 } 169 159 else 170 160 { 171 OUT.illum_col .x =ao;161 OUT.illum_col = (float4)ao; 172 162 } 173 163 … … 178 168 179 169 180 181 170 pixel combine(fragment IN, 182 171 uniform sampler2D colors, … … 185 174 pixel OUT; 186 175 187 float4 col = tex2D (colors, IN.texCoord.xy);176 float4 col = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 188 177 float4 ao = tex2D(ssaoTex, IN.texCoord.xy); 189 178 190 179 OUT.illum_col = col * ao.x; 180 OUT.illum_col.w = ao.w; 191 181 192 182 return OUT;
Note: See TracChangeset
for help on using the changeset viewer.