Changeset 2891 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Timestamp:
- 09/01/08 08:58:38 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/antialiasing.cg
r2887 r2891 13 13 uniform float4 e_barrier = float4(5e-5, 5e-5, 0, 0); // x = normal, y = depth 14 14 // the weights for normal / depth discontinuity 15 //uniform float4 e_weights = float4(10.0f, 0.1f, 1.0f, 1.0f); // x = normal, y = depth16 uniform float4 e_weights = float4(1.0f, 1.0f, 1.0f, 1.0f); // x = normal, y = depth17 uniform float4 e_kernel = float4(0. 35f, 1.0f, 1.0f, 1.0f);15 uniform 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 17 uniform float4 e_kernel = float4(0.5f, 1.0f, 1.0f, 1.0f); 18 18 19 19 … … 34 34 nd.w = dot(nc, float3(tex2D(normals, IN.lb.xy))); 35 35 36 nd .x-= e_barrier.x;36 nd -= e_barrier.x; 37 37 nd = step((float4)0.0f, nd); 38 38 … … 84 84 float4 s3 = tex2Dlod(colors, float4(offset + IN.lb.xy * w, 0, 0)); 85 85 86 //float4 sx = tex2D(colors, IN.c.xy);86 float4 sc = tex2Dlod(colors, float4(IN.c.xy, 0, 0)); 87 87 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; 89 90 //return float4(w); 90 91 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg
r2887 r2891 29 29 30 30 31 float2 reflect(float2 pt, float2 n)31 float2 myreflect(float2 pt, float2 n) 32 32 { 33 33 // distance to plane … … 67 67 for (int i = 0; i < NUM_SAMPLES; i ++) 68 68 { 69 float2 offset = samples[i]; 69 //float2 offset = samples[i]; 70 float3 offset = float3(samples[i], 0); 70 71 71 72 //sample noisetex; r stores costheta, g stores sintheta 72 //float2 mynoise = tex2D(noiseTexture, IN.texCoord.xy * noiseMultiplier).xy * 2.0f - 1.0f;73 float 2 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); 74 75 75 76 // rotation … … 133 134 // expand normal 134 135 float3 normal = normalize(norm.xyz); 136 135 137 /// the current view direction 136 float3 viewDir = normalize(IN.view * 2.0f - float3(1.0f));138 float3 viewDir;// = normalize(IN.view); 137 139 138 140 // the current world position -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r2873 r2891 24 24 struct fragin 25 25 { 26 float4 position: POSITION; // eye space 27 float4 texCoord: TEXCOORD0; 26 float4 color: COLOR0; 27 float4 position: POSITION; // eye space 28 float4 texCoord: TEXCOORD0; 28 29 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 33 32 34 float4 mypos: TEXCOORD3; 35 //float DEPTH; 33 float3 normal: TEXCOORD2; 34 35 float4 mypos: TEXCOORD3; 36 //float DEPTH; 36 37 }; 37 38 -
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 1 struct appdata { 2 float3 Position : POSITION; 3 float3 Normal : NORMAL; 4 }; 10 5 11 uniform sampler2D tex;12 uniform vec4 far_d;13 6 14 varying vec4 vPos; 7 struct vpconn { 8 float4 Hposition : POSITION; 9 float4 TexCoord0 : TEXCOORD0; 10 float4 TexCoord1 : TEXCOORD1; 11 float4 Color0 : COLOR0; 12 }; 15 13 16 uniform sampler2DArray stex; 17 float shadowCoef() 14 15 vpconn main(appdata IN, 16 uniform float4x4 WorldViewProj, 17 uniform float4x4 TexTransform, 18 uniform float3x3 WorldIT, 19 uniform float3 LightVec) 18 20 { 19 int index = 3;21 vpconn OUT; 20 22 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)); 28 24 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; 35 27 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; 38 31 39 // get the stored depth40 float shadow_d = texture2DArray(stex, shadow_coord.xyz).x;32 OUT.TexCoord0 = mul(TexTransform, tempPos); 33 OUT.TexCoord1 = mul(TexTransform, tempPos); 41 34 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); 44 36 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; 47 38 } 48 39 49 void main() 40 41 struct v2f_simple { 42 float4 Hposition : POSITION; 43 float4 TexCoord0 : TEXCOORD0; 44 float4 TexCoord1 : TEXCOORD1; 45 float4 Color0 : COLOR0; 46 }; 47 48 49 float4 main(v2f_simple IN, 50 uniform sampler2D ShadowMap, 51 uniform sampler2D SpotLight) : COLOR 50 52 { 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; 56 57 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r2890 r2891 4 4 // Screen Spaced Ambient Occlusion shader 5 5 // based on shader of Alexander Kusternig 6 7 6 8 7 … … 22 21 23 22 24 float2 reflect(float2 pt, float2 n)23 float2 myreflect(float2 pt, float2 n) 25 24 { 26 25 // distance to plane … … 57 56 for (int i = 0; i < NUM_SAMPLES; ++ i) 58 57 { 59 const float2 offset = samples[i]; 58 //const float2 offset = samples[i]; 59 const float3 offset = float3(samples[i], 0); 60 60 61 61 //////////////////// … … 63 63 64 64 //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); 66 67 67 68 const float2 offsetTransformed = reflect(offset, mynoise); … … 123 124 // expand normal 124 125 float3 normal = normalize(norm.xyz); 126 125 127 /// 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); 128 129 129 130 // the current world position … … 182 183 float4 ao = tex2D(ssaoTex, IN.texCoord.xy); 183 184 184 //OUT.illum_col = col * ao.x;185 OUT.illum_col = ao;185 OUT.illum_col = col * ao.x; 186 //OUT.illum_col = ao; 186 187 187 188 OUT.illum_col.w = ao.w;
Note: See TracChangeset
for help on using the changeset viewer.