Ignore:
Timestamp:
10/16/08 19:51:16 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r3026 r3034  
    175175        const float eyeDepth = tex2Dlod(colors, float4(IN.texCoord, 0, 0)).w; 
    176176 
    177         float4 position; 
    178         position.xyz = eyePos - viewDir * eyeDepth; 
    179          
     177        const float4 worldPos = float4(eyePos - viewDir * eyeDepth, 1); 
    180178         
    181179        // diffuse intensity 
     
    193191                ) 
    194192        { 
    195                 position.w = 1.0f; 
    196  
    197                 float4 lightSpacePos = mul(shadowMatrix, position); 
     193                float4 lightSpacePos = mul(shadowMatrix, worldPos); 
    198194                lightSpacePos /= lightSpacePos.w; 
    199195 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg

    r3026 r3034  
    179179        const float3 eyeSpacePos = -viewDir * eyeDepth; 
    180180 
    181         const float3 centerPosition = eyePos + eyeSpacePos; 
    182         const float4 realPos = float4(centerPosition, 1.0f); 
     181        const float4 worldPos = float4(eyePos + eyeSpacePos, 1.0f); 
    183182 
    184183        // calculcate the current projected depth for next frame 
    185         float4 currentPos = mul(modelViewProj, realPos); 
     184        float4 currentPos = mul(modelViewProj, worldPos); 
     185 
    186186        const float w = SAMPLE_RADIUS / currentPos.w; 
    187187        currentPos /= currentPos.w; 
     188         
    188189        const float currentDepth = currentPos.z * 1e-3f; 
    189190 
     
    197198        //-- compute temporally smoothing 
    198199 
    199          
    200200        // reprojection new frame into old one  
    201201        // calculate projected depth 
    202         float4 projPos = mul(oldModelViewProj, realPos); 
     202        float4 projPos = mul(oldModelViewProj, worldPos); 
    203203        projPos /= projPos.w; 
    204204 
     
    210210 
    211211        // retrieve the sample from the last frame 
    212         float3 oldSsao = tex2D(oldSsaoTex, tex); 
    213         float3 oldIllum = tex2D(oldIllumTex, tex); 
     212        float3 oldSsao = tex2D(oldSsaoTex, tex).xyz; 
     213        float3 oldIllum = tex2D(oldIllumTex, tex).xyz; 
    214214 
    215215        const float oldDepth = oldSsao.z; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r3031 r3034  
    1515 
    1616  float4 color: COLOR0;   
    17   float4 worldPos: TEXCOORD1; // world position 
     17  float4 eyePos: TEXCOORD1; // eye position 
    1818  float3 normal: TEXCOORD2; 
    1919}; 
     
    2424{ 
    2525        float4 color: COLOR0;   
    26         float4 position: POSITION; // eye space 
     26        //float4 position: POSITION; 
    2727        float4 texCoord: TEXCOORD0;     
    2828 
    2929        float4 winPos: WPOS; 
    30         float4 worldPos: TEXCOORD1; // world position 
     30        float4 eyePos: TEXCOORD1; // eye position 
    3131        float3 normal: TEXCOORD2; 
    3232}; 
     
    4040}; 
    4141 
     42 
    4243#pragma position_invariant vtx 
    4344 
    44 vtxout vtx(vtxin IN,  
    45                    uniform float4x4 modelView) 
     45vtxout vtx(vtxin IN) 
    4646{ 
    4747        vtxout OUT; 
     
    5050        OUT.texCoord = IN.texCoord; 
    5151 
    52         //OUT.worldPos = mul(glstate.matrix.inverse.projection, OUT.position); 
    53         OUT.worldPos = mul(modelView, IN.position); 
    5452        // transform the vertex position into eye space 
     53        OUT.eyePos = mul(glstate.matrix.modelview[0], IN.position); 
     54        // transform the vertex position into post projection space 
    5555        OUT.position = mul(glstate.matrix.mvp, IN.position); 
    5656 
     
    6060} 
    6161 
    62  
    63 // bilinear interpolation 
    64 inline float3 Interpol(float2 w, float3 bl, float3 br, float3 tl, float3 tr) 
    65 { 
    66         float3 x1 = lerp(bl, tl, w.y); 
    67         float3 x2 = lerp(br, tr, w.y);  
    68         float3 v = lerp(x1, x2, w.x);  
    69  
    70         return v; 
    71 } 
    72  
    7362//#pragma position_invariant fragtex 
    7463 
    7564pixel fragtex(fragin IN,  
    76                           uniform sampler2D tex, 
    77                           uniform float3 eyePos, 
    78                           uniform float3 bl, 
    79                           uniform float3 br, 
    80                           uniform float3 tl, 
    81                           uniform float3 tr 
     65                          uniform sampler2D tex 
    8266                          ) 
    8367{ 
     
    9983 
    10084        // compute eye linear depth 
    101         pix.col.w = length(eyePos - IN.worldPos.xyz); 
     85        pix.col.w = length(IN.eyePos.xyz); 
    10286 
    10387        return pix; 
     
    10589 
    10690 
    107 pixel frag(fragin IN,  
    108                    uniform float3 eyePos, 
    109                    uniform float3 bl, 
    110                    uniform float3 br, 
    111                    uniform float3 tl, 
    112                    uniform float3 tr) 
     91pixel frag(fragin IN) 
    11392{ 
    11493        pixel pix; 
     
    11998        pix.norm = IN.normal; 
    12099 
     100        pix.col.w = length(IN.eyePos.xyz); 
     101 
    121102        // hack: squeeze some information about the ambient term into the target 
    122103        //pix.col.w = glstate.material.emission.x; 
    123         pix.col.w = length(eyePos - IN.worldPos.xyz); 
    124104 
    125105        return pix; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3028 r3034  
    159159        const float eyeDepth = tex2Dlod(colors, float4(IN.texCoord, 0, 0)).w; 
    160160        const float3 eyeSpacePos = -viewDir * eyeDepth; 
    161         const float3 centerPosition = eyePos + eyeSpacePos; 
    162  
    163         const float4 realPos = float4(centerPosition, 1.0f); 
     161        const float4 worldPos = float4(eyePos + eyeSpacePos, 1.0f); 
    164162 
    165163 
     
    167165        //-- calculcate the current projected depth for next frame 
    168166         
    169         float4 currentPos = mul(modelViewProj, realPos); 
     167        float4 currentPos = mul(modelViewProj, worldPos); 
    170168         
    171169        const float w = SAMPLE_RADIUS / currentPos.w; 
     
    185183         
    186184        // calculate projected depth 
    187         float4 projPos = mul(oldModelViewProj, realPos); 
     185        float4 projPos = mul(oldModelViewProj, worldPos); 
    188186        projPos /= projPos.w; 
    189  
     187         
    190188        // the current depth projected into the old frame 
    191189        const float projDepth = projPos.z * precisionScale; 
Note: See TracChangeset for help on using the changeset viewer.