Changeset 2884


Ignore:
Timestamp:
08/29/08 15:46:36 (16 years ago)
Author:
mattausch
Message:

found bug with lod levels
made env file for shaders

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  
    308308                        </File> 
    309309                        <File 
     310                                RelativePath=".\src\shaderenv.h" 
     311                                > 
     312                        </File> 
     313                        <File 
    310314                                RelativePath=".\src\ShadowMapping.cpp" 
    311315                                > 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.cpp

    r2881 r2884  
    9494                magfilterParam = GL_LINEAR; break; 
    9595        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;  
    101101                break; 
    102102        default: 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.cpp

    r2883 r2884  
    55#include "Vector3.h" 
    66#include "Camera.h" 
     7#include "shaderenv.h" 
    78 
    89 
     
    1314namespace CHCDemoEngine 
    1415{ 
    15  
    16 // number of ssao samples 
    17 #define NUM_SAMPLES 10 
    18  
    1916 
    2017static CGprogram sCgSsaoProgram = NULL; 
     
    4946static CGparameter sNoiseMultiplierParam; 
    5047static CGparameter sExpFactorParam; 
     48 
    5149 
    5250 
     
    137135        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 
    138136 
    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); 
    140138        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, w, h, 0, GL_RGB, GL_FLOAT, randomNormals); 
    141139 
     
    183181 
    184182SsaoShader::~SsaoShader()  
    185  
    186183{ 
    187184        if (sCgSsaoProgram)     cgDestroyProgram(sCgSsaoProgram); 
     
    259256                sExpFactorParam = cgGetNamedParameter(sCgSsaoProgram, "expFactor"); 
    260257 
    261                 sSamplesParam = cgGetNamedParameter(sCgSsaoProgram, "samples"); 
    262258                sOldTexParam = cgGetNamedParameter(sCgSsaoProgram, "oldTex");   
    263259                 
     260                cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue(3.0f, 17.0f)); 
    264261 
    265262                // generate samples for ssao kernel 
    266263                GenerateSamples();  
     264 
     265                sSamplesParam = cgGetNamedParameter(sCgSsaoProgram, "samples"); 
     266                //cgSetArraySize(sSamplesParam, NUM_SAMPLES); 
     267                //cgCompileProgram(sCgSsaoProgram); 
     268                 
    267269                cgGLSetParameterArray2f(sSamplesParam, 0, NUM_SAMPLES, (const float *)samples); 
    268  
    269                 cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue(3.0f, 17.0f)); 
    270270        } 
    271271        else 
     
    415415                CombineIllum(fbo); 
    416416        } 
     417 
    417418        AntiAliasing(fbo); 
    418419 
     
    439440        cgGLSetMatrixParameterfc(sOldModelViewProjMatrixParam, (const float *)oldProjViewMatrix.x); 
    440441 
    441 //      GLuint colorsTex = mFbo->GetColorBuffer(0)->GetTexture(); 
    442442        GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); 
    443443        GLuint positionsTex = fbo->GetColorBuffer(1)->GetTexture(); 
     
    577577void SsaoShader::AntiAliasing(FrameBufferObject *fbo) 
    578578{ 
    579         //GLuint colorsTex = mNewFbo->GetColorBuffer(1)->GetTexture(); 
    580579        GLuint colorsTex = fbo->GetColorBuffer(0)->GetTexture(); 
    581580        GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 
     
    727726                cgGLSetParameter1f(sNoiseMultiplierGiParam, RandomValue(3.0f, 17.0f)); 
    728727                cgGLSetParameter1f(sExpFactorGiParam, expFactor); 
    729  
    730728 
    731729                // q: should we generate new samples or only rotate the old ones? 
     
    774772{ 
    775773        GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); 
     774 
    776775        GLuint ssaoTex = mNewFbo->GetColorBuffer(0)->GetTexture(); 
    777776        GLuint illumTex = mNewFbo->GetColorBuffer(1)->GetTexture(); 
    778777 
    779         // 
    780778        fbo->Bind(); 
    781779 
    782         // write into old color texture (not needed anymore) 
     780        // overwrite old color texture 
    783781        glDrawBuffers(1, mymrt); 
    784782 
     
    829827        GLuint ssaoTex = mNewFbo->GetColorBuffer(0)->GetTexture(); 
    830828 
    831         // 
    832829        fbo->Bind(); 
    833830 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2881 r2884  
    4444 
    4545 
    46 ///////////// 
    47 //-- fbos 
    48  
     46// fbo 
    4947FrameBufferObject *fbo = NULL; 
    50  
    51 bool isFirstTexture = true; 
    5248 
    5349GLuint fontTex; 
     
    537533        // this fbo basicly stores the scene information we get from standard rendering of a frame 
    538534        // 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); 
    540536 
    541537        // the diffuse color buffer 
     
    552548 
    553549        // 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); 
    555551 
    556552        PrintGLerror("fbo"); 
     
    10211017        } 
    10221018 
    1023         //glFlush(); 
     1019        glFlush(); 
    10241020 
    10251021        const bool restart = true; 
     
    10271023 
    10281024        DisplayStats(); 
    1029  
    1030         // flip textures for temporal smoothing 
    1031         isFirstTexture = !isFirstTexture; 
    10321025 
    10331026        glutSwapBuffers(); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/antialiasing.cg

    r2868 r2884  
    1111 
    1212// the barrier for detecting a discontinuity 
    13 uniform float4 e_barrier = float4(5e-4, 5e-4, 0, 0); // x = normal, y = depth 
     13uniform float4 e_barrier = float4(5e-5, 5e-5, 0, 0); // x = normal, y = depth 
    1414// the weights for normal / depth discontinuity 
     15//uniform float4 e_weights = float4(10.0f, 0.1f, 1.0f, 1.0f); // x = normal, y = depth 
    1516uniform float4 e_weights = float4(1.0f, 1.0f, 1.0f, 1.0f); // x = normal, y = depth 
    1617uniform float4 e_kernel = float4(0.35f, 1.0f, 1.0f, 1.0f);  
     
    2324{ 
    2425        //return tex2D(colors, IN.c.xy); 
     26 
    2527        // normal discontinuity filter 
    2628        float3 nc = (float3)tex2D(normals, IN.c.xy); 
     
    3739        float ne = saturate(dot(nd, e_weights.x)); 
    3840 
    39         // opposite coordinates 
     41        // construct opposite coordinates 
    4042        float4 lrr = IN.lr.wzyx; 
    4143        float4 tbr = IN.tb.wzyx; 
     
    6668 
    6769        dd = abs(2.0f * dc - dd) - e_barrier.y; 
    68         dd = step(dd, 0.0f); 
     70        dd = step(dd, (float4)0.0f); 
    6971 
    7072        float de = saturate(dot(dd, e_weights.y)); 
     
    7779        float2 offset = IN.c.xy * (1.0f - w); 
    7880 
    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)); 
    8385 
    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 
    8593        //return float4(w); 
    8694} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r2882 r2884  
    5454 
    5555        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)); 
    5757        float4 position = tex2D(positions, IN.texCoord.xy); 
    5858 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg

    r2882 r2884  
    11//////////////////// 
    2 // Screen Spaced Ambient Occlusion shader 
     2// SSAO + color bleeding shader 
    33// based on shader of Alexander Kusternig 
    44 
    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" 
    196 
    207 
     
    8370 
    8471                //sample noisetex; r stores costheta, g stores sintheta 
     72                //float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f; 
    8573                float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy; 
    8674 
     
    210198         
    211199        OUT.illum_col = (col + illum) * ao; 
     200        OUT.illum_col.w = col.w; 
    212201 
    213202        return OUT; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r2882 r2884  
     1#include "../shaderenv.h" 
     2 
    13//////////////////// 
    24// Screen Spaced Ambient Occlusion shader 
    35// based on shader of Alexander Kusternig 
    46 
    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 
    177 
    188 
     
    6656        for (int i = 0; i < NUM_SAMPLES; ++ i)  
    6757        { 
    68                 float2 offset = samples[i]; 
     58                const float2 offset = samples[i]; 
    6959 
    7060                //////////////////// 
    7161                // add random noise: r stores costheta, g stores sintheta 
    7262 
    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; 
    7464                float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy; 
    7565 
    76                 float2 offsetTransformed = reflect(offset, mynoise); 
     66                const float2 offsetTransformed = reflect(offset, mynoise); 
    7767 
    7868                // weight with projected coordinate to reach similar kernel size for near and far 
     
    165155                (abs(depthDif) < 1e-3f)) 
    166156        { 
    167                 OUT.illum_col.x = ao * expFactor + oldCol.x * (1.0f - expFactor); 
     157                OUT.illum_col = (float4)ao * expFactor + oldCol.x * (1.0f - expFactor); 
    168158        } 
    169159        else 
    170160        { 
    171                 OUT.illum_col.x = ao; 
     161                OUT.illum_col = (float4)ao; 
    172162        } 
    173163 
     
    178168 
    179169 
    180  
    181170pixel combine(fragment IN,  
    182171                          uniform sampler2D colors, 
     
    185174        pixel OUT; 
    186175 
    187         float4 col = tex2D(colors, IN.texCoord.xy); 
     176        float4 col = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 
    188177        float4 ao = tex2D(ssaoTex, IN.texCoord.xy); 
    189178 
    190179        OUT.illum_col = col * ao.x; 
     180        OUT.illum_col.w = ao.w; 
    191181 
    192182        return OUT; 
Note: See TracChangeset for help on using the changeset viewer.