Changeset 3010 for GTP/trunk


Ignore:
Timestamp:
10/07/08 03:02:30 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
2 added
9 edited

Legend:

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

    r2961 r3010  
    22Microsoft Visual Studio Solution File, Format Version 9.00 
    33# Visual Studio 2005 
    4 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "friendlyculling", "FriendlyCulling.vcproj", "{03661866-4093-4B02-B26A-028EA91AF023}" 
     4Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DemoEngine", "FriendlyCulling.vcproj", "{03661866-4093-4B02-B26A-028EA91AF023}" 
    55EndProject 
    66Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Converter", "Converter.vcproj", "{93A522E1-76F0-4D46-9C97-30DC2DDB531D}" 
     7EndProject 
     8Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FriendlyCulling", "MainApp.vcproj", "{A564071F-D054-4556-883B-999D7F9CC58C}" 
     9        ProjectSection(ProjectDependencies) = postProject 
     10                {03661866-4093-4B02-B26A-028EA91AF023} = {03661866-4093-4B02-B26A-028EA91AF023} 
     11        EndProjectSection 
    712EndProject 
    813Global 
     
    2025                {93A522E1-76F0-4D46-9C97-30DC2DDB531D}.Release|Win32.ActiveCfg = Release|Win32 
    2126                {93A522E1-76F0-4D46-9C97-30DC2DDB531D}.Release|Win32.Build.0 = Release|Win32 
     27                {A564071F-D054-4556-883B-999D7F9CC58C}.Debug|Win32.ActiveCfg = Debug|Win32 
     28                {A564071F-D054-4556-883B-999D7F9CC58C}.Debug|Win32.Build.0 = Debug|Win32 
     29                {A564071F-D054-4556-883B-999D7F9CC58C}.Release|Win32.ActiveCfg = Release|Win32 
     30                {A564071F-D054-4556-883B-999D7F9CC58C}.Release|Win32.Build.0 = Release|Win32 
    2231        EndGlobalSection 
    2332        GlobalSection(SolutionProperties) = preSolution 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj

    r2980 r3010  
    33        ProjectType="Visual C++" 
    44        Version="8,00" 
    5         Name="friendlyculling" 
     5        Name="DemoEngine" 
    66        ProjectGUID="{03661866-4093-4B02-B26A-028EA91AF023}" 
    77        RootNamespace="chc_revisited" 
     
    9898                <Configuration 
    9999                        Name="Release|Win32" 
    100                         OutputDirectory="$(SolutionDir)/bin/$(ConfigurationName)" 
     100                        OutputDirectory="$(SolutionDir)/lib/$(ConfigurationName)" 
    101101                        IntermediateDirectory="obj/$(ConfigurationName)" 
    102                         ConfigurationType="1" 
     102                        ConfigurationType="4" 
    103103                        CharacterSet="1" 
    104104                        WholeProgramOptimization="1" 
     
    150150                        /> 
    151151                        <Tool 
    152                                 Name="VCLinkerTool" 
    153                                 AdditionalDependencies="glut32.lib glew32s.lib glew32.lib DevIL.lib ILUT.lib zlib.lib cg.lib cgGL.lib" 
    154                                 LinkIncremental="1" 
    155                                 AdditionalLibraryDirectories="libs/GL;libs/Devil/lib;libs/Zlib/lib;&quot;$(CG_LIB_PATH)&quot;" 
    156                                 IgnoreAllDefaultLibraries="false" 
    157                                 IgnoreDefaultLibraryNames="LIBCMT" 
    158                                 GenerateDebugInformation="false" 
    159                                 SubSystem="1" 
    160                                 OptimizeReferences="2" 
    161                                 EnableCOMDATFolding="2" 
    162                                 OptimizeForWindows98="1" 
    163                                 TargetMachine="1" 
     152                                Name="VCLibrarianTool" 
    164153                        /> 
    165154                        <Tool 
     
    167156                        /> 
    168157                        <Tool 
    169                                 Name="VCManifestTool" 
    170                         /> 
    171                         <Tool 
    172158                                Name="VCXDCMakeTool" 
    173159                        /> 
     
    177163                        <Tool 
    178164                                Name="VCFxCopTool" 
    179                         /> 
    180                         <Tool 
    181                                 Name="VCAppVerifierTool" 
    182                         /> 
    183                         <Tool 
    184                                 Name="VCWebDeploymentTool" 
    185165                        /> 
    186166                        <Tool 
     
    240220                        </File> 
    241221                        <File 
     222                                RelativePath=".\src\IrradianceMap.cpp" 
     223                                > 
     224                        </File> 
     225                        <File 
     226                                RelativePath=".\src\IrradianceMap.h" 
     227                                > 
     228                        </File> 
     229                        <File 
    242230                                RelativePath=".\src\MotionPath.cpp" 
    243231                                > 
     
    269257                        <File 
    270258                                RelativePath=".\src\SceneEntityConverter.h" 
    271                                 > 
    272                         </File> 
    273                         <File 
    274                                 RelativePath=".\src\shaderenv.h" 
    275259                                > 
    276260                        </File> 
     
    531515                                </File> 
    532516                                <File 
     517                                        RelativePath=".\src\shaderenv.h" 
     518                                        > 
     519                                </File> 
     520                                <File 
    533521                                        RelativePath=".\src\ShadowMapping.h" 
    534522                                        > 
     
    599587                                                /> 
    600588                                        </FileConfiguration> 
    601                                 </File> 
    602                                 <File 
    603                                         RelativePath=".\src\chcdemo.cpp" 
    604                                         > 
    605589                                </File> 
    606590                                <File 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3009 r3010  
    573573                sColorsTexDownSampleParam = cgGetNamedParameter(sCgDownSampleProgram, "colors");  
    574574                sDownSampleOffsetParam = cgGetNamedParameter(sCgDownSampleProgram, "downSampleOffs"); 
    575                  
    576                 float downSampleOffsets[8]; 
    577  
    578                 float w = 1028; 
    579                 float h = 768; 
    580  
    581                 float xoffs = 0.5f / w; 
    582                 float yoffs = 0.5f / h; 
    583  
    584                 downSampleOffsets[0] =  xoffs; downSampleOffsets[1] =  yoffs; 
    585                 downSampleOffsets[2] =  xoffs; downSampleOffsets[3] = -yoffs; 
    586                 downSampleOffsets[4] = -xoffs; downSampleOffsets[5] = -yoffs; 
    587                 downSampleOffsets[6] = -xoffs; downSampleOffsets[7] =  yoffs; 
    588  
    589                 cgGLSetParameterArray2f(sDownSampleOffsetParam, 0, 4, (const float *)downSampleOffsets); 
    590575        } 
    591576        else 
     
    12141199{ 
    12151200        // hack: estimate value where sky burns out 
    1216         whiteLum = log(1e4f); 
     1201        whiteLum = log(WHITE_LUMINANCE); 
    12171202         
    12181203        //////////////////// 
     
    12981283 
    12991284 
     1285static void ComputeDownsSampleOffsets(float *downSampleOffsets, int w, int h) 
     1286{ 
     1287        /* 
     1288        float downSampleOffsets[8]; 
     1289 
     1290        const float xoffs = 0.5f / w; 
     1291        const float yoffs = 0.5f / h; 
     1292 
     1293        downSampleOffsets[0] =  xoffs; downSampleOffsets[1] =  yoffs; 
     1294        downSampleOffsets[2] =  xoffs; downSampleOffsets[3] = -yoffs; 
     1295        downSampleOffsets[4] = -xoffs; downSampleOffsets[5] = -yoffs; 
     1296        downSampleOffsets[6] = -xoffs; downSampleOffsets[7] =  yoffs; 
     1297        */ 
     1298        const float xoffs = .5f / w; 
     1299        const float yoffs = .5f / h; 
     1300 
     1301        int idx  = 0; 
     1302 
     1303        for (int x = -1; x <= 1; ++ x) 
     1304        { 
     1305                for (int y = -1; y <= 1; ++ y) 
     1306                { 
     1307                        downSampleOffsets[idx + 0] = x * xoffs; 
     1308                        downSampleOffsets[idx + 1] = y * yoffs; 
     1309 
     1310                        idx += 2; 
     1311                } 
     1312        } 
     1313} 
     1314 
     1315 
    13001316void DeferredRenderer::DownSample(FrameBufferObject *fbo, int bufferIdx, 
    13011317                                                                  FrameBufferObject *downSampleFbo,  
    13021318                                                                  int downSampleBufferIdx) 
    13031319{ 
     1320        float downSampleOffsets[NUM_DOWNSAMPLES * 2]; 
     1321        ComputeDownsSampleOffsets(downSampleOffsets, fbo->GetWidth(), fbo->GetHeight()); 
     1322 
    13041323        ColorBufferObject *colorBuffer = fbo->GetColorBuffer(bufferIdx); 
    13051324        GLuint colorsTex = colorBuffer->GetTexture(); 
     
    13121331        cgGLSetTextureParameter(sColorsTexDownSampleParam, colorsTex); 
    13131332        cgGLEnableTextureParameter(sColorsTexDownSampleParam); 
     1333 
     1334        cgGLSetParameterArray2f(sDownSampleOffsetParam, 0, NUM_DOWNSAMPLES, (const float *)downSampleOffsets); 
    13141335 
    13151336        mDownSampleFbo->Bind(); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3009 r3010  
    5959/// the renderable scene geometry 
    6060SceneEntityContainer sceneEntities; 
    61 SceneEntityContainer sceneEntities2; 
    6261// traverses and renders the hierarchy 
    6362RenderTraverser *traverser = NULL; 
     
    18281827        DEL_PTR(ssaoShader); 
    18291828 
    1830         CLEAR_CONTAINER(sceneEntities2); 
    1831  
    18321829        if (sCgMrtVertexProgram) 
    18331830                cgDestroyProgram(sCgMrtVertexProgram); 
     
    20302027                 
    20312028                if (!showAlgorithmTime) 
    2032                 { 
    2033                         sprintf(msg[7], "%s:  %6.1f fps", alg_str[renderMode], fps); 
    2034                 } 
     2029                                sprintf(msg[7], "%s:  %6.1f fps", alg_str[renderMode], fps); 
    20352030                else 
    2036                 { 
    20372031                        sprintf(msg[7], "%s:  %6.1f ms", alg_str[renderMode], rTime); 
    2038                 } 
    2039  
     2032                 
    20402033                myfont.DrawString(msg[7], 1.3f, 690.0f, 760.0f);//, top_color, bottom_color); 
    20412034                 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r3009 r3010  
    99//#define NUM_SAMPLES 16 
    1010 
    11 // for linear falloff 
    12 //#define SAMPLE_INTENSITY 500.0f 
     11// for quadratic falloff 
     12#define SAMPLE_INTENSITY 0.35f 
     13//#define SAMPLE_INTENSITY 0.32f 
    1314 
    14 // for quadratic falloff 
    15 #define SAMPLE_INTENSITY 0.32f 
    16 //#define SAMPLE_INTENSITY 0.85f 
    17  
    18 //#define AREA_SIZE 15e-1f 
    1915#define AREA_SIZE 8e-1f 
    20  
    21 #define VIEW_CORRECTION_SCALE 0.0f 
    22 //#define VIEW_CORRECTION_SCALE 0.1f 
    2316 
    2417//#define DISTANCE_SCALE 1e-4f 
     
    2619 
    2720#define ILLUM_INTENSITY 5e-1f; 
    28 //#define ILLUM_INTENSITY 9e-1f; 
    2921 
    30 #define SSAO_MIPMAP_LEVEL 0//1 
    31 #define GI_MIPMAP_LEVEL 0//2 
     22#define VIEW_CORRECTION_SCALE 0.1f 
    3223 
    3324 
     
    4738#define LOGLUM_RANGE 20.0f 
    4839 
    49 #define MAX_LOD_LEVEL 99 
     40#define MAX_LOD_LEVEL 10 
    5041 
    51 #define MIN_DEPTH_DIFF 1e-5f 
     42#define MIN_DEPTH_DIFF 1e-3f 
     43// burnout 
     44#define WHITE_LUMINANCE 3e4f 
     45 
     46/////////////////// 
     47 
     48#define NUM_DOWNSAMPLES 9 
    5249 
    5350 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg

    r3009 r3010  
    103103                //if ((texcoord.x <= 1.0f) && (texcoord.x >= 0.0f) && (texcoord.y <= 1.0f) && (texcoord.y >= 0.0f)) ++ numSamples; 
    104104 
     105 
    105106                ////////// 
    106107                //-- reconstruct world space position from sample 
    107108 
    108                 float4 sample = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)); 
     109                float4 sample = tex2Dlod(colors, float4(texcoord, 0, 0)); 
    109110                const float eyeSpaceDepth = sample.w; 
    110111                //float3 rotView = normalize(Interpol(texcoord, bl, br, tl, tr)); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3009 r3010  
    5252{ 
    5353#if USE_EYE_SPACE_DEPTH 
    54         float eyeSpaceDepth = tex2Dlod(colors, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).w; 
     54        float eyeSpaceDepth = tex2Dlod(colors, float4(texcoord, 0, 0)).w; 
    5555        //float3 rotView = normalize(Interpol(texcoord, bl, br, tl, tr)); 
    5656        float3 rotView = Interpol(texcoord, bl, br, tl, tr); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao3d.cg

    r2998 r3010  
    7676                        ++ j; 
    7777                        // sample downsampled texture in order to speed up texture accesses 
    78                         float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, SSAO_MIPMAP_LEVEL)).xyz; 
     78                        float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, 0)).xyz; 
    7979                        //float3 sample_position = tex2D(positions, texcoord).xyz; 
    8080 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg

    r3008 r3010  
    2020 
    2121 
    22 float4 DownSample(frag IN, 
     22/*float4 DownSample(frag IN, 
    2323                                  uniform sampler2D colors, 
    24                                   uniform float2 downSampleOffs[4]): COLOR 
     24                                  uniform float2 downSampleOffs[9]): COLOR 
    2525{     
    2626    float4 average = .0f; 
    2727 
    28     for(int i = 0; i < 4; ++ i) 
     28        const float4 avgColor = tex2Dlod(colors, float4(IN.texCoord, 0, 0)); 
     29 
     30        float j = 0; 
     31        float4 color; 
     32 
     33    for (int i = 0; i < 9; ++ i) 
    2934    { 
    30         average += tex2Dlod(colors, float4(IN.texCoord + downSampleOffs[i],0,0)); 
     35                color = tex2Dlod(colors, float4(IN.texCoord + downSampleOffs[i], 0, 0)); 
     36                if (abs(color.w - avgColor.w) < 1e-3f) 
     37                { 
     38                        average += color; 
     39                        ++ j; 
     40                } 
    3141    } 
    3242         
    33     average *= 1.0f / 4.0f; 
     43    //average *= 1.0f / 9.0f; 
     44    average *= 1.0f / j; 
     45 
     46    return average; 
     47}*/ 
     48   
     49float4 DownSample(frag IN, 
     50                                  uniform sampler2D colors, 
     51                                  uniform float2 downSampleOffs[NUM_DOWNSAMPLES]): COLOR 
     52{     
     53    float4 average = .0f; 
     54 
     55    for (int i = 0; i < NUM_DOWNSAMPLES; ++ i) 
     56    { 
     57                average += tex2Dlod(colors, float4(IN.texCoord + downSampleOffs[i], 0, 0)); 
     58    } 
     59        
     60        average *= 1.0f / (float)NUM_DOWNSAMPLES; 
    3461 
    3562    return average; 
    3663} 
    37      
     64 
     65 
     66/** Does the first downsampling step and on the same time calculates the  
     67        intensity. 
     68*/ 
    3869 
    3970float4 GreyScaleDownSample(frag IN, 
    40                                                    uniform sampler2D colors 
     71                                                   uniform sampler2D colors, 
     72                                                   uniform float2 downSampleOffs[4] 
    4173                                                   ): COLOR 
    4274{ 
     
    5082        //float3 w = float3(0.2125f, 0.7154f, 0.0721f); 
    5183 
    52         float4 cols[4]; 
    53  
    54         cols[0] = tex2D(colors, IN.lt); 
    55         cols[1] = tex2D(colors, IN.lb); 
    56         cols[2] = tex2D(colors, IN.rt); 
    57         cols[3] = tex2D(colors, IN.rb); 
     84        float4 color; 
    5885 
    5986        for (int i = 0; i < 4; ++ i) 
    6087        { 
     88                color = tex2D(colors, downSampleOffs[i]); 
     89 
    6190                const float intensity = dot(cols[i].rgb, w); 
    6291 
     
    6594        } 
    6695 
    67         average = exp(average * 0.25f); 
     96        average *= 0.25f; 
    6897 
    69         float4 c = cols[0] + cols[1] + cols[2] + cols[3]; 
    70  
    71         return c * 0.25f; 
    7298        // Output the luminance to the render target 
    73         //return float4(average, maximum, 0.0f, 1.0f); 
     99        return float4(average, maximum, 0.0f, 1.0f); 
    74100} 
    75101     
     102 
     103/** Used for downsampling the tone map parameters (average loglum, maximum) 
     104        to the next lower level. This has to be applied until there is only 
     105        a 1x1 texture which holds the required numbers. 
     106*/ 
     107float4 DownSampleForToneMapping(frag IN, 
     108                                                                uniform sampler2D colors, 
     109                                                                uniform float2 downSampleOffs[4]): COLOR 
     110{     
     111        float average = .0f; 
     112        float maximum = .0f; 
     113         
     114        float4 color; 
     115 
     116        for (int i = 0; i < 4; ++ i) 
     117        { 
     118                color = tex2D(colors, downSampleOffs[i]); 
     119 
     120                maximum = max(maximum, color.y); 
     121                average += color.x; 
     122        } 
     123 
     124        average *= 1.0f / (float)NUM_DOWNSAMPLES; 
     125 
     126        return float4(average, maximum, 0.0f, 1.0f); 
     127} 
     128 
     129 
    76130 
    77131pixel ToneMap(frag IN, 
Note: See TracChangeset for help on using the changeset viewer.