Changeset 2973 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Timestamp:
- 09/25/08 11:05:46 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/antialiasing.cg
r2970 r2973 21 21 22 22 23 float3 ToneMap(float imageKey, float whiteLum, float middleGrey, float3 color)24 {25 float3 outCol;26 const float pixLum = 0.2125f * color.x + 0.7154f * color.y + 0.0721f * color.z;27 28 // adjust to middle gray29 const float lum = middleGrey * pixLum / imageKey;30 31 // map to range and calc burnout32 const float burnedLum = lum * (1.0f + lum / whiteLum * whiteLum) / (1.0f + lum);33 34 outCol = color * burnedLum / pixLum;35 36 /*37 outCol = color;38 39 outCol.rgb *= MIDDLE_GRAY /(MIDDLE_GRAY + 0.001f);40 outCol.rgb *= (1.0f + color.rgb / whiteLum);41 outCol.rgb /= (1.0f + color.rgb);42 */43 //vColor.rgb += 0.6f * vBloom;44 45 return outCol;46 }47 48 49 23 float4 main(v2p IN, 50 24 uniform sampler2D colors, 51 uniform sampler2D normals, 52 uniform float imageKey, 53 uniform float whiteLum, 54 uniform float middleGrey 25 uniform sampler2D normals 55 26 ): COLOR 56 27 { … … 121 92 //return (s0 + s1 + s2 + s3) * 0.25f; 122 93 123 //return float4(w);124 col.xyz = ToneMap(imageKey, whiteLum, middleGrey, col.xyz);125 126 94 return col; 127 95 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg
r2972 r2973 7 7 float4 pos: WPOS; 8 8 float4 texCoord: TEXCOORD0; 9 10 float2 lt: TEXCOORD1; // left top 11 float2 rb: TEXCOORD2; // right bottom 12 float2 rt: TEXCOORD3; // right top 13 float2 lb: TEXCOORD4; // left bottom 9 14 }; 10 15 11 16 12 13 float3 ToneMap(float imageKey, float whiteLum, float middleGrey, float3 color) 17 struct pixel 14 18 { 15 float3 outCol; 16 const float pixLum = 0.2125f * color.x + 0.7154f * color.y + 0.0721f * color.z; 17 18 // adjust to middle gray 19 const float lum = middleGrey * pixLum / imageKey; 20 21 // map to range and calc burnout 22 const float burnedLum = lum * (1.0f + lum / whiteLum * whiteLum) / (1.0f + lum); 23 24 outCol = color * burnedLum / pixLum; 25 26 return outCol; 27 } 28 19 float4 col: COLOR0; 20 }; 29 21 30 22 … … 37 29 for(int i = 0; i < 16; ++ i) 38 30 { 39 average += tex2D(colors, IN.texCoord + float2(downSampleOffs[i].x, downSampleOffs[i].y));31 average += tex2D(colors, IN.texCoord.xy + downSampleOffs[i]); 40 32 } 41 33 … … 47 39 48 40 float4 GreyScaleDownSample(fragment IN, 49 uniform sampler2D colors, 50 float2 offs[16]): COLOR 41 uniform sampler2D colors): COLOR 51 42 { 52 43 … … 55 46 float maximum = -1e20; 56 47 57 float4 color = 0.0f;58 59 48 // the rgb weights 60 49 const float3 w = float3(0.299f, 0.587f, 0.114f); 61 50 //float3 w = float3(0.2125f, 0.7154f, 0.0721f); 62 51 52 float4 cols[4]; 53 54 cols[0] = tex2D(colors, IN.texCoord.xy + IN.lt.xy); 55 cols[1] = tex2D(colors, IN.texCoord.xy + IN.lb.xy); 56 cols[2] = tex2D(colors, IN.texCoord.xy + IN.rt.xy); 57 cols[3] = tex2D(colors, IN.texCoord.xy + IN.rb.xy); 58 59 63 60 for (int i = 0; i < 4; ++ i) 64 61 { 65 co lor = tex2D(colors, IN.texcoord + float2(offs[i].x, offs[i].y));62 const float intensity = dot(cols[i].rgb, w); 66 63 67 const float intensity = dot(color.rgb, W); 68 69 maximum = max(maximum, intentsity); 70 average += (0.25f * log(1e-5f + GreyValue)); 64 maximum = max(maximum, intensity); 65 average += (0.25f * log(1e-5f + intensity)); 71 66 } 72 67 73 68 average = exp(average); 74 69 70 return tex2D(colors, IN.texCoord.xy); 71 75 72 // Output the luminance to the render target 76 73 return float4(average, maximum, 0.0f, 1.0f); 77 74 } 75 78 76 79 80 77 pixel ToneMap(fragment IN, 78 uniform sampler2D colors, 79 uniform float imageKey, 80 uniform float whiteLum, 81 uniform float middleGrey) 82 { 83 pixel OUT; 84 float4 color = tex2D(colors, IN.texCoord.xy); 85 86 const float pixLum = 0.2125f * color.x + 0.7154f * color.y + 0.0721f * color.z; 87 88 // adjust to middle gray 89 const float lum = middleGrey * pixLum / imageKey; 90 91 // map to range and calc burnout 92 const float scaleLum = lum * (1.0f + lum / whiteLum * whiteLum) / (1.0f + lum); 93 94 OUT.col = color * scaleLum / pixLum; 95 OUT.col.w = color.w; 96 97 return OUT; 98 }
Note: See TracChangeset
for help on using the changeset viewer.