Changeset 3198 for GTP


Ignore:
Timestamp:
11/30/08 20:41:23 (15 years ago)
Author:
mattausch
Message:

removed some visual bugs (trees against sky), flickering much better now

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3197 r3198  
    1010#include "Light.h" 
    1111#include "ShaderManager.h" 
     12#include <math.h> 
    1213 
    1314#include <IL/il.h> 
     
    4142        assert(ilGetError() == IL_NO_ERROR); 
    4243} 
     44 
    4345 
    4446namespace CHCDemoEngine 
     
    111113                fprintf(stderr,"OpenGL ERROR: %s: %s\n", errStr, msg); 
    112114        } 
     115} 
     116 
     117 
     118static Sample2 UnitTest2(float x, float y, int wi, int he) 
     119{ 
     120        Sample2 s; 
     121 
     122        s.x = float(floor(x * (float)wi - 0.5f) + 1.0f) / (float)wi; 
     123        s.y = float(floor(y * (float)he - 0.5f) + 1.0f) / (float)he; 
     124 
     125        return s; 
    113126} 
    114127 
     
    309322 
    310323        /////////////// 
    311         //-- the downsampled ssao + color bleeding textures: as gi is inherently low frequency, we can use these to improve performance 
     324        //-- the downsampled ssao + color bleeding textures: as GI is mostly low frequency, we can use lower resolution toimprove performance 
    312325 
    313326        mDownSampleFbo = new FrameBufferObject(dsw, dsh, FrameBufferObject::DEPTH_NONE); 
    314         //mDownSampleFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
    315327        mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
    316         // downsample buffer for the normal texture 
    317         //mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
    318         mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST); 
    319         // downsample buffer for the offset texture 
    320         //mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
    321         mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST); 
    322  
    323         for (int i = 0; i < 3; ++ i) 
    324         { 
    325                 FrameBufferObject::InitBuffer(mDownSampleFbo, i); 
    326         } 
     328 
     329        FrameBufferObject::InitBuffer(mDownSampleFbo, 0); 
    327330 
    328331        mFBOs.push_back(mDownSampleFbo); 
     
    343346 
    344347        InitCg(); 
     348 
     349        float x = 400.5f / w; 
     350        float y = 100.5f / h; 
     351         
     352        Sample2 res = UnitTest2(x, y, dsw, dsh); 
     353 
     354        cout << "input  : " << x << ", " << y << endl; 
     355        cout << "result : " << res.x << " " << res.y << endl; 
     356        cout << "result2: " << res.x * w << " " << res.y * h << endl; 
    345357} 
    346358 
     
    447459         
    448460        string prepareSsaoParams[] =  
    449                 {"colorsTex", "normalsTex", "diffVals", "oldTex",  
     461                {"colorsTex", "diffVals", "oldTex",  
    450462                 "oldEyePos", "modelViewProj", "oldModelViewProj", 
    451463                 "oldbl", "oldbr", "oldtl", "oldtr"}; 
    452464 
    453         sCgPrepareSsaoProgram->AddParameters(prepareSsaoParams, 0, 11); 
     465        sCgPrepareSsaoProgram->AddParameters(prepareSsaoParams, 0, 10); 
    454466 
    455467 
     
    634646 
    635647        if (0) 
    636         { 
    637648                colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
    638                 normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
    639                 attribsTex = fbo->GetColorBuffer(2)->GetTexture(); 
    640         } 
    641649        else 
    642         { 
    643650                colorsTex = mDownSampleFbo->GetColorBuffer(0)->GetTexture(); 
    644                 normalsTex = mDownSampleFbo->GetColorBuffer(1)->GetTexture(); 
    645                 attribsTex = mDownSampleFbo->GetColorBuffer(2)->GetTexture(); 
    646                 //attribsTex = fbo->GetColorBuffer(2)->GetTexture(); 
    647         } 
     651         
     652        normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
     653        attribsTex = fbo->GetColorBuffer(2)->GetTexture(); 
    648654 
    649655        // flip flop between illumination buffers 
     
    10171023void DeferredRenderer::PrepareSsao(FrameBufferObject *fbo) 
    10181024{ 
    1019         GLuint colorsTex, normalsTex, diffVals, oldTex; 
    1020  
    1021         colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
    1022         normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
    1023         diffVals = fbo->GetColorBuffer(2)->GetTexture(); 
    1024  
     1025        GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
     1026        GLuint diffVals = fbo->GetColorBuffer(2)->GetTexture(); 
    10251027        // flip flop between illumination buffers 
    1026         oldTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex)->GetTexture(); 
     1028        GLuint oldTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex)->GetTexture(); 
    10271029 
    10281030        int i = 0; 
    10291031 
    10301032        sCgPrepareSsaoProgram->SetTexture(i ++, colorsTex); 
    1031         sCgPrepareSsaoProgram->SetTexture(i ++, normalsTex); 
    10321033        sCgPrepareSsaoProgram->SetTexture(i ++, diffVals); 
    10331034        sCgPrepareSsaoProgram->SetTexture(i ++, oldTex); 
     
    10511052        mDownSampleFbo->Bind(); 
    10521053 
    1053         glDrawBuffers(3, mrt + 0); 
     1054        glDrawBuffers(1, mrt); 
    10541055 
    10551056        DrawQuad(sCgPrepareSsaoProgram); 
     
    11891190} 
    11901191 
    1191  
    11921192} // namespace 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r3196 r3198  
    66//-- ssao + gi parameters 
    77 
    8 //#define NUM_SAMPLES 8 
     8#define NUM_SAMPLES 8 
    99//#define NUM_SAMPLES 16 
    10 #define NUM_SAMPLES 24 
     10//#define NUM_SAMPLES 24 
    1111 
    12 // for quadratic falloff 
    13 //#define SAMPLE_INTENSITY 0.9f 
    14 //#define SAMPLE_INTENSITY 2.0f 
    15  
    16 //#define SAMPLE_INTENSITY 0.075f 
    17 #define SAMPLE_INTENSITY 0.2f 
     12#define SAMPLE_INTENSITY 0.5f 
     13//#define SAMPLE_INTENSITY 1.0f 
    1814 
    1915#define SAMPLE_RADIUS 8e-1f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/antialiasing.cg

    r3189 r3198  
    4747        // weight the influence of normal discontinuities 
    4848        //const float ne = saturate(dot(nd, weights.x)); 
    49         const float ne = nd.x * nd.y *nd.z * nd.w * weights.x; 
     49        const float ne = nd.x * nd.y * nd.z * nd.w * weights.x; 
    5050 
    5151 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg

    r3197 r3198  
    122122        for (int i = 0; i < NUM_SSAO_FILTER_SAMPLES; ++ i) 
    123123        { 
    124                 sampleTexCoord = float4(texCoord + filterOffs[i] * scale, 0, 0); 
     124                sampleTexCoord = float4(texCoord + filterOffs[i] * scale, .0f, .0f); 
    125125 
    126126                aoSample = tex2Dlod(ssaoTex, sampleTexCoord); 
     
    128128 
    129129                // check spatial discontinuity 
    130                 // using the depth from the color texture is not 100% correct as depth was 
     130 
     131                // note: using the depth from the color texture is not 100% correct as depth was 
    131132                // not scaled with the interpolated view vector depth yet ... 
    132133                samplePos = ReconstructSamplePos(colorsTex, sampleTexCoord.xy, bl, br, tl, tr); 
     
    134135 
    135136                len = min(SqrLen(centerPos - samplePos), 1e2f); 
    136  
    137137                spatialFactor = 1.0f / max(len, 1e-3f); 
    138138 
    139139                //normalFactor = max(step(.0f, dot(sampleNorm, centerNormal)), 1e-2f); 
    140                 //normalFactor = max(dot(sampleNorm, samplePos), 1e-3f); 
    141140                convergenceFactor = aoSample.y + 1.0f; 
    142                 //convergenceFactor = max(step(0.5f + NUM_SAMPLES, aoSample.y), 1e-2f); 
    143                 //convergenceFactor = aoSample.y; 
    144  
     141                 
    145142                // combine the weights 
    146143                w = convergenceFactor * convergenceFactor * spatialFactor;// * normalFactor; 
    147                 //w = spatialFactor * normalFactor; 
    148  
     144                 
    149145                average += aoSample.x * w; 
    150146                total_w += w; 
     
    178174        float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
    179175 
    180         float4 dummy; 
    181         //const float xoffs = .5f / 1024.0f;    const float yoffs = .5f / 768.0f; 
    182         const float xoffs = 1.0f / 1024.0f;     const float yoffs = 1.0f / 768.0f; 
    183  
    184         dummy.x = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(xoffs, yoffs), 0, 0)).w; 
    185         dummy.y = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(xoffs, -yoffs), 0, 0)).w; 
    186         dummy.z = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(-xoffs, yoffs), 0, 0)).w; 
    187         dummy.w = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(-yoffs, -yoffs), 0, 0)).w; 
    188  
    189         /*dummy.x = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(xoffs, 0), 0, 0)).y; 
    190         dummy.y = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(0, yoffs), 0, 0)).y; 
    191         dummy.z = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(-xoffs, 0), 0, 0)).y; 
    192         dummy.w = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(0, -yoffs), 0, 0)).y; 
    193 */ 
    194         const float convergence = min(min(dummy.x, dummy.y), min(dummy.z, dummy.w)); 
    195         //const float convergence = max(max(dummy.x, dummy.y), max(dummy.z, dummy.w)); 
     176        // get the minimum convergence by exactly sampling the 4 surrounding 
     177        // texels in the old texture, otherwise flickering because convergence 
     178        // will be interpolated when upsampling and filter size does not match! 
     179        float4 texelCenterConv; 
     180        const float w = 512.0f; const float h = 384.0f; 
     181        const float xoffs = .5f / w; const float yoffs = .5f / h; 
     182 
     183        // get position exactly between old texel centers 
     184        float2 center; 
     185        center.x = float(floor(IN.texCoord.x * w - .5f) + 1.0f) / w; 
     186        center.y = float(floor(IN.texCoord.y * h - .5f) + 1.0f) / h; 
     187 
     188        texelCenterConv.x = tex2Dlod(ssaoTex, float4(center + float2(xoffs, yoffs), 0, 0)).y; 
     189        texelCenterConv.y = tex2Dlod(ssaoTex, float4(center + float2(xoffs, -yoffs), 0, 0)).y; 
     190        texelCenterConv.z = tex2Dlod(ssaoTex, float4(center + float2(-xoffs, yoffs), 0, 0)).y; 
     191        texelCenterConv.w = tex2Dlod(ssaoTex, float4(center + float2(-xoffs, -yoffs), 0, 0)).y; 
     192 
     193        const float m1 = min(texelCenterConv.x, texelCenterConv.y); 
     194        const float m2 = min(texelCenterConv.z, texelCenterConv.w); 
     195 
     196        const float convergence = min(m1, m2); 
    196197        //const float convergence = ao.y; 
    197198 
     
    201202        // filter up to a certain convergance value and leave out background (sky) by checking depth 
    202203        if ((convergence < thres) && (col.w < 1e10f)) 
    203         //if (col.w < 1e10f) 
    204204        { 
    205                 //const float eyeSpaceDepth = col.w; const float distanceScaleWeight = 2.0f; 
    206                 //const float distanceScale = distanceScaleWeight / (eyeSpaceDepth + distanceScaleWeight); 
    207205                const float distanceScale = 1.0f; 
    208206 
    209207                const float convergenceWeight = thres / (SSAO_FILTER_WIDTH - 1.0f); 
    210208                const float convergenceScale = convergenceWeight / (convergence + convergenceWeight); 
    211  
    212209                const float scale = SSAO_FILTER_WIDTH * convergenceScale * distanceScale; 
    213210 
    214211                // the filtered ssao value 
    215                 //ao.x = DiscontinuityFilter2(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, scale, bl, br, tl, tr); 
     212                ao.x = DiscontinuityFilter2(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, scale, bl, br, tl, tr); 
    216213        } 
    217214 
     
    221218                OUT.illum_col.xyz = col.xyz; 
    222219 
    223         //OUT.illum_col.xyz = float3(0, clamp(1.0f - ao.y * 1e-3f, 0, 1), 1); 
    224         //const float mydummy = ao.w * 1e-3f; 
    225         OUT.illum_col.xyz = float3(ao.x, ao.x, ao.x); 
     220        //OUT.illum_col.xyz = float3(ao.x, ao.x, step(thres, convergence)); 
     221        //OUT.illum_col.xyz = float3(ao.x, ao.x, ao.x); 
    226222        //OUT.illum_col.xyz = float3(0, clamp(1.0f - ao.y * 1e-3f, 0, 1), 1); 
    227223        //OUT.illum_col.xyz = float3(0, 1.0f - step(0.5f + NUM_SAMPLES, convergence), 1); 
     
    230226        return OUT; 
    231227} 
     228 
     229 
     230 
     231/** Function combining image and indirect illumination buffer using a  
     232        depth and normal aware discontinuity filter. 
     233*/ 
     234pixel SmoothSsao(fragment IN,  
     235                                 uniform sampler2D ssaoTex) 
     236{ 
     237        pixel OUT; 
     238 
     239        float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
     240 
     241        float4 dummy; 
     242        const float xoffs = .5f / 1024.0f; const float yoffs = .5f / 768.0f; 
     243 
     244        // get positions exactly between old texel centers 
     245        dummy.x = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(xoffs, 0), 0, 0)).y; 
     246        dummy.y = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(0, -yoffs), 0, 0)).y; 
     247        dummy.z = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(-xoffs, 0), 0, 0)).y; 
     248        dummy.w = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(0, yoffs), 0, 0)).y; 
     249 
     250        const float m1 = min(dummy.x, dummy.y); 
     251        const float m2 = min(dummy.z, dummy.w); 
     252 
     253        ao.y = min(ao.y, min(m1, m2)); 
     254 
     255        return OUT; 
     256} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r3197 r3198  
    203203inline float PixelValid(sampler2D oldTex, 
    204204                                                float4 color, 
    205                                                 float3 diffVec, 
     205                                                float3 difVec, 
    206206                                                float2 texCoord, 
    207207                                                float3 viewDir, 
     
    229229 
    230230        // compute position from old frame for dynamic objects + translational portion 
    231         const float3 translatedPos = diffVec - oldEyePos + worldPos.xyz; 
     231        const float3 translatedPos = difVec - oldEyePos + worldPos.xyz; 
    232232 
    233233 
     
    254254         
    255255        const float depthDif = abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth); 
    256         const float squaredLen = SqrLen(diffVec); 
     256        const float squaredLen = SqrLen(difVec); 
    257257         
    258258        // test if this pixel was not valid in the old frame 
     
    280280 
    281281 
    282 pixel PrepareSsao(fragment IN, 
     282float4 PrepareSsao(fragment IN, 
    283283                                   uniform sampler2D colorsTex, 
    284                                    uniform sampler2D normalsTex, 
    285284                                   uniform sampler2D diffVals, 
    286285                                   uniform sampler2D oldTex, 
     
    292291                                   uniform float3 oldtr, 
    293292                                   uniform float3 oldEyePos 
    294                                    ) 
     293                                   ): COLOR0 
    295294{    
    296         pixel pix; 
    297  
    298         const float3 difVec = tex2Dlod(diffVals, float4(IN.texCoord, 0 ,0)).xyz; 
    299  
    300         const float3 viewDir = IN.view; 
    301295        float4 color = tex2Dlod(colorsTex, float4(IN.texCoord, 0, 0)); 
    302  
    303          
    304         /*float4 dummy; 
    305         const float xoffs = .5f / 1024.0f; const float yoffs = .5f / 768.0f; 
    306         //const float xoffs = 1.0f / 1024.0f; const float yoffs = 1.0f / 768.0f; 
    307  
    308         dummy.x = tex2Dlod(colorsTex, float4(IN.texCoord + float2(xoffs, yoffs), 0, 0)).w; 
    309         dummy.y = tex2Dlod(colorsTex, float4(IN.texCoord + float2(xoffs, -yoffs), 0, 0)).w; 
    310         dummy.z = tex2Dlod(colorsTex, float4(IN.texCoord + float2(-xoffs, yoffs), 0, 0)).w; 
    311         dummy.w = tex2Dlod(colorsTex, float4(IN.texCoord + float2(-yoffs, -yoffs), 0, 0)).w; 
    312         color.w = min(min(dummy.x, dummy.y), min(dummy.z, dummy.w)); 
    313         //color.w = max(max(dummy.x, dummy.y), max(dummy.z, dummy.w)); 
    314         */ 
    315          
    316         //const float3 normal = normalize(tex2Dlod(normalsTex, float4(IN.texCoord, 0 ,0)).xyz); 
    317  
    318         float3 dummy[4]; 
    319         const float xoffs = .5f / 1024.0f; const float yoffs = .5f / 768.0f; 
    320         //const float xoffs = 1.0f / 1024.0f; const float yoffs = 1.0f / 768.0f; 
    321  
    322         dummy[0] = tex2Dlod(normalsTex, float4(IN.texCoord + float2(xoffs, yoffs), 0, 0)).xyz; 
    323         dummy[1] = tex2Dlod(normalsTex, float4(IN.texCoord + float2(xoffs, -yoffs), 0, 0)).xyz; 
    324         dummy[2] = tex2Dlod(normalsTex, float4(IN.texCoord + float2(-xoffs, yoffs), 0, 0)).xyz; 
    325         dummy[3] = tex2Dlod(normalsTex, float4(IN.texCoord + float2(-yoffs, -yoffs), 0, 0)).xyz; 
    326          
    327         float dot1 = dot(dummy[0], dummy[3]); 
    328         float dot2 = dot(dummy[1], dummy[2]); 
    329  
    330         float isEdge = step(.0f, dot1) * step(.0f, dot2); 
    331  
    332         const float3 normal = isEdge * normalize(dummy[0] + dummy[1] + dummy[2] + dummy[3]); 
    333  
    334296        // store scaled view vector so wie don't have to normalize for e.g., ssao 
    335297        color.w /= length(IN.view); 
     298 
     299        const float4 difVec = tex2Dlod(diffVals, float4(IN.texCoord, 0, 0)); 
    336300 
    337301        // do reprojection and filter out the pixels that are not save 
     
    340304                                                          difVec.xyz, 
    341305                                                          IN.texCoord, 
    342                                                           viewDir, 
     306                                                          IN.view, 
    343307                                                          oldEyePos, 
    344308                                                          modelViewProj, 
     
    347311                                                          ); 
    348312 
    349         pix.color = color; 
    350         pix.color.x = pValid; 
    351  
    352         pix.normal = normal; 
    353         pix.diffVal = difVec; 
    354  
    355         return pix; 
     313        color.x = pValid; 
     314 
     315        return color; 
    356316} 
    357317 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/normalMapping.cg

    r3195 r3198  
    127127        //const float3 tangentSpaceNorm = tex2Dlod(normalMap, float4(IN.texCoord.xy, 0, 0)).xyz * 2.0f - float3(1.0f); 
    128128        const float3 tangentSpaceNorm = tex2Dlod(normalMap, float4(IN.texCoord.xy, 0, 0)).xyz; 
    129         pix.normal = mul(tangToWorldTrafo, tangentSpaceNorm); 
    130         //pix.normal = tangentSpaceNorm; 
     129        //pix.normal = mul(tangToWorldTrafo, tangentSpaceNorm); 
     130        pix.normal = normalize(mul(tangToWorldTrafo, tangentSpaceNorm)); 
    131131         
    132132        return pix; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3197 r3198  
    292292                float3 dirSample = samplePos - centerPosition; 
    293293 
    294                 const float sqrLen = max(SqrLen(dirSample), 1e-3f); 
    295                 //const float lengthToSample = max(length(dirSample), 1e-2f); 
     294                const float sqrLen = max(SqrLen(dirSample), 1e-2f); 
    296295                const float lengthToSample = sqrt(sqrLen); 
    297296 
     
    395394 
    396395        // cull background note: this should be done with the stencil buffer 
     396        //if (SqrLen(diffVec < 1e6f) && (eyeSpaceDepth < 1e10f)) 
    397397        if (eyeSpaceDepth < 1e10f) 
    398398        { 
     
    402402        else 
    403403        { 
    404                  ao = float3(1.0f, .0f, .0f); 
     404                 ao = float3(1.0f, 1.0f, 1.0f); 
    405405        } 
    406406 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg

    r3149 r3198  
    9999        float logLum = logLumScaled * LOGLUM_RANGE + MINLOGLUM; 
    100100 
    101         float newImageKey = max(exp(logLum), 1e-6f); 
     101        float newImageKey = max(exp(logLum), 1e-3f); 
    102102 
    103103        // adjust to middle gray 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/treeanimation.cg

    r3168 r3198  
    103103        // hack: no translational component anyway 
    104104        OUT.oldWorldPos = oldOffs; 
     105        //OUT.oldWorldPos = float4(1e20f, 1e20f, 1e20f, oldOffs.w); 
    105106        OUT.worldPos = offs; 
    106107 
    107108        return OUT; 
    108109} 
     110 
     111/* 
     112 
     113pixel fragtex(fragin IN,  
     114                          uniform sampler2D tex: TEXUNIT0, 
     115                          uniform float4x4 viewMatrix 
     116                          ) 
     117{ 
     118        float4 texColor = tex2D(tex, IN.texCoord.xy); 
     119 
     120        // account for alpha blending 
     121        if (texColor.w < 0.5f) discard; 
     122 
     123        pixel pix; 
     124 
     125        // save color in first render target 
     126        // hack: use combination of emmisive + diffuse (emmisive used as constant ambient term) 
     127        pix.col = (glstate.material.emission + glstate.material.diffuse) * texColor;  
     128        // save world space normal in rt => transform back into world space by 
     129        // multiplying with inverse view. since transforming normal with T means to  
     130        // multiply with the inverse transpose of T, we multiple with  
     131        // Transp(Inv(Inv(view))) = Transp(view) 
     132        pix.norm = normalize(mul(transpose(viewMatrix), IN.normal).xyz); 
     133        //pix.norm = IN.normal.xyz; 
     134        // compute eye linear depth 
     135        pix.col.w = 1e20f;//length(IN.eyePos.xyz); 
     136 
     137        // the scene entity id 
     138        //pix.id = glstate.fog.color.xyz; 
     139        // the offset to the world pos from old frame 
     140        pix.offsVec = IN.oldWorldPos.xyz - IN.worldPos.xyz; 
     141 
     142        return pix; 
     143}*/ 
Note: See TracChangeset for help on using the changeset viewer.