Changeset 2867


Ignore:
Timestamp:
08/26/08 13:30:31 (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/default.env

    r2865 r2867  
    1111camPosition=483.398f 242.364f 186.078f 
    1212camDirection=1 0 0 
    13 useFullScreen=0 
    14 useLODs=0 
     13useFullScreen=1 
     14useLODs=1 
    1515#modelPath=data/city/model/ 
    1616 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredShader.cpp

    r2866 r2867  
    4242        mFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
    4343        // the diffuse color buffer 
    44         mFbo->AddColorBuffer(w, h, ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false, false); 
     44        mFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
    4545} 
    4646 
     
    112112        GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 
    113113 
     114        if (1) 
     115        { 
     116                glEnable(GL_TEXTURE_2D); 
     117                // generate mip map levels for position texture 
     118                glBindTexture(GL_TEXTURE_2D, colorsTex); 
     119                glGenerateMipmapEXT(GL_TEXTURE_2D); 
     120        } 
     121 
    114122        // read the second buffer, write to the first buffer 
    115123        mFbo->Bind(); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.cpp

    r2866 r2867  
    5050                                                                         FILTER_TYPE filterType,  
    5151                                                                         bool useMipMap,  
    52                                                                          bool useMultiSampling, 
    5352                                                                         int attachment_idx) 
    5453{ 
     
    8180        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, color_attachment[attachment_idx], GL_TEXTURE_2D, mTexId, 0); 
    8281 
    83         GLuint filterParam; 
     82        GLuint minfilterParam; 
     83        GLuint magfilterParam; 
    8484 
    8585        switch (filterType) 
    8686        { 
    8787        case FILTER_NEAREST: 
    88                 filterParam = GL_NEAREST; break; 
     88                minfilterParam = GL_NEAREST; 
     89                magfilterParam = GL_NEAREST; break; 
    8990        case FILTER_LINEAR: 
    90                 filterParam = GL_LINEAR; break; 
     91                minfilterParam = GL_LINEAR; 
     92                magfilterParam = GL_LINEAR; break; 
    9193        case FILTER_MIPMAP_LINEAR:  
    92                 filterParam = GL_LINEAR_MIPMAP_LINEAR; break; 
     94                //minfilterParam = GL_LINEAR_MIPMAP_LINEAR; 
     95                minfilterParam = GL_NEAREST_MIPMAP_NEAREST; 
     96                //minfilterParam = GL_NEAREST_MIPMAP_LINEAR; 
     97                magfilterParam = GL_NEAREST; break; 
    9398        default: 
    94                 filterParam = GL_NEAREST; 
     99                minfilterParam = GL_NEAREST; 
     100                magfilterParam = GL_NEAREST; 
     101 
    95102                cerr << "should not come here" << endl; 
    96103        } 
     
    107114        } 
    108115 
    109         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filterParam); 
    110         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filterParam); 
     116        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magfilterParam); 
     117        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minfilterParam); 
    111118 
    112119        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapParam); 
    113120        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapParam); 
     121 
     122        if (useMipMap) glGenerateMipmapEXT(GL_TEXTURE_2D); 
    114123 
    115124        // print status 
     
    178187 
    179188 
    180 int FrameBufferObject::AddColorBuffer(int w, int h, 
    181                                                                           ColorBufferObject::FORMAT col,  
     189int FrameBufferObject::AddColorBuffer(ColorBufferObject::FORMAT col,  
    182190                                                                          ColorBufferObject::WRAP_TYPE wrapType,  
    183191                                                                          ColorBufferObject::FILTER_TYPE filterType,  
    184                                                                           bool useMipMap,  
    185                                                                           bool useMultiSampling) 
     192                                                                          bool useMipMap) 
    186193{ 
    187194        cout << "adding color buffer" << endl; 
     
    189196        Bind(); 
    190197 
    191         int idx = (int)mColorBuffers.size(); 
     198        const int idx = (int)mColorBuffers.size(); 
     199 
    192200        ColorBufferObject *colorBuf =  
    193                 new ColorBufferObject(w, h, col, wrapType, filterType, useMipMap, useMultiSampling, idx); 
     201                new ColorBufferObject(mWidth, mHeight, col, wrapType, filterType, useMipMap, idx); 
    194202 
    195203        mColorBuffers.push_back(colorBuf); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.h

    r2866 r2867  
    2525                                          FILTER_TYPE filterType,  
    2626                                          bool useMipMap,  
    27                                           bool useMultiSampling, 
    2827                                          int attachment_idx); 
    2928 
     
    5150                Returns the index that allows to retrieve the color buffer object. 
    5251        */ 
    53         int AddColorBuffer(int w, int h, 
    54                                    ColorBufferObject::FORMAT col,  
     52        int AddColorBuffer(ColorBufferObject::FORMAT col,  
    5553                               ColorBufferObject::WRAP_TYPE wrapType,  
    5654                                           ColorBufferObject::FILTER_TYPE filterType,  
    57                                            bool useMipMap,  
    58                                            bool useMultiSampling); 
     55                                           bool useMipMap); 
    5956 
    6057        /** Returns the color buffer object on position i. 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.cpp

    r2847 r2867  
    2626void Shape::Render(RenderState *state) 
    2727{ 
    28         if (mMaterial) mMaterial->Render(state); 
     28        if (mMaterial)  
     29                mMaterial->Render(state); 
    2930 
    3031        mParent->GetTransform()->Load(state); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.cpp

    r2866 r2867  
    6464 
    6565 
    66 SsaoShader::SsaoShader(int w, int h,  
    67                                            Camera *cam, 
    68                                            float scaleFactor 
    69                                            ): 
     66SsaoShader::SsaoShader(int w, int h, Camera *cam, float scaleFactor): 
    7067mWidth(w), mHeight(h),  
    7168mCamera(cam), 
     
    7875        mNewFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
    7976        // the diffuse color buffer 
    80         mNewFbo->AddColorBuffer(w, h, ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false, false); 
     77        mNewFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
    8178         
    8279        mOldFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
    8380        // the diffuse color buffer 
    84         mOldFbo->AddColorBuffer(w, h, ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false, false); 
     81        mOldFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
    8582         
    8683 
     
    167164        cgGLSetMatrixParameterfc(sOldModelViewProjMatrixParam, (const float *)oldProjViewMatrix.x); 
    168165 
     166        glPushAttrib(GL_VIEWPORT_BIT); 
     167        glViewport(0, 0, mWidth, mHeight); 
     168 
     169        glDrawBuffers(1, mymrt); 
     170 
     171        cgGLEnableProfile(RenderState::sCgFragmentProfile); 
     172 
     173        glDisable(GL_ALPHA_TEST); 
     174        glDisable(GL_TEXTURE_2D); 
     175        glDisable(GL_LIGHTING); 
     176 
     177        glMatrixMode(GL_PROJECTION); 
     178        glPushMatrix(); 
     179        glLoadIdentity(); 
     180 
     181        glMatrixMode(GL_MODELVIEW); 
     182        glPushMatrix(); 
     183        glLoadIdentity(); 
     184 
     185        const float offs = 0.5f; 
     186        glOrtho(-offs, offs, -offs, offs, 0, 1); 
     187 
    169188        // switch roles of old and new fbo 
    170189        // the algorihm uses two input fbos, where the one 
     
    177196        //DisplayTexture(); 
    178197        AntiAliasing(fbo); 
     198 
     199        glEnable(GL_LIGHTING); 
     200        glDisable(GL_TEXTURE_2D); 
     201 
     202        glMatrixMode(GL_PROJECTION); 
     203        glPopMatrix(); 
     204 
     205        glMatrixMode(GL_MODELVIEW); 
     206        glPopMatrix(); 
     207 
     208        glPopAttrib(); 
     209 
     210        cgGLDisableProfile(RenderState::sCgFragmentProfile); 
    179211} 
    180212 
     
    186218        GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 
    187219 
     220        if (1) 
     221        { 
     222                // generate mip map levels for position texture 
     223                glBindTexture(GL_TEXTURE_2D, positionsTex); 
     224                glGenerateMipmapEXT(GL_TEXTURE_2D); 
     225        } 
     226 
     227 
    188228        // read the second buffer, write to the first buffer 
    189229        mNewFbo->Bind(); 
    190230        GLuint oldTex = mOldFbo->GetColorBuffer(0)->GetTexture(); 
    191231 
    192         glPushAttrib(GL_VIEWPORT_BIT); 
    193         glViewport(0, 0, mWidth, mHeight); 
    194  
    195232        glDrawBuffers(1, mymrt); 
    196233 
    197         glDisable(GL_ALPHA_TEST); 
    198         glDisable(GL_TEXTURE_2D); 
    199         glDisable(GL_LIGHTING); 
    200  
    201         glMatrixMode(GL_PROJECTION); 
    202         glPushMatrix(); 
    203         glLoadIdentity(); 
    204  
    205         glMatrixMode(GL_MODELVIEW); 
    206         glPushMatrix(); 
    207         glLoadIdentity(); 
    208  
    209         const float offs = 0.5f; 
    210  
    211         glOrtho(-offs, offs, -offs, offs, 0, 1); 
    212  
    213234        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    214  
    215         cgGLEnableProfile(RenderState::sCgFragmentProfile); 
    216235 
    217236        cgGLBindProgram(sCgSsaoProgram); 
     
    265284        cgGLDisableTextureParameter(sOldTexParam); 
    266285 
    267         cgGLDisableProfile(RenderState::sCgFragmentProfile); 
    268  
    269         glEnable(GL_LIGHTING); 
    270         glDisable(GL_TEXTURE_2D); 
    271  
    272         glMatrixMode(GL_PROJECTION); 
    273         glPopMatrix(); 
    274  
    275         glMatrixMode(GL_MODELVIEW); 
    276         glPopMatrix(); 
    277  
    278         glPopAttrib(); 
    279  
    280286        FrameBufferObject::Release(); 
    281287 
     
    316322void SsaoShader::CreateNoiseTex2D() 
    317323{ 
    318         GLubyte *randomNormals = new GLubyte[mWidth * mHeight * 3]; 
     324        //GLubyte *randomNormals = new GLubyte[mWidth * mHeight * 3]; 
     325        float *randomNormals = new float[mWidth * mHeight * 3]; 
    319326 
    320327        for (int i = 0; i < mWidth * mHeight * 3; i += 3) 
     
    324331                const float theta = 2.0f * acos(sqrt(1.0f - rx)); 
    325332 
    326                 randomNormals[i + 0] = (GLubyte)((cos(theta) * 0.5f + 0.5f) * 255.0f); 
    327                 randomNormals[i + 1] = (GLubyte)((sin(theta) * 0.5f + 0.5f) * 255.0f); 
     333                //randomNormals[i + 0] = (GLubyte)((cos(theta) * 0.5f + 0.5f) * 255.0f); 
     334                //randomNormals[i + 1] = (GLubyte)((sin(theta) * 0.5f + 0.5f) * 255.0f); 
     335                randomNormals[i + 0] = cos(theta); 
     336                randomNormals[i + 1] = sin(theta); 
    328337                randomNormals[i + 2] = 0; 
    329338        } 
     
    338347        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 
    339348 
    340         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, mWidth, mHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, randomNormals); 
     349        //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, mWidth, mHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, randomNormals); 
     350        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, mWidth, mHeight, 0, GL_RGB, GL_FLOAT, randomNormals); 
    341351 
    342352        glBindTexture(GL_TEXTURE_2D, 0); 
     
    371381        GLuint colorsTex = mNewFbo->GetColorBuffer(0)->GetTexture(); 
    372382        GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 
    373  
    374         glPushAttrib(GL_VIEWPORT_BIT); 
    375         glViewport(0, 0, mWidth, mHeight); 
    376  
    377         glDisable(GL_ALPHA_TEST); 
    378         glDisable(GL_TEXTURE_2D); 
    379         glDisable(GL_LIGHTING); 
    380          
    381         glMatrixMode(GL_PROJECTION); 
    382         glPushMatrix(); 
    383         glLoadIdentity(); 
    384  
    385         glMatrixMode(GL_MODELVIEW); 
    386         glPushMatrix(); 
    387         glLoadIdentity(); 
    388  
    389         const float offs = 0.5f; 
    390          
    391         glOrtho(-offs, offs, -offs, offs, 0, 1); 
     383         
    392384        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    393385 
     
    422414        cgGLDisableTextureParameter(sNormalsTexAntiAliasingParam); 
    423415 
    424         cgGLDisableProfile(RenderState::sCgFragmentProfile); 
    425          
    426         glEnable(GL_LIGHTING); 
    427         glDisable(GL_TEXTURE_2D); 
    428          
    429         glMatrixMode(GL_PROJECTION); 
    430         glPopMatrix(); 
    431  
    432         glMatrixMode(GL_MODELVIEW); 
    433         glPopMatrix(); 
    434  
    435         glPopAttrib(); 
    436  
    437         PrintGLerror("deferred shading"); 
     416        PrintGLerror("antialiasing"); 
    438417} 
    439418 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2866 r2867  
    303303                //env.GetIntParam(string("numSssaoSamples"), numSsaoSamples); 
    304304 
     305 
    305306                cout << "*********** parameters ***************" << endl; 
     307 
    306308                cout << "assumedVisibleFrames: " << assumedVisibleFrames << endl;  
    307309                cout << "maxBatchSize: " << maxBatchSize << endl; 
     
    338340        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_MULTISAMPLE); 
    339341        //glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); 
    340  
    341342        //glutInitDisplayString("samples=2"); 
     343 
     344        SceneEntity::SetUseLODs(useLODs); 
     345 
    342346 
    343347        if (!useFullScreen) 
     
    531535        // this fbo basicly stores the scene information we get from standard rendering of a frame 
    532536        // we store colors, normals, positions (for the ssao) 
    533         fbo = new FrameBufferObject(texWidth, texHeight, FrameBufferObject::DEPTH_24); 
     537        fbo = new FrameBufferObject(texWidth, texHeight, FrameBufferObject::DEPTH_32); 
    534538 
    535539        // the diffuse color buffer 
    536         fbo->AddColorBuffer(texWidth, texHeight, ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false, false); 
     540        fbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, false); 
    537541        // the positions buffer 
    538         fbo->AddColorBuffer(512, 512, ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, false, false); 
     542        fbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_MIPMAP_LINEAR, true); 
     543        //fbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, true); 
    539544        // the normals buffer 
    540         //fbo->AddColorBuffer(ColorBufferObject::BUFFER_UBYTE, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, false, false); 
    541         fbo->AddColorBuffer(texWidth, texHeight, ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, false, false); 
     545        //fbo->AddColorBuffer(ColorBufferObject::BUFFER_UBYTE, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, false); 
     546        fbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, false); 
    542547 
    543548        PrintGLerror("fbo"); 
     
    10351040                break; 
    10361041        case '+': 
    1037                 maxBatchSize += 10; 
     1042                if (maxBatchSize < 10) 
     1043                        maxBatchSize = 10; 
     1044                else 
     1045                        maxBatchSize += 10; 
     1046 
    10381047                traverser->SetMaxBatchSize(maxBatchSize); 
    10391048                break; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/antialiasing.cg

    r2866 r2867  
    1010}; 
    1111 
    12 //uniform sampler2D s_distort; 
    13 uniform float4 e_barrier = float4(5e-5, 5e-5, 0, 0); 
     12// the barrier for detecting a discontinuity 
     13uniform float4 e_barrier = float4(5e-3, 5e-3, 0, 0); // x = normal, y = depth 
     14// the weights for normal / depth discontinuity 
    1415uniform float4 e_weights = float4(1.0f, 1.0f, 1.0f, 1.0f); // x = normal, y = depth 
    15 uniform float4 e_kernel = float4(0.3f, 1.0f, 1.0f, 1.0f); // x = normal, y = depth 
     16uniform float4 e_kernel = float4(0.35f, 1.0f, 1.0f, 1.0f);  
    1617 
    1718 
     
    2122                        ): COLOR 
    2223{ 
     24        //return tex2D(colors, IN.c.xy); 
    2325        // normal discontinuity filter 
    2426        float3 nc = (float3)tex2D(normals, IN.c.xy); 
     
    8183 
    8284        return (s0 + s1 + s2 + s3) / 4.0f; 
    83         //return float4(w); 
    8485} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r2866 r2867  
    77 
    88// rule of thumb: approx 1 / NUM_SAMPLES 
    9 #define SAMPLE_INTENSITY 0.17 
     9#define SAMPLE_INTENSITY 0.15 
    1010//#define SAMPLE_INTENSITY 0.125f 
    1111 
     
    3737  float2 rpt = pt - d * 2.0f * n; 
    3838 
    39   //return pt; 
    4039  return rpt; 
    4140} 
     
    8079 
    8180                //sample noisetex; r stores costheta, g stores sintheta 
    82                 float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f; 
     81                //float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f; 
     82                float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy; 
    8383 
    8484                // rotation 
    8585                //float2 offsetTransformed = offset; 
    86                 float2 offsetTransformed = rotate(offset, mynoise); 
    87                 //float2 offsetTransformed = reflect(offset, noise); 
     86                //float2 offsetTransformed = rotate(offset, mynoise); 
     87                float2 offsetTransformed = reflect(offset, mynoise); 
    8888 
    8989                // weight with projected coordinate to reach similar kernel size for near and far 
    9090                float2 texcoord = IN.texCoord.xy + offsetTransformed * AREA_SIZE * w; 
    9191 
    92                 float3 sample_position = tex2D(positions, texcoord).xyz; 
     92                // sample downsampled texture in order to speed up texture accesses 
     93                float3 sample_position = tex2Dlod(positions, float4(texcoord, 0, 1)).xyz; 
     94                //float3 sample_position = tex2D(positions, texcoord).xyz; 
    9395 
    9496                float3 vector_to_sample = sample_position - centerPosition.xyz; 
     
    112114 
    113115        return (1.0f - total_ao); 
    114         //return float4(dot(currentViewDir, currentNormal)); 
     116        //return dot(currentViewDir, currentNormal); 
    115117} 
    116118 
     
    180182 
    181183 
     184/** function for standard deferred shading 
     185*/ 
    182186float4 shade(fragment IN,  
    183187                         uniform sampler2D colors, 
     
    199203        float3 light2 = normalize(lightDir2.xyz); 
    200204 
    201         float diffuseLight = max(dot(normal, light), 0.0f); 
    202         float diffuseLight2 = max(dot(normal, light2), 0.0f); 
     205        float diffuseLight = saturate(dot(normal, light)); 
     206        float diffuseLight2 = saturate(dot(normal, light2)); 
    203207 
    204208        float diffuse = diffuseLight + diffuseLight2; 
    205         //float diffuse = diffuseLight; 
    206209 
    207210        return (ambient + diffuse) * color * (1.0f - amb) + amb * color; 
     
    227230 
    228231        float4 normal = tex2D(normals, IN.texCoord.xy); 
     232         
     233        // the ambient term 
    229234        float amb = normal.w; 
    230235 
    231236        // expand normal 
    232         normal = normalize(normal * 2.0f - 1.0f); 
     237        normal = normalize(normal);// * 2.0f - 1.0f); 
    233238        /// the current view direction 
    234239        float3 viewDir = normalize(IN.view * 2.0f - float3(1.0f)); 
     
    263268        if ((tex.x >= 0.0f) && (tex.x < 1.0f) &&  
    264269                (tex.y >= 0.0f) && (tex.y < 1.0f) &&  
    265                 (abs(depthDif)  < 8e-5f)) 
     270                (abs(depthDif)  < 1e-4f)) 
    266271        { 
    267272                OUT.color = attenuated_color * expFactor + col1 * float4(1.0f - expFactor); 
     
    292297 
    293298        float4 normal = tex2D(normals, IN.texCoord.xy); 
     299 
     300        // an ambient color term 
    294301        float amb = normal.w; 
    295302 
    296303        // expand normal 
    297         normal = normalize(normal * 2.0f - float4(1.0f)); 
     304        normal = normalize(normal);// * 2.0f - float4(1.0f)); 
    298305 
    299306        float4 col = shade(IN, colors, positions, normal.xyz, amb); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r2866 r2867  
    7777        // save color in first render target 
    7878        pix.col = (ambient + diffuse) * tex2D(tex, IN.texCoord.xy); 
     79         
    7980        // save world position in second rt 
    8081        pix.pos = IN.worldPos * maxDepth; 
    8182        // save normal in third rt 
    82         pix.norm.xyz = IN.normal * 0.5f + 0.5f; 
     83        //pix.norm.xyz = IN.normal * 0.5f + 0.5f; 
     84        pix.norm.xyz = IN.normal; 
    8385 
    8486        // hack: squeeze some information about ambient into the texture 
     
    107109        pix.col = diffuse; 
    108110        pix.pos = IN.worldPos * maxDepth; 
    109         pix.norm.xyz = IN.normal * 0.5f + float3(0.5f); 
    110         // hack: squeeze some information about ambient into the texture 
     111        //pix.norm.xyz = IN.normal * 0.5f + float3(0.5f); 
     112        pix.norm.xyz = IN.normal; 
     113        // hack: squeeze some information about the ambient term into the target 
    111114        pix.norm.w = ambient.x; 
    112115        pix.pos.w = IN.mypos.w; 
Note: See TracChangeset for help on using the changeset viewer.