Ignore:
Timestamp:
07/07/08 10:52:03 (16 years ago)
Author:
mattausch
Message:

worked on deferred shading

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
Files:
4 deleted
2 edited

Legend:

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

    r2817 r2818  
    6060           uniform sampler2D positions, 
    6161           uniform sampler2D normals, 
    62            const uniform float4x4 ProjTrafo, 
    6362           uniform sampler2D noiseTexture                                
    6463           ) 
    6564{ 
    6665  // the current world position 
    67   float4 centerPositionW = tex2D(positions, IN.texCoord.xy); 
    68   float3 centerPosition = centerPositionW.xyz; 
     66  float4 centerPosition = tex2D(positions, IN.texCoord.xy); 
     67  // the w coordinate from the persp. projection 
     68  float w = centerPosition.w; 
    6969 
    7070  // the normal on the current position 
     
    8787    //sample noisetex; r stores costheta, g stores sintheta 
    8888    float3 noise = tex2D(noiseTexture, IN.texCoord.xy).xyz * 2.0f - 1.0f; 
    89  
    90     //float2 offsetTransformed = offset;//reflect(offset, noise.xy); 
     89         
     90    // rotation 
     91    //float2 offsetTransformed = offset; 
    9192    float2 offsetTransformed; 
    9293    offsetTransformed.x = noise.r * offset.x - noise.g * offset.y; 
     
    9495                 
    9596    // weight with projected coordinate to reach similar kernel size for near and far 
    96     float2 texcoord = IN.texCoord.xy + offsetTransformed * areaSize * centerPositionW.w; 
     97    float2 texcoord = IN.texCoord.xy + offsetTransformed * areaSize * w; 
    9798     
    9899    float3 sample_position = tex2D(positions, texcoord).xyz; 
    99100     
    100     float3 vector_to_sample = sample_position - centerPosition; 
     101    float3 vector_to_sample = sample_position - centerPosition.xyz; 
    101102    float length_to_sample = length(vector_to_sample); 
    102103    float3 direction_to_sample = vector_to_sample / (length_to_sample + 1e-9f); 
     
    125126           uniform sampler2D positions, 
    126127           uniform sampler2D normals, 
    127            const uniform float4x4 ProjTrafo, 
    128128           uniform sampler2D noiseTexture) 
    129129{ 
     
    137137 
    138138  // expand normal 
    139   normal = normal * 2.0f - 1.0f; 
     139  normal = normalize(normal * 2.0f - 1.0f); 
    140140 
    141141  float4 position = tex2D(positions, IN.texCoord.xy); 
     
    146146  float3 light = normalize(lightDir.xyz); 
    147147  float3 light2 = normalize(lightDir2.xyz); 
    148  
     148  
    149149  float diffuseLight = max(dot(normal, light), 0.0f); 
    150150  float diffuseLight2 = max(dot(normal, light2), 0.0f); 
     
    152152  float diffuse = diffuseLight + diffuseLight2; 
    153153 
    154   float ao = ssao(IN, positions, normals, ProjTrafo, noiseTexture); 
     154  float ao = ssao(IN, positions, normals, noiseTexture); 
    155155  //OUT.color = ao;  
    156156  OUT.color = ao * (ambient + diffuse) * color; 
    157 //OUT.color = (ambient + diffuse) * color; 
    158  
    159   //float4 currentPos = tex2D(normals, IN.texCoord.xy) * 0.5f + 0.5f; 
    160   //float4 currentPos = tex2D(normals, IN.texCoord.xy); 
    161   //OUT.color = currentPos; 
     157  //OUT.color = (ambient + diffuse) * color; 
    162158       
    163159  return OUT; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r2813 r2818  
    4141 
    4242 
    43 vtxout vtx(vtxin IN, uniform float4x4 ModelViewProj) 
     43vtxout vtx(vtxin IN,  
     44           const uniform float4x4 ModelViewProj, 
     45           uniform float4x4 ModelMatrix) 
    4446{ 
    4547   vtxout OUT; 
    4648   
    4749   // transform the vertex position into eye space 
    48    OUT.position = mul(ModelViewProj, IN.position); 
    49  
    5050   OUT.color = IN.color; 
    5151 
    5252   OUT.texCoord = IN.texCoord; 
     53   OUT.worldPos = mul(ModelMatrix, IN.position); 
     54 
     55   // transform the vertex position into eye space 
     56   OUT.position = mul(ModelViewProj, OUT.worldPos); 
     57 
    5358   OUT.worldPos = IN.position; 
    54    // eye pos with linear depth 
    55    //OUT.worldPos = OUT.position; 
     59 
    5660   OUT.normal = IN.normal; 
    5761 
     
    6670  pix.col = tex2D(tex, IN.texCoord.xy); 
    6771  pix.pos = IN.worldPos * maxDepth; 
     72  pix.norm = IN.normal; 
    6873  pix.pos.w = IN.projPos.w; 
    69   pix.norm = IN.normal; 
    7074 
    7175  return pix; 
Note: See TracChangeset for help on using the changeset viewer.