Changeset 2865 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Timestamp:
- 08/25/08 17:34:34 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/antialiasing.cg
r2864 r2865 1 1 struct v2p 2 2 { 3 float tc0: TEXCOORD0; // Center 4 float tc1: TEXCOORD1; // Center 5 float tc2: TEXCOORD2; // Center 6 float tc3: TEXCOORD3; // Center 7 float tc4: TEXCOORD4; // Center 8 float tc5: TEXCOORD5; // Center 9 float tc6: TEXCOORD6; // Center 10 } 3 float2 c: TEXCOORD0; // center 4 float2 lt: TEXCOORD1; // left top 5 float2 rb: TEXCOORD2; // right bottom 6 float2 rt: TEXCOORD3; // right top 7 float2 lb: TEXCOORD4; // left bottom 8 float4 lr: TEXCOORD5; // left / right 9 float4 tb: TEXCOORD6; // top / bottom 10 }; 11 12 //uniform sampler2D s_distort; 13 uniform float4 e_barrier = float4(5e-5, 5e-5, 0, 0); 14 uniform 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 11 16 12 17 13 uniform sampler2D s_distort; 14 uniform hlf4 e_barrier; 15 uniform half4 e_weights; 16 uniform half4 e_kernel; 18 float4 main(v2p IN, 19 uniform sampler2D colors, 20 uniform sampler2D normals 21 ): COLOR 22 { 23 // normal discontinuity filter 24 float3 nc = (float3)tex2D(normals, IN.c.xy); 17 25 18 half4 main(v2p) : COLOR 19 { 20 21 22 // discontinuity filter 23 /*float nc = tex1D(s_normal, I.tc0); 24 float nd; 25 26 nd.x = dot(nc, float3(tex2D(s_normal, I.tc1)); 27 nd.y = dot(nc, float3(tex2D(s_normal, I.tc2)); 28 nd.z = dot(nc, float3(tex2D(s_normal, I.tc3)); 29 nd.w = dot(nc, float3(tex2D(s_normal, I.tc4)); 26 float4 nd; 27 nd.x = dot(nc, float3(tex2D(normals, IN.lt.xy))); 28 nd.y = dot(nc, float3(tex2D(normals, IN.rb.xy))); 29 nd.z = dot(nc, float3(tex2D(normals, IN.rt.xy))); 30 nd.w = dot(nc, float3(tex2D(normals, IN.lb.xy))); 30 31 31 32 nd -= e_barrier.x; 32 nd = max(0, nd);33 nd = step(0, nd); 33 34 34 35 float ne = saturate(dot(nd, e_weights.x)); 35 36 36 float 4 tc5r = = I.tc5.wzyx;37 float 4 tc6r = = I.tc6.wzyx;38 */ 37 // opposite coordinates 38 float4 lrr = IN.lr.wzyx; 39 float4 tbr = IN.tb.wzyx; 39 40 41 // depth filter: compute gradient difference: 42 // (c - sample) + (c - opposite sample) 43 44 float4 dc = float4(tex2D(colors, IN.c).w); 45 46 float pos_lt = (float)tex2D(colors, IN.lt.xy).w; 47 float pos_rb = (float)tex2D(colors, IN.rb.xy).w; 48 49 float pos_lb = (float)tex2D(colors, IN.lb.xy).w; 50 float pos_rt = (float)tex2D(colors, IN.rt.xy).w; 51 52 float pos_l = (float)tex2D(colors, IN.lr.xy).w; 53 float pos_r = (float)tex2D(colors, lrr.xy).w; 54 55 float pos_t = (float)tex2D(colors, IN.tb.xy).w; 56 float pos_b = (float)tex2D(colors, tbr.xy).w; 57 58 float4 dd; 59 60 dd.x = pos_lt + pos_rb; 61 dd.y = pos_lb + pos_rt; 62 dd.z = pos_l + pos_r; 63 dd.w = pos_t + pos_b; 64 65 dd = abs(2.0f * dc - dd) - e_barrier.y; 66 dd = step(dd, 0); 67 float de = saturate(dot(dd, e_weights.y)); 68 69 // weight: 0 = no aa, 1 = full antialiasing 70 float w = (1.0f - de * ne) * e_kernel.x; 71 72 // smoothed color 73 // (a - c) * w + c = a * w + c * (1 - w) 74 float2 offset = IN.c.xy * (1.0f - w); 75 76 float4 s0 = tex2D(colors, offset + IN.lt.xy * w); 77 float4 s1 = tex2D(colors, offset + IN.rb.xy * w); 78 float4 s2 = tex2D(colors, offset + IN.rt.xy * w); 79 float4 s3 = tex2D(colors, offset + IN.lb.xy * w); 80 81 return (s0 + s1 + s2 + s3) / 4.0f; 82 //return float4(w); 40 83 } 41 42 43 44 45 struct fragment46 {47 float4 pos: WPOS; // normalized screen position48 float4 texCoord: TEXCOORD0;49 };50 51 struct pixel52 {53 float4 color: COLOR0;54 };55 56 57 pixel main(fragment IN,58 uniform sampler2D colorsTex1,59 uniform sampler2D colorsTex2)60 {61 pixel OUT;62 63 float4 col1 = tex2D(colorsTex1, IN.texCoord.xy);64 float4 col2 = tex2D(colorsTex2, IN.texCoord.xy);65 66 const float x = 0.5f;67 OUT.color = col1 * x + col2 * (1.0f - x);68 69 return OUT;70 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2863 r2865 7 7 8 8 // rule of thumb: approx 1 / NUM_SAMPLES 9 //#define SAMPLE_INTENSITY 0.2 10 #define SAMPLE_INTENSITY 0.125f9 #define SAMPLE_INTENSITY 0.17 10 //#define SAMPLE_INTENSITY 0.125f 11 11 12 12 #define AREA_SIZE 9e-1f 13 13 //#define VIEW_CORRECTION_SCALE 0.3f 14 #define VIEW_CORRECTION_SCALE 1.0f14 #define VIEW_CORRECTION_SCALE 0.5f 15 15 #define DISTANCE_SCALE 1e-6f 16 16 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r2851 r2865 73 73 uniform float4 diffuse) 74 74 { 75 pixel pix; 76 77 pix.col = (ambient + diffuse) * tex2D(tex, IN.texCoord.xy); 78 pix.pos = IN.worldPos * maxDepth; 79 pix.norm.xyz = IN.normal * 0.5f + 0.5f; 75 pixel pix; 80 76 81 // hack: squeeze some information about ambient into the texture 82 pix.norm.w = ambient.x; 83 // hack: store projection coordinate for scaling ssao 84 pix.pos.w = IN.projPos.w; 77 pix.col = (ambient + diffuse) * tex2D(tex, IN.texCoord.xy); 78 pix.pos = IN.worldPos * maxDepth; 79 pix.norm.xyz = IN.normal * 0.5f + 0.5f; 85 80 86 if (pix.col.w < 0.5f) 87 discard; 81 // hack: squeeze some information about ambient into the texture 82 pix.norm.w = ambient.x; 83 // hack: store projection coordinate for scaling ssao 84 pix.pos.w = IN.projPos.w; 88 85 89 pix.col.w = IN.mypos.z / IN.mypos.w; 86 // account for alpha blending 87 if (pix.col.w < 0.5f) 88 discard; 90 89 91 return pix; 90 // write the depth 91 pix.col.w = IN.mypos.z / IN.mypos.w; 92 93 return pix; 92 94 } 93 95 … … 98 100 uniform float4 diffuse) 99 101 { 100 pixel pix; 101 102 pix.col = diffuse; 103 pix.pos = IN.worldPos * maxDepth; 104 pix.norm.xyz = IN.normal * 0.5f + float3(0.5f); 105 // hack: squeeze some information about ambient into the texture 106 pix.norm.w = ambient.x; 107 pix.pos.w = IN.mypos.w; 108 pix.col.w = IN.mypos.z / IN.mypos.w; 102 pixel pix; 109 103 110 return pix; 104 pix.col = diffuse; 105 pix.pos = IN.worldPos * maxDepth; 106 pix.norm.xyz = IN.normal * 0.5f + float3(0.5f); 107 // hack: squeeze some information about ambient into the texture 108 pix.norm.w = ambient.x; 109 pix.pos.w = IN.mypos.w; 110 pix.col.w = IN.mypos.z / IN.mypos.w; 111 112 return pix; 111 113 }
Note: See TracChangeset
for help on using the changeset viewer.