Changeset 2891 for GTP


Ignore:
Timestamp:
09/01/08 08:58:38 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
4 added
11 edited

Legend:

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

    r2890 r2891  
    175175        float z_far = mFar; 
    176176 
    177         float fov = 120 * M_PI / 180.0f;//mFovy; 
     177        float fov = mFovy; 
    178178 
    179179        const float w_near = 2.0f * tan(fov * 0.5f) * z_near; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.cpp

    r2890 r2891  
    193193mUseTemporalCoherence(true), 
    194194mUseGlobIllum(false), 
    195 mSampling(POISSON) 
     195mSampling(POISSON), 
     196mFboIndex(0) 
    196197{ 
    197198        // create noise texture for ssao 
     
    201202        //-- the flip-flop fbos 
    202203 
    203         mNewFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
     204        /*mNewFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
    204205         
    205206        mNewFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
     
    212213         
    213214        mOldFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
    214         mOldFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
    215          
    216         //mFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
    217         //mFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false);*/ 
     215        mOldFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false);*/ 
     216         
     217        mFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
     218 
     219        mFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
     220        mFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
     221        mFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
     222        mFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
    218223} 
    219224 
     
    227232        if (sCgAntiAliasingProgram) cgDestroyProgram(sCgAntiAliasingProgram); 
    228233 
    229         DEL_PTR(mNewFbo); 
    230         DEL_PTR(mOldFbo); 
    231         //DEL_PTR(mFbo); 
     234        //DEL_PTR(mNewFbo); 
     235        //DEL_PTR(mOldFbo); 
     236        DEL_PTR(mFbo); 
    232237 
    233238        glDeleteTextures(1, &noiseTex); 
     
    418423        // contais the color buffer from the last frame,  
    419424        // the other one will be written 
    420         swap(mNewFbo, mOldFbo);  
    421  
     425        //swap(mNewFbo, mOldFbo);        
     426        mFboIndex = 2 - mFboIndex; 
    422427        FrameBufferObject::Release(); 
    423428 
     
    492497 
    493498        // read the second buffer, write to the first buffer 
    494         mNewFbo->Bind(); 
    495         glDrawBuffers(1, mymrt); 
    496  
    497  
    498         GLuint oldTex = mOldFbo->GetColorBuffer(0)->GetTexture(); 
     499        //mNewFbo->Bind(); 
     500        mFbo->Bind(); 
     501        glDrawBuffers(1, mymrt + mFboIndex); 
     502 
     503 
     504        //GLuint oldTex = mOldFbo->GetColorBuffer(0)->GetTexture(); 
     505        GLuint oldTex = mFbo->GetColorBuffer(2 - mFboIndex)->GetTexture(); 
    499506 
    500507        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     
    545552        //const float new_offs = 0.55f; 
    546553        const float new_offs = 0.5f; 
    547         /* 
    548         glTexCoord2f(0, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, tl.x, tl.y, tl.z); glVertex3f(-new_offs, -new_offs, -0.5f); 
    549         glTexCoord2f(1, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, tr.x, tr.y, tr.z); glVertex3f( new_offs, -new_offs, -0.5f); 
    550         glTexCoord2f(1, 1); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, br.x, br.y, br.z); glVertex3f( new_offs,  new_offs, -0.5f); 
    551         glTexCoord2f(0, 1); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, bl.x, bl.y, bl.z); glVertex3f(-new_offs,  new_offs, -0.5f); 
    552 */ 
     554         
    553555        glTexCoord2f(0, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, bl.x, bl.y, bl.z); glVertex3f(-new_offs, -new_offs, -0.5f); 
    554556        glTexCoord2f(1, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, br.x, br.y, br.z); glVertex3f( new_offs, -new_offs, -0.5f); 
     
    715717 
    716718        // read the second buffer, write to the first buffer 
    717         mNewFbo->Bind(); 
    718         glDrawBuffers(2, mymrt); 
    719  
    720         GLuint oldSsaoTex = mOldFbo->GetColorBuffer(0)->GetTexture(); 
    721         GLuint oldIllumTex = mOldFbo->GetColorBuffer(1)->GetTexture(); 
     719        //mNewFbo->Bind(); 
     720        mFbo->Bind(); 
     721 
     722        glDrawBuffers(2, mymrt + mFboIndex); 
     723 
     724        //GLuint oldSsaoTex = mOldFbo->GetColorBuffer(0)->GetTexture(); 
     725        //GLuint oldIllumTex = mOldFbo->GetColorBuffer(1)->GetTexture(); 
     726         
     727        GLuint oldSsaoTex = mFbo->GetColorBuffer(2 - mFboIndex)->GetTexture(); 
     728        GLuint oldIllumTex = mFbo->GetColorBuffer(2 - mFboIndex + 1)->GetTexture(); 
    722729 
    723730        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     
    766773        ComputeViewVectors(tl, tr, bl, br); 
    767774 
    768         glColor3f(1.0f, 1.0f, 1.0f); 
    769  
    770775        glBegin(GL_QUADS); 
    771776 
     
    773778        //const float new_offs = 0.55f; 
    774779        const float new_offs = 0.5f; 
    775          
    776         glColor3f(bl.x, bl.y, bl.z); glTexCoord2f(0, 0); glVertex3f(-new_offs, -new_offs, -0.5f); 
    777         glColor3f(br.x, br.y, br.z); glTexCoord2f(1, 0); glVertex3f( new_offs, -new_offs, -0.5f); 
    778         glColor3f(tr.x, tr.y, tr.z); glTexCoord2f(1, 1); glVertex3f( new_offs,  new_offs, -0.5f); 
    779         glColor3f(tl.x, tl.y, tl.z); glTexCoord2f(0, 1); glVertex3f(-new_offs,  new_offs, -0.5f); 
     780                 
     781        glTexCoord2f(0, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, bl.x, bl.y, bl.z); glVertex3f(-new_offs, -new_offs, -0.5f); 
     782        glTexCoord2f(1, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, br.x, br.y, br.z); glVertex3f( new_offs, -new_offs, -0.5f); 
     783        glTexCoord2f(1, 1); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, tr.x, tr.y, tr.z); glVertex3f( new_offs,  new_offs, -0.5f); 
     784        glTexCoord2f(0, 1); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, tl.x, tl.y, tl.z); glVertex3f(-new_offs,  new_offs, -0.5f); 
    780785 
    781786        glEnd(); 
     
    798803        GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); 
    799804 
    800         GLuint ssaoTex = mNewFbo->GetColorBuffer(0)->GetTexture(); 
    801         GLuint illumTex = mNewFbo->GetColorBuffer(1)->GetTexture(); 
     805        //GLuint ssaoTex = mNewFbo->GetColorBuffer(0)->GetTexture(); 
     806        //GLuint illumTex = mNewFbo->GetColorBuffer(1)->GetTexture(); 
     807        GLuint ssaoTex = mFbo->GetColorBuffer(mFboIndex)->GetTexture(); 
     808        GLuint illumTex = mFbo->GetColorBuffer(mFboIndex + 1)->GetTexture(); 
     809 
    802810 
    803811        fbo->Bind(); 
     
    850858{ 
    851859        GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); 
    852         GLuint ssaoTex = mNewFbo->GetColorBuffer(0)->GetTexture(); 
     860        //GLuint ssaoTex = mNewFbo->GetColorBuffer(0)->GetTexture(); 
     861        GLuint ssaoTex = mFbo->GetColorBuffer(mFboIndex)->GetTexture(); 
    853862 
    854863        fbo->Bind(); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.h

    r2889 r2891  
    8080        Camera *mCamera; 
    8181 
    82         FrameBufferObject *mOldFbo; 
    83         FrameBufferObject *mNewFbo; 
    84         //FrameBufferObject *mFbo; 
     82        //FrameBufferObject *mOldFbo; 
     83        //FrameBufferObject *mNewFbo; 
     84        FrameBufferObject *mFbo; 
    8585 
    8686        bool mUseGlobIllum; 
     
    8888 
    8989        int mSampling; 
     90        int mFboIndex; 
    9091}; 
    9192 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.cpp

    r2889 r2891  
    151151 
    152152        RenderFrustum(); 
     153 
     154        Vector3 pos = mCamera->GetPosition(); 
     155 
     156        // coordinates 
     157        glColor3f(0.0f, 1.0f, 0.0f); 
     158        glBegin(GL_LINES); 
     159        glVertex3d(pos.x, pos.y, pos.z); 
     160        glVertex3d(pos.x + 100, pos.y, pos.z); 
     161        glEnd(); 
     162 
     163        glColor3f(0.0f, 0.0f, 1.0f); 
     164        glBegin(GL_LINES); 
     165        glVertex3d(pos.x, pos.y, pos.z); 
     166        glVertex3d(pos.x, pos.y + 100, pos.z); 
     167        glEnd(); 
     168 
    153169        //RenderBoxForViz(mBvh->GetBox()); 
    154170         
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2889 r2891  
    550550 
    551551        // the diffuse color buffer 
    552         fbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_MIPMAP_LINEAR, true); 
    553         //fbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, false); 
     552        //fbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_MIPMAP_LINEAR, true); 
     553        fbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, false); 
    554554 
    555555        // the positions buffer 
     
    15441544        visualization->Render(); 
    15451545 
    1546         // coordinates 
    1547         glColor3f(0.0f, 1.0f, 0.0f); 
    1548         glBegin(GL_LINES); 
    1549         glVertex3d(pos.x, pos.y, pos.z); 
    1550         glVertex3d(pos.x + 100, pos.y, pos.z); 
    1551         glEnd(); 
    1552  
    1553         glColor3f(0.0f, 0.0f, 1.0f); 
    1554         glBegin(GL_LINES); 
    1555         glVertex3d(pos.x, pos.y, pos.z); 
    1556         glVertex3d(pos.x, pos.y + 100, pos.z); 
    1557         glEnd(); 
     1546         
    15581547         
    15591548        // reset previous settings 
     
    15641553        glMatrixMode(GL_MODELVIEW); 
    15651554        glPopMatrix(); 
    1566  
    1567         Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr; 
    1568  
    1569         camera->ComputePoints(ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr); 
    1570  
    1571         Vector3 bl, br, tl, tr; 
    1572  
    1573         bl = Normalize(nbl - fbl) * 100; 
    1574         br = Normalize(nbr - fbr) * 100; 
    1575         tl = Normalize(ntl - ftl) * 100; 
    1576         tr = Normalize(ntr - ftr) * 100; 
    1577  
    1578         Vector3 dum = pos + camera->GetDirection() * 20; 
    1579  
    1580         // coordinates 
    1581         glColor3f(0.0f, 1.0f, 0.0f); 
    1582  
    1583         glBegin(GL_LINES); 
    1584         glVertex3d(dum.x, dum.y, dum.z); 
    1585         glVertex3d(dum.x + bl.x, dum.y + bl.y, dum.z + bl.z); 
    1586         glEnd(); 
    1587  
    1588 /*      glColor3f(1.0f, 0.0f, 0.0f); 
    1589  
    1590         glBegin(GL_LINES); 
    1591         glVertex3d(dum.x, dum.y, dum.z); 
    1592         glVertex3d(dum.x + br.x, dum.y + br.y, dum.z + br.z); 
    1593         glEnd(); 
    1594  
    1595 */      glColor3f(0.0f, 0.0f, 1.0f); 
    1596  
    1597         glBegin(GL_LINES); 
    1598         glVertex3d(dum.x, dum.y, dum.z); 
    1599         glVertex3d(dum.x + tl.x, dum.y + tl.y, dum.z + tl.z); 
    1600         glEnd(); 
    1601 /* 
    1602         glColor3f(1.0f, 0.0f, 1.0f); 
    1603  
    1604         glBegin(GL_LINES); 
    1605         glVertex3d(dum.x, dum.y, dum.z); 
    1606         glVertex3d(dum.x + tr.x, dum.y + tr.y, dum.z + tr.z); 
    1607         glEnd();*/ 
    16081555} 
    16091556 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r2887 r2891  
    22#define __SHADERENV_H 
    33 
    4 //#define NUM_SAMPLES 8 
    5 #define NUM_SAMPLES 16 
     4#define NUM_SAMPLES 8 
     5//#define NUM_SAMPLES 16 
    66 
    77// rule of thumb: approx 1 / NUM_SAMPLES 
    8 #define SAMPLE_INTENSITY 0.14f 
    9 //#define SAMPLE_INTENSITY 0.28f 
     8//#define SAMPLE_INTENSITY 0.14f 
     9#define SAMPLE_INTENSITY 0.28f 
    1010 
    1111#define AREA_SIZE 5e-1f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/antialiasing.cg

    r2887 r2891  
    1313uniform 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 
    16 uniform float4 e_weights = float4(1.0f, 1.0f, 1.0f, 1.0f); // x = normal, y = depth 
    17 uniform float4 e_kernel = float4(0.35f, 1.0f, 1.0f, 1.0f);  
     15uniform float4 e_weights = float4(0.5f, 0.5f, 1.0f, 1.0f); // x = normal, y = depth 
     16//uniform float4 e_weights = float4(1.0f, 1.0f, 1.0f, 1.0f); // x = normal, y = depth 
     17uniform float4 e_kernel = float4(0.5f, 1.0f, 1.0f, 1.0f);  
    1818 
    1919 
     
    3434        nd.w = dot(nc, float3(tex2D(normals, IN.lb.xy))); 
    3535 
    36         nd.x -= e_barrier.x; 
     36        nd -= e_barrier.x; 
    3737        nd = step((float4)0.0f, nd); 
    3838 
     
    8484        float4 s3 = tex2Dlod(colors, float4(offset + IN.lb.xy * w, 0, 0)); 
    8585 
    86         //float4 sx = tex2D(colors, IN.c.xy); 
     86        float4 sc = tex2Dlod(colors, float4(IN.c.xy, 0, 0)); 
    8787 
    88         return (s0 + s1 + s2 + s3) * 0.25f; 
     88        return (s0 + s1 + s2 + s3 + sc) * 0.2f; 
     89        //return (s0 + s1 + s2 + s3) * 0.25f; 
    8990        //return float4(w); 
    9091} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg

    r2887 r2891  
    2929 
    3030 
    31 float2 reflect(float2 pt, float2 n) 
     31float2 myreflect(float2 pt, float2 n) 
    3232{ 
    3333        // distance to plane 
     
    6767        for (int i = 0; i < NUM_SAMPLES; i ++)  
    6868        { 
    69                 float2 offset = samples[i]; 
     69                //float2 offset = samples[i]; 
     70                float3 offset = float3(samples[i], 0); 
    7071 
    7172                //sample noisetex; r stores costheta, g stores sintheta 
    72                 //float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f; 
    73                 float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy; 
     73                //float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy; 
     74                float3 mynoise = float3(tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy, 0); 
    7475 
    7576                // rotation 
     
    133134        // expand normal 
    134135        float3 normal = normalize(norm.xyz); 
     136 
    135137        /// the current view direction 
    136         float3 viewDir = normalize(IN.view * 2.0f - float3(1.0f)); 
     138        float3 viewDir;// = normalize(IN.view); 
    137139 
    138140        // the current world position 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r2873 r2891  
    2424struct fragin 
    2525{ 
    26   float4 position: POSITION; // eye space 
    27   float4 texCoord: TEXCOORD0;     
     26        float4 color: COLOR0;   
     27        float4 position: POSITION; // eye space 
     28        float4 texCoord: TEXCOORD0;     
    2829 
    29   float4 projPos: WPOS; 
    30   float4 color: COLOR0;   
    31   float4 worldPos: TEXCOORD1; // world position 
    32   float3 normal: TEXCOORD2; 
     30        float4 projPos: WPOS; 
     31        float4 worldPos: TEXCOORD1; // world position 
    3332 
    34   float4 mypos: TEXCOORD3; 
    35   //float DEPTH; 
     33        float3 normal: TEXCOORD2; 
     34 
     35        float4 mypos: TEXCOORD3; 
     36        //float DEPTH; 
    3637}; 
    3738 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/shadow.cg

    r2882 r2891  
    1 //---------------------------------------------------------------------------------- 
    2 // File:   shadow_single_fragment.glsl 
    3 // Author: Rouslan Dimitrov 
    4 // Email:  sdkfeedback@nvidia.com 
    5 // Cascaded shadows maps, single shadow sample 
    6 // Copyright (c) NVIDIA Corporation. All rights reserved. 
    7 //---------------------------------------------------------------------------------- 
    8 #version 120 
    9 #extension GL_EXT_texture_array : enable 
     1struct appdata { 
     2        float3 Position : POSITION; 
     3        float3 Normal : NORMAL; 
     4}; 
    105 
    11 uniform sampler2D tex; 
    12 uniform vec4 far_d; 
    136 
    14 varying vec4 vPos; 
     7struct vpconn { 
     8        float4 Hposition : POSITION; 
     9        float4 TexCoord0 : TEXCOORD0; 
     10        float4 TexCoord1 : TEXCOORD1; 
     11        float4 Color0 : COLOR0; 
     12}; 
    1513 
    16 uniform sampler2DArray stex; 
    17 float shadowCoef() 
     14 
     15vpconn main(appdata IN, 
     16                        uniform float4x4 WorldViewProj, 
     17                        uniform float4x4 TexTransform, 
     18                        uniform float3x3 WorldIT, 
     19                        uniform float3 LightVec) 
    1820{ 
    19         int index = 3; 
     21        vpconn OUT; 
    2022         
    21         // find the appropriate depth map to look up in based on the depth of this fragment 
    22         if(gl_FragCoord.z < far_d.x) 
    23                 index = 0; 
    24         else if(gl_FragCoord.z < far_d.y) 
    25                 index = 1; 
    26         else if(gl_FragCoord.z < far_d.z) 
    27                 index = 2; 
     23        float3 worldNormal = normalize(mul(WorldIT, IN.Normal)); 
    2824         
    29         // transform this fragment's position from view space to scaled light clip space 
    30         // such that the xy coordinates are in [0;1] 
    31         // note there is no need to divide by w for othogonal light sources 
    32         vec4 shadow_coord = gl_TextureMatrix[index]*vPos; 
    33  
    34         shadow_coord.w = shadow_coord.z; 
     25        float ldotn = max(dot(LightVec, worldNormal), 0.0); 
     26        OUT.Color0.xyz = ldotn.xxx; 
    3527         
    36         // tell glsl in which layer to do the look up 
    37         shadow_coord.z = float(index); 
     28        float4 tempPos; 
     29        tempPos.xyz = IN.Position.xyz; 
     30        tempPos.w = 1.0; 
    3831         
    39         // get the stored depth 
    40         float shadow_d = texture2DArray(stex, shadow_coord.xyz).x; 
     32        OUT.TexCoord0 = mul(TexTransform, tempPos); 
     33        OUT.TexCoord1 = mul(TexTransform, tempPos); 
    4134         
    42         // get the difference of the stored depth and the distance of this fragment to the light 
    43         float diff = shadow_d - shadow_coord.w; 
     35        OUT.Hposition = mul(WorldViewProj, tempPos); 
    4436         
    45         // smoothen the result a bit, to avoid aliasing at shadow contact point 
    46         return clamp( diff*250.0 + 1.0, 0.0, 1.0); 
     37        return OUT; 
    4738} 
    4839 
    49 void main() 
     40 
     41struct v2f_simple { 
     42        float4 Hposition : POSITION; 
     43        float4 TexCoord0 : TEXCOORD0; 
     44        float4 TexCoord1 : TEXCOORD1; 
     45        float4 Color0 : COLOR0; 
     46}; 
     47 
     48 
     49float4 main(v2f_simple IN, 
     50                        uniform sampler2D ShadowMap, 
     51                        uniform sampler2D SpotLight) : COLOR 
    5052{ 
    51     const float shadow_ambient = 0.9; 
    52         vec4 color_tex = texture2D(tex, gl_TexCoord[0].st); 
    53         float shadow_coef = shadowCoef(); 
    54         float fog = clamp(gl_Fog.scale*(gl_Fog.end + vPos.z), 0.0, 1.0); 
    55         gl_FragColor = mix(gl_Fog.color, (shadow_ambient * shadow_coef * gl_Color * color_tex + (1.0 - shadow_ambient) * color_tex), fog); 
     53        float4 shadow = tex2D(ShadowMap, IN.TexCoord0.xy); 
     54        float4 spotlight = tex2D(SpotLight, IN.TexCoord1.xy); 
     55        float4 lighting = IN.Color0; 
     56        return shadow * spotlight * lighting; 
    5657} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r2890 r2891  
    44// Screen Spaced Ambient Occlusion shader 
    55// based on shader of Alexander Kusternig 
    6  
    76 
    87 
     
    2221 
    2322 
    24 float2 reflect(float2 pt, float2 n) 
     23float2 myreflect(float2 pt, float2 n) 
    2524{ 
    2625        // distance to plane 
     
    5756        for (int i = 0; i < NUM_SAMPLES; ++ i)  
    5857        { 
    59                 const float2 offset = samples[i]; 
     58                //const float2 offset = samples[i]; 
     59                const float3 offset = float3(samples[i], 0); 
    6060 
    6161                //////////////////// 
     
    6363 
    6464                //const float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f; 
    65                 float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy; 
     65                //float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy; 
     66                float3 mynoise = float3(tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy,0); 
    6667 
    6768                const float2 offsetTransformed = reflect(offset, mynoise); 
     
    123124        // expand normal 
    124125        float3 normal = normalize(norm.xyz); 
     126         
    125127        /// the current view direction 
    126         //float3 viewDir = normalize(IN.view * 2.0f - float3(1.0f)); 
    127         float3 viewDir = normalize(IN.view); 
     128        float3 viewDir;// = normalize(IN.view); 
    128129 
    129130        // the current world position 
     
    182183        float4 ao = tex2D(ssaoTex, IN.texCoord.xy); 
    183184 
    184         //OUT.illum_col = col * ao.x; 
    185         OUT.illum_col = ao; 
     185        OUT.illum_col = col * ao.x; 
     186        //OUT.illum_col = ao; 
    186187 
    187188        OUT.illum_col.w = ao.w; 
Note: See TracChangeset for help on using the changeset viewer.