Ignore:
Timestamp:
10/08/08 17:39:20 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj

    r3010 r3016  
    515515                                </File> 
    516516                                <File 
    517                                         RelativePath=".\src\shaderenv.h" 
    518                                         > 
    519                                 </File> 
    520                                 <File 
    521517                                        RelativePath=".\src\ShadowMapping.h" 
    522518                                        > 
     
    769765                        <File 
    770766                                RelativePath=".\src\shaders\mrt.cg" 
     767                                > 
     768                        </File> 
     769                        <File 
     770                                RelativePath=".\src\shaderenv.h" 
    771771                                > 
    772772                        </File> 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3015 r3016  
    7070static CGparameter sOldModelViewProjMatrixParam; 
    7171static CGparameter sModelViewProjMatrixParam; 
    72 static CGparameter sMaxDepthParam; 
    7372static CGparameter sEyePosParam; 
    7473static CGparameter sEyePosShadowParam; 
     
    8382 
    8483static CGparameter sColorsTexGiParam; 
    85 static CGparameter sPositionsTexGiParam; 
    8684static CGparameter sNormalsTexGiParam; 
    8785 
     
    8987static CGparameter sOldModelViewProjMatrixGiParam; 
    9088static CGparameter sModelViewProjMatrixGiParam; 
    91 static CGparameter sMaxDepthGiParam; 
    9289static CGparameter sSamplesGiParam;  
    9390static CGparameter sOldSsaoTexGiParam; 
     
    131128 
    132129static CGparameter sShadowMatrixParam; 
    133 static CGparameter sMaxDepthShadowParam; 
    134130static CGparameter sSampleWidthParam; 
    135131 
     
    274270mWidth(w), mHeight(h),  
    275271mCamera(cam), 
    276 mScaleFactor(scaleFactor), 
    277272mUseTemporalCoherence(true), 
    278273mRegenerateSamples(true), 
     
    374369                sOldModelViewProjMatrixParam = cgGetNamedParameter(sCgSsaoProgram, "oldModelViewProj"); 
    375370                sModelViewProjMatrixParam = cgGetNamedParameter(sCgSsaoProgram, "modelViewProj"); 
    376                 sMaxDepthParam = cgGetNamedParameter(sCgSsaoProgram, "maxDepth"); 
    377371                sTemporalCoherenceParam = cgGetNamedParameter(sCgSsaoProgram, "temporalCoherence"); 
    378372 
     
    401395 
    402396                // we need size of texture for scaling 
    403                 sPositionsTexGiParam = cgGetNamedParameter(sCgGiProgram, "positions");   
    404397                sColorsTexGiParam = cgGetNamedParameter(sCgGiProgram, "colors");   
    405398                sNormalsTexGiParam = cgGetNamedParameter(sCgGiProgram, "normals");   
     
    407400                sOldModelViewProjMatrixGiParam = cgGetNamedParameter(sCgGiProgram, "oldModelViewProj"); 
    408401                sModelViewProjMatrixGiParam = cgGetNamedParameter(sCgGiProgram, "modelViewProj"); 
    409                 sMaxDepthGiParam = cgGetNamedParameter(sCgGiProgram, "maxDepth"); 
    410402                sTemporalCoherenceGiParam = cgGetNamedParameter(sCgGiProgram, "temporalCoherence"); 
    411403 
     
    501493 
    502494                sShadowMapParam = cgGetNamedParameter(sCgDeferredShadowProgram, "shadowMap");   
    503                 sMaxDepthShadowParam = cgGetNamedParameter(sCgDeferredShadowProgram, "maxDepth"); 
    504495                sSampleWidthParam = cgGetNamedParameter(sCgDeferredShadowProgram, "sampleWidth"); 
    505496                sShadowMatrixParam = cgGetNamedParameter(sCgDeferredShadowProgram, "shadowMatrix"); 
     
    696687 
    697688        cgGLSetMatrixParameterfc(sOldModelViewProjMatrixParam, (const float *)oldProjViewMatrix.x); 
    698 #if 1 
     689#if 0 
    699690        GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
    700691        GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
     
    733724        cgGLEnableTextureParameter(sOldTexParam); 
    734725         
    735         cgGLSetParameter1f(sMaxDepthParam, mScaleFactor); 
    736  
    737         Vector3 pos = mCamera->GetPosition() / mScaleFactor; 
     726        Vector3 pos = mCamera->GetPosition(); 
    738727        cgGLSetParameter3f(sEyePosParam, pos.x, pos.y, pos.z); 
    739728         
     
    913902        cgGLSetMatrixParameterfc(sModelViewProjMatrixGiParam, (const float *)projViewMatrix.x); 
    914903 
    915         //GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
     904#if 0 
     905        GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
     906        GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
     907#else 
    916908        GLuint colorsTex = mDownSampleFbo->GetColorBuffer(0)->GetTexture(); 
    917909        GLuint normalsTex = mDownSampleFbo->GetColorBuffer(1)->GetTexture(); 
    918         GLuint positionsTex = fbo->GetColorBuffer(2)->GetTexture(); 
     910#endif 
    919911 
    920912        glPushAttrib(GL_VIEWPORT_BIT); 
     
    931923        cgGLBindProgram(sCgGiProgram); 
    932924 
    933         cgGLSetTextureParameter(sPositionsTexGiParam, positionsTex); 
    934         cgGLEnableTextureParameter(sPositionsTexGiParam); 
    935925 
    936926        cgGLSetTextureParameter(sColorsTexGiParam, colorsTex); 
     
    948938        cgGLSetTextureParameter(sOldIllumTexGiParam, oldIllumTex); 
    949939        cgGLEnableTextureParameter(sOldIllumTexGiParam); 
    950  
    951         cgGLSetParameter1f(sMaxDepthGiParam, mScaleFactor); 
    952940 
    953941 
     
    964952                GenerateSamples(mSamplingMethod);  
    965953 
    966 #ifdef USE_3D_SSAO 
    967                 cgGLSetParameterArray3f(sSamplesGiParam, 0, NUM_SAMPLES, (const float *)samples3); 
    968 #else 
    969954                cgGLSetParameterArray2f(sSamplesGiParam, 0, NUM_SAMPLES, (const float *)samples2); 
    970 #endif 
    971955        } 
    972956 
     
    975959        ComputeViewVectors(tl, tr, bl, br); 
    976960         
    977         const Vector3 pos = mCamera->GetPosition() / mScaleFactor; 
     961        const Vector3 pos = mCamera->GetPosition(); 
    978962        cgGLSetParameter3f(sEyePosGiParam, pos.x, pos.y, pos.z); 
    979963 
     
    997981 
    998982        cgGLDisableTextureParameter(sColorsTexGiParam); 
    999         cgGLDisableTextureParameter(sPositionsTexGiParam); 
    1000983        cgGLDisableTextureParameter(sNormalsTexGiParam); 
    1001984        cgGLDisableTextureParameter(sNoiseTexGiParam); 
     
    11321115        cgGLEnableTextureParameter(sShadowMapParam); 
    11331116 
    1134         cgGLSetParameter1f(sMaxDepthShadowParam, mScaleFactor); 
    1135  
    11361117        cgGLSetParameter1f(sSampleWidthParam, 2.0f / shadowMap->GetSize()); 
    11371118         
     
    11481129        ComputeViewVectors(tl, tr, bl, br); 
    11491130         
    1150         const Vector3 pos = mCamera->GetPosition() / mScaleFactor; 
     1131        const Vector3 pos = mCamera->GetPosition(); 
    11511132        cgGLSetParameter3f(sEyePosShadowParam, pos.x, pos.y, pos.z); 
    11521133 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h

    r3007 r3016  
    103103        int mHeight; 
    104104 
    105         /// a scale factor of scene positions in order to get better float precision in the shader 
    106         float mScaleFactor; 
    107  
    108105        Camera *mCamera; 
    109106 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3015 r3016  
    2424#include "RenderQueue.h" 
    2525#include "Material.h" 
    26 #include <Cg/cg.h> 
    27 #include <Cg/cgGL.h> 
    2826#include "glfont2.h" 
    2927#include "PerformanceGraph.h" 
     
    4240#include "EntityMerger.h" 
    4341 
     42#include <Cg/cg.h> 
     43#include <Cg/cgGL.h> 
    4444 
    4545 
     
    9898SkyPreetham *preetham = NULL; 
    9999 
     100 
    100101/// the used render type for this render pass 
    101102enum RenderMethod 
     
    269270static CGprogram sCgMrtVertexProgram = NULL; 
    270271 
    271 static CGparameter sMaxDepthParam; 
    272 static CGparameter sMaxDepthParamTex; 
    273272static CGparameter sEyePosParamTex; 
    274273static CGparameter sEyePosParam; 
     
    565564                cgGLLoadProgram(RenderState::sCgMrtFragmentTexProgram); 
    566565 
    567                 sMaxDepthParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "maxDepth"); 
    568566                sEyePosParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "eyePos"); 
    569567                RenderState::sTexParam = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "tex"); 
    570568         
    571                 //const float maxDepth = MAX_DEPTH_CONST / farDist; 
    572                 const float maxDepth = 1.0f; 
    573  
    574                 cgGLSetParameter1f(sMaxDepthParamTex, maxDepth); 
    575  
    576569                sTLParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "tl");  
    577570                sTRParamTex = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "tr");  
     
    594587                cgGLLoadProgram(RenderState::sCgMrtFragmentProgram); 
    595588 
    596                 sMaxDepthParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "maxDepth"); 
    597589                sEyePosParam = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "eyePos"); 
    598590                 
    599                 //const float maxDepth = MAX_DEPTH_CONST / farDist; 
    600                 const float maxDepth = 1.0f; 
    601  
    602                 cgGLSetParameter1f(sMaxDepthParam, maxDepth); 
    603  
    604591                sTLParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "tl");  
    605592                sTRParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "tr");  
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r3015 r3016  
    1010 
    1111// for quadratic falloff 
    12 #define SAMPLE_INTENSITY 0.35f 
     12#define SAMPLE_INTENSITY 0.15f 
    1313//#define SAMPLE_INTENSITY 0.32f 
    1414 
    1515#define AREA_SIZE 8e-1f 
    1616 
    17 #define DISTANCE_SCALE 1e-1f 
    18 //#define DISTANCE_SCALE 1e-6f 
     17//#define DISTANCE_SCALE 1e-1f 
     18#define DISTANCE_SCALE 5e-2f 
    1919 
    20 #define ILLUM_INTENSITY 5e-1f; 
     20#define ILLUM_INTENSITY 5e-2f 
    2121 
    2222#define VIEW_CORRECTION_SCALE 0.1f 
     
    4040#define MAX_LOD_LEVEL 10 
    4141 
    42 #define MIN_DEPTH_DIFF 1e-1f 
     42#define MIN_DEPTH_DIFF 1e-3f 
    4343// burnout 
    4444#define WHITE_LUMINANCE 3e4f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r3014 r3016  
    140140                                  uniform sampler2D shadowMap, 
    141141                                  uniform float4x4 shadowMatrix, 
    142                                   uniform float maxDepth, 
    143142                                  uniform float sampleWidth, 
    144143                                  uniform sampler2D noiseTexture, 
     
    183182                ) 
    184183        { 
    185                 position *= maxDepth; 
    186184                position.w = 1.0f; 
    187185 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg

    r3014 r3016  
    1010         // normalized screen position 
    1111        float4 pos: WPOS; 
    12         float4 texCoord: TEXCOORD0;  
     12        float2 texCoord: TEXCOORD0;  
    1313        float3 view: TEXCOORD1; 
    1414}; 
     
    123123                float cos_angle = max(dot(direction_to_sample, currentNormal), 0); 
    124124 
     125                const float denom = (DISTANCE_SCALE + length_to_sample * length_to_sample); 
    125126                // distance between current position and sample position controls AO intensity. 
    126                 const float distance_intensity =  
    127                         (SAMPLE_INTENSITY * DISTANCE_SCALE) / (DISTANCE_SCALE + length_to_sample * length_to_sample); 
     127                const float ssao_intensity = SAMPLE_INTENSITY / denom; 
     128 
     129                const float illum_intensity = ILLUM_INTENSITY / denom; 
    128130 
    129131                // if normal perpenticular to view dir, only half of the samples count 
     
    133135                total_color.xyz += cos_angle * distance_intensity * view_correction * sample_color * ILLUM_INTENSITY; 
    134136#endif 
    135                 total_ao += cos_angle * distance_intensity; 
    136                 total_color += cos_angle * distance_intensity * sample_color * ILLUM_INTENSITY; 
     137                total_ao += cos_angle * ssao_intensity; 
     138                total_color += cos_angle * illum_intensity * sample_color; 
    137139        } 
    138140 
     
    148150pixel2 main(fragment IN,  
    149151                   uniform sampler2D colors, 
    150                    uniform sampler2D positions, 
    151152                   uniform sampler2D normals, 
    152153                   uniform sampler2D noiseTexture, 
     
    156157                   const uniform float4x4 oldModelViewProj, 
    157158                   const uniform float4x4 modelViewProj, 
    158                    uniform float maxDepth, 
    159159                   uniform float temporalCoherence, 
    160160                   uniform float3 eyePos, 
     
    167167        pixel2 OUT; 
    168168 
    169         float4 norm = tex2D(normals, IN.texCoord.xy); 
     169        float4 norm = tex2Dlod(normals, float4(IN.texCoord, 0 ,0)); 
    170170        float3 normal = normalize(norm.xyz);     
    171171 
     
    178178 
    179179        float3 viewDir = IN.view; 
    180         const float eyeDepth = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)).w; 
     180        const float eyeDepth = tex2Dlod(colors, float4(IN.texCoord, 0, 0)).w; 
    181181         
    182182        const float3 eyeSpacePos = -viewDir * eyeDepth; 
    183183 
    184         float3 centerPosition; 
    185         centerPosition.xyz = eyePos - viewDir * eyeDepth; 
    186          
     184        float3 centerPosition = eyePos + eyeSpacePos; 
    187185        //const float3 centerPosition = tex2D(positions, IN.texCoord.xy).xyz; 
    188186 
     
    197195        //-- compute temporally smoothing 
    198196 
    199         float4 realPos = float4(centerPosition * maxDepth, 1.0f); 
     197        float4 realPos = float4(centerPosition, 1.0f); 
    200198 
    201199 
     
    269267        pixel OUT; 
    270268 
    271         float4 col = tex2D(colors, IN.texCoord.xy); 
    272         float ao = tex2D(ssaoTex, IN.texCoord.xy).x; 
    273         float4 illum = tex2D(illumTex, IN.texCoord.xy); 
    274          
     269        float4 col = tex2Dlod(colors, float4(IN.texCoord, 0, 0)); 
     270        float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)).x; 
     271        float4 illum = tex2Dlod(illumTex, float4(IN.texCoord, 0, 0)); 
     272 
    275273        OUT.illum_col = (col + illum) * ao; 
    276274        OUT.illum_col.w = col.w; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r3009 r3016  
    7878pixel fragtex(fragin IN,  
    7979                          uniform sampler2D dirtTex, 
    80                           uniform float maxDepth, 
    8180                          uniform sampler2D tex, 
    8281                          uniform float3 eyePos, 
     
    110109        const float2 screenCoord = projPos.xy * 0.5f + 0.5f; 
    111110        const float magView = length(Interpol(screenCoord, bl, br, tl, tr)); 
    112         pix.col.w = length(eyePos - IN.worldPos.xyz) * maxDepth / magView; 
     111        pix.col.w = length(eyePos - IN.worldPos.xyz) / magView; 
    113112 
    114113#if 0 
     
    122121 
    123122pixel frag(fragin IN,  
    124                    uniform float maxDepth,  
    125123                   uniform float3 eyePos, 
    126124                   uniform float3 bl, 
     
    147145        float2 screenCoord = projPos.xy * 0.5f + 0.5f; 
    148146        const float magView = length(Interpol(screenCoord, bl, br, tl, tr)); 
    149         pix.col.w = length(eyePos - IN.worldPos.xyz) * maxDepth / magView; 
     147        pix.col.w = length(eyePos - IN.worldPos.xyz) / magView; 
    150148 
    151149#if 0 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3014 r3016  
    150150                   const uniform float4x4 oldModelViewProj, 
    151151                   const uniform float4x4 modelViewProj, 
    152                    uniform float maxDepth, 
    153152                   uniform float temporalCoherence, 
    154153                   uniform float3 eyePos, 
     
    176175 
    177176        float3 centerPosition; 
    178         centerPosition.xyz = eyePos - viewDir * eyeDepth; 
     177        centerPosition.xyz = eyePos + eyeSpacePos; 
    179178 
    180179        const float2 ao = ssao(IN, colors, noiseTexture, samples, normal, eyeSpacePos, w, bl, br, tl, tr); 
     180 
    181181#else 
    182182 
     
    191191        //-- compute temporally smoothing 
    192192 
    193         float4 realPos = float4(centerPosition * maxDepth, 1.0f); 
     193        float4 realPos = float4(centerPosition, 1.0f); 
    194194 
    195195 
     
    264264        float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
    265265 
    266         //OUT.illum_col = col * ao.x; 
    267         OUT.illum_col = float4(ao.x,ao.x,ao.x, ao.w); 
     266        OUT.illum_col = col * ao.x; 
     267        //OUT.illum_col = float4(ao.x,ao.x,ao.x, ao.w); 
    268268        OUT.illum_col.w = col.w; 
    269269 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg

    r3014 r3016  
    5151                                  uniform float2 downSampleOffs[NUM_DOWNSAMPLES]): COLOR 
    5252{     
    53         //return tex2Dlod(colors, float4(IN.texCoord, 0, 0)); 
    54  
     53        return tex2Dlod(colors, float4(IN.texCoord, 0, 0)); 
     54/* 
    5555    float4 average = .0f; 
    5656 
     
    6262        average *= 1.0f / (float)NUM_DOWNSAMPLES; 
    6363 
    64     return average; 
     64    return average;*/ 
    6565} 
    6666 
Note: See TracChangeset for help on using the changeset viewer.