diff options
Diffstat (limited to 'linden/indra/newview/app_settings/shaders/class1/deferred')
36 files changed, 1098 insertions, 128 deletions
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index a91e9fa..f90d91f 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | |||
@@ -13,9 +13,9 @@ uniform sampler2DShadow shadowMap1; | |||
13 | uniform sampler2DShadow shadowMap2; | 13 | uniform sampler2DShadow shadowMap2; |
14 | uniform sampler2DShadow shadowMap3; | 14 | uniform sampler2DShadow shadowMap3; |
15 | uniform sampler2D noiseMap; | 15 | uniform sampler2D noiseMap; |
16 | uniform sampler2DRect positionMap; | 16 | uniform sampler2DRect depthMap; |
17 | 17 | ||
18 | uniform mat4 shadow_matrix[4]; | 18 | uniform mat4 shadow_matrix[6]; |
19 | uniform vec4 shadow_clip; | 19 | uniform vec4 shadow_clip; |
20 | uniform vec2 screen_res; | 20 | uniform vec2 screen_res; |
21 | 21 | ||
@@ -26,15 +26,31 @@ varying vec3 vary_ambient; | |||
26 | varying vec3 vary_directional; | 26 | varying vec3 vary_directional; |
27 | varying vec3 vary_fragcoord; | 27 | varying vec3 vary_fragcoord; |
28 | varying vec3 vary_position; | 28 | varying vec3 vary_position; |
29 | varying vec3 vary_light; | ||
29 | 30 | ||
30 | uniform float alpha_soften; | 31 | uniform float alpha_soften; |
31 | 32 | ||
33 | uniform mat4 inv_proj; | ||
34 | |||
35 | vec4 getPosition(vec2 pos_screen) | ||
36 | { | ||
37 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
38 | vec2 sc = pos_screen.xy*2.0; | ||
39 | sc /= screen_res; | ||
40 | sc -= vec2(1.0,1.0); | ||
41 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
42 | vec4 pos = inv_proj * ndc; | ||
43 | pos /= pos.w; | ||
44 | pos.w = 1.0; | ||
45 | return pos; | ||
46 | } | ||
47 | |||
32 | void main() | 48 | void main() |
33 | { | 49 | { |
34 | vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; | 50 | vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; |
35 | frag *= screen_res; | 51 | frag *= screen_res; |
36 | 52 | ||
37 | vec3 samp_pos = texture2DRect(positionMap, frag).xyz; | 53 | vec3 samp_pos = getPosition(frag).xyz; |
38 | 54 | ||
39 | float shadow = 1.0; | 55 | float shadow = 1.0; |
40 | vec4 pos = vec4(vary_position, 1.0); | 56 | vec4 pos = vec4(vary_position, 1.0); |
@@ -82,7 +98,7 @@ void main() | |||
82 | 98 | ||
83 | //gl_FragColor = gl_Color; | 99 | //gl_FragColor = gl_Color; |
84 | gl_FragColor = color; | 100 | gl_FragColor = color; |
85 | //gl_FragColor = vec4(1,0,1,1); | 101 | //gl_FragColor = vec4(1,0,1,1)*shadow; |
86 | 102 | ||
87 | } | 103 | } |
88 | 104 | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl index b496bd6..48baf77 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl | |||
@@ -20,8 +20,11 @@ varying vec3 vary_ambient; | |||
20 | varying vec3 vary_directional; | 20 | varying vec3 vary_directional; |
21 | varying vec3 vary_fragcoord; | 21 | varying vec3 vary_fragcoord; |
22 | varying vec3 vary_position; | 22 | varying vec3 vary_position; |
23 | varying vec3 vary_light; | ||
23 | 24 | ||
24 | uniform float near_clip; | 25 | uniform float near_clip; |
26 | uniform float shadow_offset; | ||
27 | uniform float shadow_bias; | ||
25 | 28 | ||
26 | void main() | 29 | void main() |
27 | { | 30 | { |
@@ -32,8 +35,9 @@ void main() | |||
32 | 35 | ||
33 | vec4 pos = (gl_ModelViewMatrix * gl_Vertex); | 36 | vec4 pos = (gl_ModelViewMatrix * gl_Vertex); |
34 | vec3 norm = normalize(gl_NormalMatrix * gl_Normal); | 37 | vec3 norm = normalize(gl_NormalMatrix * gl_Normal); |
35 | vary_position = pos.xyz; | 38 | // KL this works around ATI not compiling the shader but maintains shadow offset and bias vec3 not vec4 |
36 | 39 | vary_position = pos.xyz + norm.xyz * (-pos.z/64.0*shadow_offset+shadow_bias); | |
40 | |||
37 | calcAtmospherics(pos.xyz); | 41 | calcAtmospherics(pos.xyz); |
38 | 42 | ||
39 | //vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.)); | 43 | //vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.)); |
@@ -54,6 +58,8 @@ void main() | |||
54 | col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz); | 58 | col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz); |
55 | col.rgb = scaleDownLight(col.rgb); | 59 | col.rgb = scaleDownLight(col.rgb); |
56 | 60 | ||
61 | vary_light = gl_LightSource[0].position.xyz; | ||
62 | |||
57 | vary_ambient = col.rgb*gl_Color.rgb; | 63 | vary_ambient = col.rgb*gl_Color.rgb; |
58 | vary_directional.rgb = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a))); | 64 | vary_directional.rgb = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a))); |
59 | 65 | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaF.glsl index 6c94f5c..ff64a6b 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaF.glsl | |||
@@ -12,7 +12,7 @@ uniform sampler2DShadow shadowMap2; | |||
12 | uniform sampler2DShadow shadowMap3; | 12 | uniform sampler2DShadow shadowMap3; |
13 | uniform sampler2D noiseMap; | 13 | uniform sampler2D noiseMap; |
14 | 14 | ||
15 | uniform mat4 shadow_matrix[4]; | 15 | uniform mat4 shadow_matrix[6]; |
16 | uniform vec4 shadow_clip; | 16 | uniform vec4 shadow_clip; |
17 | 17 | ||
18 | vec3 atmosLighting(vec3 light); | 18 | vec3 atmosLighting(vec3 light); |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl index 58aa5a9..4b9cca2 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl | |||
@@ -8,13 +8,18 @@ | |||
8 | uniform sampler2D diffuseMap; | 8 | uniform sampler2D diffuseMap; |
9 | 9 | ||
10 | varying vec3 vary_normal; | 10 | varying vec3 vary_normal; |
11 | varying vec4 vary_position; | ||
12 | 11 | ||
13 | void main() | 12 | void main() |
14 | { | 13 | { |
15 | gl_FragData[0] = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy); | 14 | vec4 diff = gl_Color*texture2D(diffuseMap, gl_TexCoord[0].xy); |
15 | // Viewer 2.0 uses 0.2 but for KL's viewer if i want a complete avatar need this to be 0.0 for now. | ||
16 | if (diff.a < 0.0) | ||
17 | { | ||
18 | discard; | ||
19 | } | ||
20 | |||
21 | gl_FragData[0] = vec4(diff.rgb, 1.0); | ||
16 | gl_FragData[1] = vec4(0,0,0,0); | 22 | gl_FragData[1] = vec4(0,0,0,0); |
17 | gl_FragData[2] = vec4(normalize(vary_normal), 0.0); | 23 | gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0); |
18 | gl_FragData[3] = vary_position; | ||
19 | } | 24 | } |
20 | 25 | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl index 27c09db..00083eb 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl | |||
@@ -10,6 +10,7 @@ uniform sampler2D diffuseMap; | |||
10 | 10 | ||
11 | void main() | 11 | void main() |
12 | { | 12 | { |
13 | gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy)); | 13 | gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy).a); |
14 | //gl_FragColor = vec4(1,1,1,1); | ||
14 | } | 15 | } |
15 | 16 | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl index 14da6b1..8c8489d 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl | |||
@@ -28,8 +28,7 @@ void main() | |||
28 | norm = normalize(norm); | 28 | norm = normalize(norm); |
29 | 29 | ||
30 | pos = gl_ProjectionMatrix * pos; | 30 | pos = gl_ProjectionMatrix * pos; |
31 | //smash geometry against near clip plane | 31 | pos.z = max(pos.z, -pos.w+0.01); |
32 | pos.z = max(pos.z, -1.0); | ||
33 | gl_Position = pos; | 32 | gl_Position = pos; |
34 | 33 | ||
35 | gl_FrontColor = gl_Color; | 34 | gl_FrontColor = gl_Color; |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl index 12a7ff7..471a1f0 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl | |||
@@ -10,7 +10,6 @@ mat4 getSkinnedTransform(); | |||
10 | attribute vec4 weight; | 10 | attribute vec4 weight; |
11 | 11 | ||
12 | varying vec3 vary_normal; | 12 | varying vec3 vary_normal; |
13 | varying vec4 vary_position; | ||
14 | 13 | ||
15 | void main() | 14 | void main() |
16 | { | 15 | { |
@@ -30,7 +29,6 @@ void main() | |||
30 | norm.z = dot(trans[2].xyz, gl_Normal); | 29 | norm.z = dot(trans[2].xyz, gl_Normal); |
31 | norm = normalize(norm); | 30 | norm = normalize(norm); |
32 | 31 | ||
33 | vary_position = pos; | ||
34 | vary_normal = norm; | 32 | vary_normal = norm; |
35 | 33 | ||
36 | gl_Position = gl_ProjectionMatrix * pos; | 34 | gl_Position = gl_ProjectionMatrix * pos; |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl index 3c6700a..1713fe9 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl | |||
@@ -7,10 +7,11 @@ | |||
7 | 7 | ||
8 | #extension GL_ARB_texture_rectangle : enable | 8 | #extension GL_ARB_texture_rectangle : enable |
9 | 9 | ||
10 | uniform sampler2DRect positionMap; | 10 | uniform sampler2DRect depthMap; |
11 | uniform sampler2DRect normalMap; | 11 | uniform sampler2DRect normalMap; |
12 | uniform sampler2DRect lightMap; | 12 | uniform sampler2DRect lightMap; |
13 | 13 | ||
14 | uniform float dist_factor; | ||
14 | uniform float blur_size; | 15 | uniform float blur_size; |
15 | uniform vec2 delta; | 16 | uniform vec2 delta; |
16 | uniform vec3 kern[32]; | 17 | uniform vec3 kern[32]; |
@@ -19,30 +20,52 @@ uniform float kern_scale; | |||
19 | 20 | ||
20 | varying vec2 vary_fragcoord; | 21 | varying vec2 vary_fragcoord; |
21 | 22 | ||
23 | uniform mat4 inv_proj; | ||
24 | uniform vec2 screen_res; | ||
25 | |||
26 | vec4 getPosition(vec2 pos_screen) | ||
27 | { | ||
28 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
29 | vec2 sc = pos_screen.xy*2.0; | ||
30 | sc /= screen_res; | ||
31 | sc -= vec2(1.0,1.0); | ||
32 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
33 | vec4 pos = inv_proj * ndc; | ||
34 | pos /= pos.w; | ||
35 | pos.w = 1.0; | ||
36 | return pos; | ||
37 | } | ||
38 | |||
22 | void main() | 39 | void main() |
23 | { | 40 | { |
24 | vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz; | 41 | vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0; |
25 | vec3 pos = texture2DRect(positionMap, vary_fragcoord.xy).xyz; | 42 | vec3 pos = getPosition(vary_fragcoord.xy).xyz; |
26 | vec2 ccol = texture2DRect(lightMap, vary_fragcoord.xy).rg; | 43 | vec4 ccol = texture2DRect(lightMap, vary_fragcoord.xy).rgba; |
27 | 44 | ||
28 | vec2 dlt = kern_scale * delta / (1.0+norm.xy*norm.xy); | 45 | vec2 dlt = kern_scale * delta / (1.0+norm.xy*norm.xy); |
29 | 46 | ||
47 | dlt /= max(-pos.z*dist_factor, 1.0); | ||
48 | |||
30 | vec2 defined_weight = kern[0].xy; // special case the first (centre) sample's weight in the blur; we have to sample it anyway so we get it for 'free' | 49 | vec2 defined_weight = kern[0].xy; // special case the first (centre) sample's weight in the blur; we have to sample it anyway so we get it for 'free' |
31 | vec2 col = defined_weight * ccol; | 50 | vec4 col = defined_weight.xyxx * ccol; |
32 | 51 | ||
33 | for (int i = 1; i < kern_length; i++) | 52 | for (int i = 1; i < kern_length; i++) |
34 | { | 53 | { |
35 | vec2 tc = vary_fragcoord.xy + kern[i].z*dlt; | 54 | vec2 tc = vary_fragcoord.xy + kern[i].z*dlt; |
36 | vec3 samppos = texture2DRect(positionMap, tc).xyz; | 55 | vec3 samppos = getPosition(tc).xyz; |
37 | float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane | 56 | float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane |
38 | if (d*d <= 0.003) | 57 | if (d*d <= 0.003) |
39 | { | 58 | { |
40 | col += texture2DRect(lightMap, tc).rg*kern[i].xy; | 59 | col += texture2DRect(lightMap, tc)*kern[i].xyxx; |
41 | defined_weight += kern[i].xy; | 60 | defined_weight += kern[i].xy; |
42 | } | 61 | } |
43 | } | 62 | } |
44 | 63 | ||
45 | col /= defined_weight; | ||
46 | 64 | ||
47 | gl_FragColor = vec4(col.r, col.g, 0.0, 1.0); | 65 | |
66 | col /= defined_weight.xyxx; | ||
67 | |||
68 | gl_FragColor = col; | ||
69 | |||
70 | //gl_FragColor = ccol; | ||
48 | } | 71 | } |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl index a8712bc..1c29dae 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl | |||
@@ -11,7 +11,6 @@ uniform sampler2D bumpMap; | |||
11 | varying vec3 vary_mat0; | 11 | varying vec3 vary_mat0; |
12 | varying vec3 vary_mat1; | 12 | varying vec3 vary_mat1; |
13 | varying vec3 vary_mat2; | 13 | varying vec3 vary_mat2; |
14 | varying vec4 vary_position; | ||
15 | 14 | ||
16 | void main() | 15 | void main() |
17 | { | 16 | { |
@@ -22,8 +21,7 @@ void main() | |||
22 | dot(norm,vary_mat1), | 21 | dot(norm,vary_mat1), |
23 | dot(norm,vary_mat2)); | 22 | dot(norm,vary_mat2)); |
24 | 23 | ||
25 | gl_FragData[0].rgb = gl_Color.rgb*col; | 24 | gl_FragData[0] = vec4(gl_Color.rgb*col, 0.0); |
26 | gl_FragData[1] = vec4(col*(gl_Color.a*1.5), gl_Color.a); | 25 | gl_FragData[1] = vec4(col*gl_Color.a, gl_Color.a); |
27 | gl_FragData[2] = vec4(normalize(tnorm), 0.0); | 26 | gl_FragData[2] = vec4(normalize(tnorm)*0.5+0.5, 0.0); |
28 | gl_FragData[3] = vary_position; | ||
29 | } | 27 | } |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl index ba18092..9589912 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl | |||
@@ -8,7 +8,6 @@ | |||
8 | varying vec3 vary_mat0; | 8 | varying vec3 vary_mat0; |
9 | varying vec3 vary_mat1; | 9 | varying vec3 vary_mat1; |
10 | varying vec3 vary_mat2; | 10 | varying vec3 vary_mat2; |
11 | varying vec4 vary_position; | ||
12 | 11 | ||
13 | void main() | 12 | void main() |
14 | { | 13 | { |
@@ -16,8 +15,6 @@ void main() | |||
16 | gl_Position = ftransform(); | 15 | gl_Position = ftransform(); |
17 | gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; | 16 | gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; |
18 | 17 | ||
19 | vary_position = gl_ModelViewMatrix * gl_Vertex; | ||
20 | |||
21 | vec3 n = normalize(gl_NormalMatrix * gl_Normal); | 18 | vec3 n = normalize(gl_NormalMatrix * gl_Normal); |
22 | vec3 b = normalize(gl_NormalMatrix * gl_MultiTexCoord2.xyz); | 19 | vec3 b = normalize(gl_NormalMatrix * gl_MultiTexCoord2.xyz); |
23 | vec3 t = cross(b, n); | 20 | vec3 t = cross(b, n); |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl index f2ba2df..919dd5d 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl | |||
@@ -8,13 +8,11 @@ | |||
8 | uniform sampler2D diffuseMap; | 8 | uniform sampler2D diffuseMap; |
9 | 9 | ||
10 | varying vec3 vary_normal; | 10 | varying vec3 vary_normal; |
11 | varying vec4 vary_position; | ||
12 | 11 | ||
13 | void main() | 12 | void main() |
14 | { | 13 | { |
15 | vec3 col = texture2D(diffuseMap, gl_TexCoord[0].xy).rgb; | 14 | vec3 col = texture2D(diffuseMap, gl_TexCoord[0].xy).rgb; |
16 | gl_FragData[0] = vec4(gl_Color.rgb*col, 1.0); | 15 | gl_FragData[0] = vec4(gl_Color.rgb*col, 1.0); // KL viewer 2.0 has 0.0 but this is not working right yet besides i like to see my eyes :) |
17 | gl_FragData[1] = vec4(col*(gl_Color.a*1.5), gl_Color.a); | 16 | gl_FragData[1] = vec4(col*(gl_Color.a*1.5), gl_Color.a); |
18 | gl_FragData[2] = vec4(normalize(vary_normal), 0.0); | 17 | gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0); |
19 | gl_FragData[3] = vary_position; | ||
20 | } | 18 | } |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl index 3413a7f..44468cd 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl | |||
@@ -6,16 +6,13 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | varying vec3 vary_normal; | 8 | varying vec3 vary_normal; |
9 | varying vec4 vary_position; | ||
10 | 9 | ||
11 | void main() | 10 | void main() |
12 | { | 11 | { |
13 | //transform vertex | 12 | //transform vertex |
14 | gl_Position = ftransform(); | 13 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; |
15 | gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; | 14 | gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; |
16 | 15 | ||
17 | vary_position = gl_ModelViewMatrix * gl_Vertex; | ||
18 | |||
19 | vary_normal = normalize(gl_NormalMatrix * gl_Normal); | 16 | vary_normal = normalize(gl_NormalMatrix * gl_Normal); |
20 | 17 | ||
21 | gl_FrontColor = gl_Color; | 18 | gl_FrontColor = gl_Color; |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 2a811c5..e518bdd 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl | |||
@@ -8,14 +8,9 @@ | |||
8 | #extension GL_ARB_texture_rectangle : enable | 8 | #extension GL_ARB_texture_rectangle : enable |
9 | 9 | ||
10 | uniform sampler2D diffuseMap; | 10 | uniform sampler2D diffuseMap; |
11 | uniform sampler2DShadow shadowMap0; | 11 | uniform sampler2DRect depthMap; |
12 | uniform sampler2DShadow shadowMap1; | ||
13 | uniform sampler2DShadow shadowMap2; | ||
14 | uniform sampler2DShadow shadowMap3; | ||
15 | uniform sampler2D noiseMap; | 12 | uniform sampler2D noiseMap; |
16 | uniform sampler2DRect positionMap; | ||
17 | 13 | ||
18 | uniform mat4 shadow_matrix[4]; | ||
19 | uniform vec4 shadow_clip; | 14 | uniform vec4 shadow_clip; |
20 | uniform vec2 screen_res; | 15 | uniform vec2 screen_res; |
21 | 16 | ||
@@ -30,12 +25,27 @@ varying vec3 vary_fragcoord; | |||
30 | 25 | ||
31 | uniform float alpha_soften; | 26 | uniform float alpha_soften; |
32 | 27 | ||
28 | uniform mat4 inv_proj; | ||
29 | |||
30 | vec4 getPosition(vec2 pos_screen) | ||
31 | { | ||
32 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
33 | vec2 sc = pos_screen.xy*2.0; | ||
34 | sc /= screen_res; | ||
35 | sc -= vec2(1.0,1.0); | ||
36 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
37 | vec4 pos = inv_proj * ndc; | ||
38 | pos /= pos.w; | ||
39 | pos.w = 1.0; | ||
40 | return pos; | ||
41 | } | ||
42 | |||
33 | void main() | 43 | void main() |
34 | { | 44 | { |
35 | vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; | 45 | vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; |
36 | frag *= screen_res; | 46 | frag *= screen_res; |
37 | 47 | ||
38 | vec3 samp_pos = texture2DRect(positionMap, frag).xyz; | 48 | vec3 samp_pos = getPosition(frag).xyz; |
39 | 49 | ||
40 | float shadow = 1.0; | 50 | float shadow = 1.0; |
41 | vec4 pos = vary_position; | 51 | vec4 pos = vary_position; |
@@ -46,10 +56,10 @@ void main() | |||
46 | 56 | ||
47 | color.rgb = fullbrightScaleSoftClip(color.rgb); | 57 | color.rgb = fullbrightScaleSoftClip(color.rgb); |
48 | 58 | ||
49 | if (samp_pos.z != 0.0) | 59 | if (samp_pos.z != 0.0 && color.a < 1.0) |
50 | { | 60 | { |
51 | float dist_factor = alpha_soften; | 61 | float dist_factor = alpha_soften; |
52 | float a = gl_Color.a; | 62 | float a = color.a; |
53 | a *= a; | 63 | a *= a; |
54 | dist_factor *= 1.0/(1.0-a); | 64 | dist_factor *= 1.0/(1.0-a); |
55 | color.a *= min((pos.z-samp_pos.z)*dist_factor, 1.0); | 65 | color.a *= min((pos.z-samp_pos.z)*dist_factor, 1.0); |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl index 6381a1c..aff5117 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl | |||
@@ -12,12 +12,12 @@ vec3 atmosAffectDirectionalLight(float lightIntensity); | |||
12 | vec3 scaleDownLight(vec3 light); | 12 | vec3 scaleDownLight(vec3 light); |
13 | vec3 scaleUpLight(vec3 light); | 13 | vec3 scaleUpLight(vec3 light); |
14 | 14 | ||
15 | varying vec4 vary_position; | ||
16 | varying vec3 vary_ambient; | 15 | varying vec3 vary_ambient; |
17 | varying vec3 vary_directional; | 16 | varying vec3 vary_directional; |
18 | varying vec3 vary_normal; | 17 | varying vec3 vary_normal; |
19 | varying vec3 vary_fragcoord; | 18 | varying vec3 vary_fragcoord; |
20 | uniform float near_clip; | 19 | uniform float near_clip; |
20 | varying vec4 vary_position; | ||
21 | 21 | ||
22 | void main() | 22 | void main() |
23 | { | 23 | { |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/giF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/giF.glsl new file mode 100644 index 0000000..b351eec --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/giF.glsl | |||
@@ -0,0 +1,165 @@ | |||
1 | /** | ||
2 | * @file giF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | #extension GL_ARB_texture_rectangle : enable | ||
9 | |||
10 | uniform sampler2DRect depthMap; | ||
11 | uniform sampler2DRect normalMap; | ||
12 | uniform sampler2D noiseMap; | ||
13 | |||
14 | uniform sampler2D diffuseGIMap; | ||
15 | uniform sampler2D normalGIMap; | ||
16 | uniform sampler2D depthGIMap; | ||
17 | |||
18 | uniform sampler2D lightFunc; | ||
19 | |||
20 | // Inputs | ||
21 | varying vec2 vary_fragcoord; | ||
22 | |||
23 | uniform vec2 screen_res; | ||
24 | |||
25 | uniform mat4 inv_proj; | ||
26 | uniform mat4 gi_mat; //gPipeline.mGIMatrix - eye space to sun space | ||
27 | uniform mat4 gi_mat_proj; //gPipeline.mGIMatrixProj - eye space to projected sun space | ||
28 | uniform mat4 gi_norm_mat; //gPipeline.mGINormalMatrix - eye space normal to sun space normal matrix | ||
29 | uniform mat4 gi_inv_proj; //gPipeline.mGIInvProj - projected sun space to sun space | ||
30 | uniform float gi_radius; | ||
31 | uniform float gi_intensity; | ||
32 | uniform int gi_samples; | ||
33 | uniform vec2 gi_kern[25]; | ||
34 | uniform vec2 gi_scale; | ||
35 | uniform vec3 gi_quad; | ||
36 | uniform vec3 gi_spec; | ||
37 | uniform float gi_direction_weight; | ||
38 | uniform float gi_light_offset; | ||
39 | |||
40 | vec4 getPosition(vec2 pos_screen) | ||
41 | { | ||
42 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
43 | vec2 sc = pos_screen.xy*2.0; | ||
44 | sc /= screen_res; | ||
45 | sc -= vec2(1.0,1.0); | ||
46 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
47 | vec4 pos = inv_proj * ndc; | ||
48 | pos /= pos.w; | ||
49 | pos.w = 1.0; | ||
50 | return pos; | ||
51 | } | ||
52 | |||
53 | vec4 getGIPosition(vec2 gi_tc) | ||
54 | { | ||
55 | float depth = texture2D(depthGIMap, gi_tc).a; | ||
56 | vec2 sc = gi_tc*2.0; | ||
57 | sc -= vec2(1.0, 1.0); | ||
58 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
59 | vec4 pos = gi_inv_proj*ndc; | ||
60 | pos.xyz /= pos.w; | ||
61 | pos.w = 1.0; | ||
62 | return pos; | ||
63 | } | ||
64 | |||
65 | vec3 giAmbient(vec3 pos, vec3 norm) | ||
66 | { | ||
67 | vec4 gi_c = gi_mat_proj * vec4(pos, 1.0); | ||
68 | gi_c.xyz /= gi_c.w; | ||
69 | |||
70 | vec4 gi_pos = gi_mat*vec4(pos,1.0); | ||
71 | vec3 gi_norm = (gi_norm_mat*vec4(norm,1.0)).xyz; | ||
72 | gi_norm = normalize(gi_norm); | ||
73 | |||
74 | vec2 tcx = gi_norm.xy; | ||
75 | vec2 tcy = gi_norm.yx; | ||
76 | |||
77 | vec4 eye_pos = gi_mat*vec4(0,0,0,1.0); | ||
78 | |||
79 | vec3 eye_dir = normalize(gi_pos.xyz-eye_pos.xyz/eye_pos.w); | ||
80 | |||
81 | //vec3 eye_dir = vec3(0,0,-1); | ||
82 | //eye_dir = (gi_norm_mat*vec4(eye_dir, 1.0)).xyz; | ||
83 | //eye_dir = normalize(eye_dir); | ||
84 | |||
85 | //float round_x = gi_scale.x; | ||
86 | //float round_y = gi_scale.y; | ||
87 | |||
88 | vec3 debug = texture2D(normalGIMap, gi_c.xy).rgb*0.5+0.5; | ||
89 | debug.xz = vec2(0.0,0.0); | ||
90 | //debug = fract(debug); | ||
91 | |||
92 | float round_x = 1.0/64.0; | ||
93 | float round_y = 1.0/64.0; | ||
94 | |||
95 | //gi_c.x = floor(gi_c.x/round_x+0.5)*round_x; | ||
96 | //gi_c.y = floor(gi_c.y/round_y+0.5)*round_y; | ||
97 | |||
98 | float fda = 0.0; | ||
99 | vec3 fdiff = vec3(0,0,0); | ||
100 | |||
101 | vec3 rcol = vec3(0,0,0); | ||
102 | |||
103 | float fsa = 0.0; | ||
104 | |||
105 | for (int i = -1; i < 2; i+=2 ) | ||
106 | { | ||
107 | for (int j = -1; j < 2; j+=2) | ||
108 | { | ||
109 | vec2 tc = vec2(i, j)*0.75; | ||
110 | vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0+tc*0.5).xyz; | ||
111 | //tc += gi_norm.xy*nz.z; | ||
112 | tc += nz.xy*2.0; | ||
113 | tc /= gi_samples; | ||
114 | tc += gi_c.xy; | ||
115 | |||
116 | vec3 lnorm = -normalize(texture2D(normalGIMap, tc.xy).xyz*2.0-1.0); | ||
117 | vec3 lpos = getGIPosition(tc.xy).xyz; | ||
118 | |||
119 | vec3 at = lpos-gi_pos.xyz; | ||
120 | float dist = dot(at,at); | ||
121 | float da = clamp(1.0/(gi_spec.x*dist), 0.0, 1.0); | ||
122 | |||
123 | if (da > 0.0) | ||
124 | { | ||
125 | //add angular attenuation | ||
126 | vec3 ldir = at; | ||
127 | float ang_atten = clamp(dot(ldir, gi_norm), 0.0, 1.0); | ||
128 | |||
129 | float ld = -dot(ldir, lnorm); | ||
130 | |||
131 | if (ang_atten > 0.0 && ld < 0.0) | ||
132 | { | ||
133 | vec3 diff = texture2D(diffuseGIMap, tc.xy).xyz; | ||
134 | da = da*ang_atten; | ||
135 | fda += da; | ||
136 | fdiff += diff*da; | ||
137 | } | ||
138 | } | ||
139 | } | ||
140 | } | ||
141 | |||
142 | fdiff /= max(gi_spec.y*fda, gi_quad.z); | ||
143 | fdiff = clamp(fdiff, vec3(0), vec3(1)); | ||
144 | |||
145 | vec3 ret = fda*fdiff; | ||
146 | //ret = ret*ret*gi_quad.x+ret*gi_quad.y+gi_quad.z; | ||
147 | |||
148 | //fda *= nz.z; | ||
149 | |||
150 | //rcol.rgb *= gi_intensity; | ||
151 | //return rcol.rgb+vary_AmblitColor.rgb*0.25; | ||
152 | //return vec4(debug, 0.0); | ||
153 | //return vec4(fda*fdiff, 0.0); | ||
154 | return clamp(ret,vec3(0.0), vec3(1.0)); | ||
155 | //return debug.xyz; | ||
156 | } | ||
157 | |||
158 | void main() | ||
159 | { | ||
160 | vec2 pos_screen = vary_fragcoord.xy; | ||
161 | vec4 pos = getPosition(pos_screen); | ||
162 | vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0; | ||
163 | |||
164 | gl_FragData[0].xyz = giAmbient(pos, norm); | ||
165 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/giV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/giV.glsl new file mode 100644 index 0000000..71dcea9 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/giV.glsl | |||
@@ -0,0 +1,22 @@ | |||
1 | /** | ||
2 | * @file giV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | varying vec2 vary_fragcoord; | ||
9 | |||
10 | uniform vec2 screen_res; | ||
11 | |||
12 | void main() | ||
13 | { | ||
14 | //transform vertex | ||
15 | gl_Position = ftransform(); | ||
16 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
17 | vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res; | ||
18 | vec4 tex = gl_MultiTexCoord0; | ||
19 | tex.w = 1.0; | ||
20 | |||
21 | gl_FrontColor = gl_Color; | ||
22 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl new file mode 100644 index 0000000..e8b53b0 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl | |||
@@ -0,0 +1,15 @@ | |||
1 | /** | ||
2 | * @file luminanceF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2DRect diffuseMap; | ||
9 | |||
10 | varying vec2 vary_fragcoord; | ||
11 | |||
12 | void main() | ||
13 | { | ||
14 | gl_FragColor = texture2DRect(diffuseMap, vary_fragcoord.xy); | ||
15 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl new file mode 100644 index 0000000..db8775f --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl | |||
@@ -0,0 +1,20 @@ | |||
1 | /** | ||
2 | * @file giV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | varying vec2 vary_fragcoord; | ||
9 | |||
10 | uniform vec2 screen_res; | ||
11 | |||
12 | void main() | ||
13 | { | ||
14 | //transform vertex | ||
15 | gl_Position = ftransform(); | ||
16 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
17 | vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res; | ||
18 | |||
19 | gl_FrontColor = gl_Color; | ||
20 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl index 3689d12..ce0494c 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl | |||
@@ -7,13 +7,15 @@ | |||
7 | 7 | ||
8 | #extension GL_ARB_texture_rectangle : enable | 8 | #extension GL_ARB_texture_rectangle : enable |
9 | 9 | ||
10 | uniform sampler2DRect depthMap; | ||
10 | uniform sampler2DRect diffuseRect; | 11 | uniform sampler2DRect diffuseRect; |
11 | uniform sampler2DRect specularRect; | 12 | uniform sampler2DRect specularRect; |
12 | uniform sampler2DRect positionMap; | ||
13 | uniform sampler2DRect normalMap; | 13 | uniform sampler2DRect normalMap; |
14 | uniform samplerCube environmentMap; | 14 | uniform samplerCube environmentMap; |
15 | uniform sampler2DRect lightMap; | 15 | uniform sampler2DRect lightMap; |
16 | uniform sampler2D noiseMap; | 16 | uniform sampler2D noiseMap; |
17 | uniform sampler2D lightFunc; | ||
18 | |||
17 | 19 | ||
18 | uniform vec3 env_mat[3]; | 20 | uniform vec3 env_mat[3]; |
19 | uniform float sun_wash; | 21 | uniform float sun_wash; |
@@ -23,24 +25,48 @@ uniform int light_count; | |||
23 | uniform vec4 light[16]; | 25 | uniform vec4 light[16]; |
24 | uniform vec4 light_col[16]; | 26 | uniform vec4 light_col[16]; |
25 | 27 | ||
26 | varying vec3 vary_fragcoord; | 28 | varying vec4 vary_fragcoord; |
27 | uniform vec2 screen_res; | 29 | uniform vec2 screen_res; |
28 | 30 | ||
31 | uniform float far_z; | ||
32 | |||
33 | uniform mat4 inv_proj; | ||
34 | |||
35 | vec4 getPosition(vec2 pos_screen) | ||
36 | { | ||
37 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
38 | vec2 sc = pos_screen.xy*2.0; | ||
39 | sc /= screen_res; | ||
40 | sc -= vec2(1.0,1.0); | ||
41 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
42 | vec4 pos = inv_proj * ndc; | ||
43 | pos /= pos.w; | ||
44 | pos.w = 1.0; | ||
45 | return pos; | ||
46 | } | ||
47 | |||
29 | void main() | 48 | void main() |
30 | { | 49 | { |
31 | vec2 frag = (vary_fragcoord.xy*0.5+0.5)*screen_res; | 50 | vec2 frag = (vary_fragcoord.xy*0.5+0.5)*screen_res; |
32 | vec3 pos = texture2DRect(positionMap, frag.xy).xyz; | 51 | vec3 pos = getPosition(frag.xy).xyz; |
33 | vec3 norm = normalize(texture2DRect(normalMap, frag.xy).xyz); | 52 | if (pos.z < far_z) |
53 | { | ||
54 | discard; | ||
55 | } | ||
56 | |||
57 | vec3 norm = normalize(texture2DRect(normalMap, frag.xy).xyz*2.0-1.0); | ||
34 | vec4 spec = texture2DRect(specularRect, frag.xy); | 58 | vec4 spec = texture2DRect(specularRect, frag.xy); |
35 | vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb; | 59 | vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb; |
36 | float noise = texture2D(noiseMap, frag.xy/128.0).b; | 60 | float noise = texture2D(noiseMap, frag.xy/128.0).b; |
37 | vec3 out_col = vec3(0,0,0); | 61 | vec3 out_col = vec3(0,0,0); |
62 | vec3 npos = normalize(-pos); | ||
38 | 63 | ||
39 | for (int i = 0; i < light_count; ++i) | 64 | for (int i = 0; i < light_count; ++i) |
40 | { | 65 | { |
41 | vec3 lv = light[i].xyz-pos; | 66 | vec3 lv = light[i].xyz-pos; |
42 | float dist2 = dot(lv,lv); | 67 | float dist2 = dot(lv,lv); |
43 | if (dist2 > light[i].w) | 68 | dist2 /= light[i].w; |
69 | if (dist2 > 1.0) | ||
44 | { | 70 | { |
45 | continue; | 71 | continue; |
46 | } | 72 | } |
@@ -55,29 +81,41 @@ void main() | |||
55 | da = dot(norm, lv); | 81 | da = dot(norm, lv); |
56 | 82 | ||
57 | float fa = light_col[i].a+1.0; | 83 | float fa = light_col[i].a+1.0; |
58 | float dist_atten = clamp(1.0-(dist2-light[i].w*(1.0-fa))/(light[i].w*fa), 0.0, 1.0); | 84 | float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); |
59 | dist_atten *= noise; | 85 | dist_atten *= noise; |
60 | 86 | ||
61 | float lit = da * dist_atten; | 87 | float lit = da * dist_atten; |
62 | 88 | ||
63 | vec3 col = light_col[i].rgb*lit*diff; | 89 | vec3 col = light_col[i].rgb*lit*diff; |
90 | //vec3 col = vec3(dist2, light_col[i].a, lit); | ||
64 | 91 | ||
65 | if (spec.a > 0.0) | 92 | if (spec.a > 0.0) |
66 | { | 93 | { |
67 | vec3 ref = reflect(normalize(pos), norm); | 94 | //vec3 ref = dot(pos+lv, norm); |
68 | float sa = dot(ref,lv); | 95 | |
69 | sa = max(sa, 0.0); | 96 | float sa = dot(normalize(lv+npos),norm); |
70 | sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0); | 97 | |
71 | sa *= noise; | 98 | if (sa > 0) |
72 | col += da*sa*light_col[i].rgb*spec.rgb; | 99 | { |
100 | sa = texture2D(lightFunc,vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0); | ||
101 | sa *= noise; | ||
102 | col += da*sa*light_col[i].rgb*spec.rgb; | ||
103 | } | ||
73 | } | 104 | } |
74 | 105 | ||
75 | out_col += col; | 106 | out_col += col; |
76 | } | 107 | } |
77 | 108 | ||
109 | if (dot(out_col, out_col) <= 0.0) | ||
110 | { | ||
111 | discard; | ||
112 | } | ||
113 | |||
78 | //attenuate point light contribution by SSAO component | 114 | //attenuate point light contribution by SSAO component |
79 | out_col *= texture2DRect(lightMap, frag.xy).g; | 115 | out_col *= texture2DRect(lightMap, frag.xy).g; |
80 | 116 | ||
81 | gl_FragColor.rgb = out_col; | 117 | gl_FragColor.rgb = out_col; |
82 | gl_FragColor.a = 0.0; | 118 | gl_FragColor.a = 0.0; |
119 | |||
120 | //gl_FragColor = vec4(0.1, 0.025, 0.025/4.0, 0.0); | ||
83 | } | 121 | } |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl new file mode 100644 index 0000000..021e8a2 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl | |||
@@ -0,0 +1,184 @@ | |||
1 | /** | ||
2 | * @file multiSpotLightF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | #version 120 | ||
9 | |||
10 | #extension GL_ARB_texture_rectangle : enable | ||
11 | |||
12 | uniform sampler2DRect diffuseRect; | ||
13 | uniform sampler2DRect specularRect; | ||
14 | uniform sampler2DRect depthMap; | ||
15 | uniform sampler2DRect normalMap; | ||
16 | uniform samplerCube environmentMap; | ||
17 | uniform sampler2DRect lightMap; | ||
18 | uniform sampler2D noiseMap; | ||
19 | uniform sampler2D lightFunc; | ||
20 | uniform sampler2D projectionMap; | ||
21 | |||
22 | uniform mat4 proj_mat; //screen space to light space | ||
23 | uniform float proj_near; //near clip for projection | ||
24 | uniform vec3 proj_p; //plane projection is emitting from (in screen space) | ||
25 | uniform vec3 proj_n; | ||
26 | uniform float proj_focus; //distance from plane to begin blurring | ||
27 | uniform float proj_lod; //(number of mips in proj map) | ||
28 | uniform float proj_range; //range between near clip and far clip plane of projection | ||
29 | uniform float proj_ambient_lod; | ||
30 | uniform float proj_ambiance; | ||
31 | uniform float near_clip; | ||
32 | uniform float far_clip; | ||
33 | |||
34 | uniform vec3 proj_origin; //origin of projection to be used for angular attenuation | ||
35 | uniform float sun_wash; | ||
36 | uniform int proj_shadow_idx; | ||
37 | uniform float shadow_fade; | ||
38 | |||
39 | varying vec4 vary_light; | ||
40 | |||
41 | varying vec4 vary_fragcoord; | ||
42 | uniform vec2 screen_res; | ||
43 | |||
44 | uniform mat4 inv_proj; | ||
45 | |||
46 | vec4 getPosition(vec2 pos_screen) | ||
47 | { | ||
48 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
49 | vec2 sc = pos_screen.xy*2.0; | ||
50 | sc /= screen_res; | ||
51 | sc -= vec2(1.0,1.0); | ||
52 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
53 | vec4 pos = inv_proj * ndc; | ||
54 | pos /= pos.w; | ||
55 | pos.w = 1.0; | ||
56 | return pos; | ||
57 | } | ||
58 | |||
59 | void main() | ||
60 | { | ||
61 | vec4 frag = vary_fragcoord; | ||
62 | frag.xyz /= frag.w; | ||
63 | frag.xyz = frag.xyz*0.5+0.5; | ||
64 | frag.xy *= screen_res; | ||
65 | |||
66 | vec3 pos = getPosition(frag.xy).xyz; | ||
67 | vec3 lv = vary_light.xyz-pos.xyz; | ||
68 | float dist2 = dot(lv,lv); | ||
69 | dist2 /= vary_light.w; | ||
70 | if (dist2 > 1.0) | ||
71 | { | ||
72 | discard; | ||
73 | } | ||
74 | |||
75 | float shadow = 1.0; | ||
76 | |||
77 | if (proj_shadow_idx >= 0) | ||
78 | { | ||
79 | vec4 shd = texture2DRect(lightMap, frag.xy); | ||
80 | float sh[2]; | ||
81 | sh[0] = shd.b; | ||
82 | sh[1] = shd.a; | ||
83 | shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0); | ||
84 | } | ||
85 | |||
86 | vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0; | ||
87 | |||
88 | norm = normalize(norm); | ||
89 | float l_dist = -dot(lv, proj_n); | ||
90 | |||
91 | vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0)); | ||
92 | if (proj_tc.z < 0.0) | ||
93 | { | ||
94 | discard; | ||
95 | } | ||
96 | |||
97 | proj_tc.xyz /= proj_tc.w; | ||
98 | |||
99 | float fa = gl_Color.a+1.0; | ||
100 | float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); | ||
101 | |||
102 | lv = proj_origin-pos.xyz; | ||
103 | lv = normalize(lv); | ||
104 | float da = dot(norm, lv); | ||
105 | |||
106 | vec3 col = vec3(0,0,0); | ||
107 | |||
108 | vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; | ||
109 | |||
110 | float noise = texture2D(noiseMap, frag.xy/128.0).b; | ||
111 | if (proj_tc.z > 0.0 && | ||
112 | proj_tc.x < 1.0 && | ||
113 | proj_tc.y < 1.0 && | ||
114 | proj_tc.x > 0.0 && | ||
115 | proj_tc.y > 0.0) | ||
116 | { | ||
117 | float lit = 0.0; | ||
118 | float amb_da = proj_ambiance; | ||
119 | |||
120 | if (da > 0.0) | ||
121 | { | ||
122 | float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0); | ||
123 | float lod = diff * proj_lod; | ||
124 | |||
125 | vec4 plcol = texture2DLod(projectionMap, proj_tc.xy, lod); | ||
126 | |||
127 | vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a; | ||
128 | |||
129 | lit = da * dist_atten * noise; | ||
130 | |||
131 | col = lcol*lit*diff_tex*shadow; | ||
132 | amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; | ||
133 | } | ||
134 | |||
135 | //float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0); | ||
136 | vec4 amb_plcol = texture2DLod(projectionMap, proj_tc.xy, proj_ambient_lod); | ||
137 | |||
138 | amb_da += (da*da*0.5+0.5)*proj_ambiance; | ||
139 | |||
140 | amb_da *= dist_atten * noise; | ||
141 | |||
142 | amb_da = min(amb_da, 1.0-lit); | ||
143 | |||
144 | col += amb_da*gl_Color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; | ||
145 | } | ||
146 | |||
147 | |||
148 | vec4 spec = texture2DRect(specularRect, frag.xy); | ||
149 | if (spec.a > 0.0) | ||
150 | { | ||
151 | vec3 ref = reflect(normalize(pos), norm); | ||
152 | |||
153 | //project from point pos in direction ref to plane proj_p, proj_n | ||
154 | vec3 pdelta = proj_p-pos; | ||
155 | float ds = dot(ref, proj_n); | ||
156 | |||
157 | if (ds < 0.0) | ||
158 | { | ||
159 | vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds; | ||
160 | |||
161 | vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0)); | ||
162 | |||
163 | if (stc.z > 0.0) | ||
164 | { | ||
165 | stc.xy /= stc.w; | ||
166 | |||
167 | if (stc.x < 1.0 && | ||
168 | stc.y < 1.0 && | ||
169 | stc.x > 0.0 && | ||
170 | stc.y > 0.0) | ||
171 | { | ||
172 | vec4 scol = texture2DLod(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); | ||
173 | col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb*shadow; | ||
174 | } | ||
175 | } | ||
176 | } | ||
177 | } | ||
178 | |||
179 | //attenuate point light contribution by SSAO component | ||
180 | col *= texture2DRect(lightMap, frag.xy).g; | ||
181 | |||
182 | gl_FragColor.rgb = col; | ||
183 | gl_FragColor.a = 0.0; | ||
184 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index 52bad1f..d8ccfd4 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl | |||
@@ -9,33 +9,54 @@ | |||
9 | 9 | ||
10 | uniform sampler2DRect diffuseRect; | 10 | uniform sampler2DRect diffuseRect; |
11 | uniform sampler2DRect specularRect; | 11 | uniform sampler2DRect specularRect; |
12 | uniform sampler2DRect positionMap; | ||
13 | uniform sampler2DRect normalMap; | 12 | uniform sampler2DRect normalMap; |
14 | uniform samplerCube environmentMap; | 13 | uniform samplerCube environmentMap; |
15 | uniform sampler2DRect lightMap; | 14 | uniform sampler2DRect lightMap; |
16 | uniform sampler2D noiseMap; | 15 | uniform sampler2D noiseMap; |
16 | uniform sampler2D lightFunc; | ||
17 | uniform sampler2DRect depthMap; | ||
17 | 18 | ||
18 | uniform vec3 env_mat[3]; | 19 | uniform vec3 env_mat[3]; |
19 | uniform float sun_wash; | 20 | uniform float sun_wash; |
20 | 21 | ||
21 | varying vec4 vary_light; | 22 | varying vec4 vary_light; |
22 | 23 | ||
23 | varying vec3 vary_fragcoord; | 24 | varying vec4 vary_fragcoord; |
24 | uniform vec2 screen_res; | 25 | uniform vec2 screen_res; |
25 | 26 | ||
27 | uniform mat4 inv_proj; | ||
28 | uniform vec4 viewport; | ||
29 | |||
30 | vec4 getPosition(vec2 pos_screen) | ||
31 | { | ||
32 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
33 | vec2 sc = (pos_screen.xy-viewport.xy)*2.0; | ||
34 | sc /= viewport.zw; | ||
35 | sc -= vec2(1.0,1.0); | ||
36 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
37 | vec4 pos = inv_proj * ndc; | ||
38 | pos /= pos.w; | ||
39 | pos.w = 1.0; | ||
40 | return pos; | ||
41 | } | ||
42 | |||
26 | void main() | 43 | void main() |
27 | { | 44 | { |
28 | vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; | 45 | vec4 frag = vary_fragcoord; |
29 | frag *= screen_res; | 46 | frag.xyz /= frag.w; |
30 | vec3 pos = texture2DRect(positionMap, frag).xyz; | 47 | frag.xyz = frag.xyz*0.5+0.5; |
48 | frag.xy *= screen_res; | ||
49 | |||
50 | vec3 pos = getPosition(frag.xy).xyz; | ||
31 | vec3 lv = vary_light.xyz-pos; | 51 | vec3 lv = vary_light.xyz-pos; |
32 | float dist2 = dot(lv,lv); | 52 | float dist2 = dot(lv,lv); |
33 | if (dist2 > vary_light.w) | 53 | dist2 /= vary_light.w; |
54 | if (dist2 > 1.0) | ||
34 | { | 55 | { |
35 | discard; | 56 | discard; |
36 | } | 57 | } |
37 | 58 | ||
38 | vec3 norm = texture2DRect(normalMap, frag).xyz; | 59 | vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0; |
39 | float da = dot(norm, lv); | 60 | float da = dot(norm, lv); |
40 | if (da < 0.0) | 61 | if (da < 0.0) |
41 | { | 62 | { |
@@ -46,24 +67,30 @@ void main() | |||
46 | lv = normalize(lv); | 67 | lv = normalize(lv); |
47 | da = dot(norm, lv); | 68 | da = dot(norm, lv); |
48 | 69 | ||
49 | float noise = texture2D(noiseMap, frag/128.0).b; | 70 | float noise = texture2D(noiseMap, frag.xy/128.0).b; |
50 | 71 | ||
51 | vec3 col = texture2DRect(diffuseRect, frag).rgb; | 72 | vec3 col = texture2DRect(diffuseRect, frag.xy).rgb; |
52 | float fa = gl_Color.a+1.0; | 73 | float fa = gl_Color.a+1.0; |
53 | float dist_atten = clamp(1.0-(dist2-vary_light.w*(1.0-fa))/(vary_light.w*fa), 0.0, 1.0); | 74 | float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); |
54 | float lit = da * dist_atten * noise; | 75 | float lit = da * dist_atten * noise; |
55 | 76 | ||
56 | col = gl_Color.rgb*lit*col; | 77 | col = gl_Color.rgb*lit*col; |
57 | 78 | ||
58 | vec4 spec = texture2DRect(specularRect, frag); | 79 | vec4 spec = texture2DRect(specularRect, frag.xy); |
59 | if (spec.a > 0.0) | 80 | if (spec.a > 0.0) |
60 | { | 81 | { |
61 | vec3 ref = reflect(normalize(pos), norm); | 82 | float sa = dot(normalize(lv-normalize(pos)),norm); |
62 | float sa = dot(ref,lv); | 83 | if (sa > 0.0) |
63 | sa = max(sa, 0.0); | 84 | { |
64 | sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0); | 85 | sa = texture2D(lightFunc, vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0); |
65 | sa *= noise; | 86 | sa *= noise; |
66 | col += da*sa*gl_Color.rgb*spec.rgb; | 87 | col += da*sa*gl_Color.rgb*spec.rgb; |
88 | } | ||
89 | } | ||
90 | |||
91 | if (dot(col, col) <= 0.0) | ||
92 | { | ||
93 | discard; | ||
67 | } | 94 | } |
68 | 95 | ||
69 | //attenuate point light contribution by SSAO component | 96 | //attenuate point light contribution by SSAO component |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl index a4edb88..e815ca2 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl | |||
@@ -6,7 +6,7 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | varying vec4 vary_light; | 8 | varying vec4 vary_light; |
9 | varying vec3 vary_fragcoord; | 9 | varying vec4 vary_fragcoord; |
10 | 10 | ||
11 | uniform vec2 screen_res; | 11 | uniform vec2 screen_res; |
12 | uniform float near_clip; | 12 | uniform float near_clip; |
@@ -14,10 +14,10 @@ uniform float near_clip; | |||
14 | void main() | 14 | void main() |
15 | { | 15 | { |
16 | //transform vertex | 16 | //transform vertex |
17 | gl_Position = ftransform(); | 17 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; |
18 | 18 | ||
19 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | 19 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; |
20 | vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); | 20 | vary_fragcoord = pos; |
21 | 21 | ||
22 | vec4 tex = gl_MultiTexCoord0; | 22 | vec4 tex = gl_MultiTexCoord0; |
23 | tex.w = 1.0; | 23 | tex.w = 1.0; |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl new file mode 100644 index 0000000..71de036 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl | |||
@@ -0,0 +1,57 @@ | |||
1 | /** | ||
2 | * @file postDeferredF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | #extension GL_ARB_texture_rectangle : enable | ||
9 | |||
10 | uniform sampler2DRect diffuseRect; | ||
11 | uniform sampler2DRect localLightMap; | ||
12 | uniform sampler2DRect sunLightMap; | ||
13 | uniform sampler2DRect giLightMap; | ||
14 | uniform sampler2D luminanceMap; | ||
15 | uniform sampler2DRect lightMap; | ||
16 | |||
17 | uniform vec3 lum_quad; | ||
18 | uniform float lum_lod; | ||
19 | uniform vec4 ambient; | ||
20 | |||
21 | uniform vec3 gi_quad; | ||
22 | |||
23 | uniform vec2 screen_res; | ||
24 | varying vec2 vary_fragcoord; | ||
25 | |||
26 | void main() | ||
27 | { | ||
28 | vec2 tc = vary_fragcoord.xy; | ||
29 | vec3 lum = texture2DLod(luminanceMap, tc/screen_res, lum_lod).rgb; | ||
30 | float luminance = lum.r; | ||
31 | luminance = luminance*lum_quad.y+lum_quad.z; | ||
32 | |||
33 | vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy); | ||
34 | |||
35 | float ambocc = texture2DRect(lightMap, vary_fragcoord.xy).g; | ||
36 | |||
37 | vec3 gi_col = texture2DRect(giLightMap, vary_fragcoord.xy).rgb; | ||
38 | gi_col = gi_col*gi_col*gi_quad.x + gi_col*gi_quad.y+gi_quad.z*ambocc*ambient.rgb; | ||
39 | gi_col *= diff; | ||
40 | |||
41 | vec4 sun_col = texture2DRect(sunLightMap, vary_fragcoord.xy); | ||
42 | |||
43 | vec3 local_col = texture2DRect(localLightMap, vary_fragcoord.xy).rgb; | ||
44 | |||
45 | |||
46 | sun_col *= 1.0/min(luminance, 1.0); | ||
47 | gi_col *= 1.0/luminance; | ||
48 | |||
49 | vec3 col = sun_col.rgb+gi_col+local_col; | ||
50 | |||
51 | gl_FragColor.rgb = col.rgb; | ||
52 | col.rgb = max(col.rgb-vec3(1.0,1.0,1.0), vec3(0.0, 0.0, 0.0)); | ||
53 | |||
54 | gl_FragColor.a = 0.0; // max(dot(col.rgb,col.rgb)*lum_quad.x, sun_col.a); | ||
55 | |||
56 | //gl_FragColor.rgb = vec3(lum_lod); | ||
57 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl new file mode 100644 index 0000000..9819232 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl | |||
@@ -0,0 +1,17 @@ | |||
1 | /** | ||
2 | * @file postDeferredV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | varying vec2 vary_fragcoord; | ||
9 | uniform vec2 screen_res; | ||
10 | |||
11 | void main() | ||
12 | { | ||
13 | //transform vertex | ||
14 | gl_Position = ftransform(); | ||
15 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
16 | vary_fragcoord = (pos.xy*0.5+0.5)*screen_res; | ||
17 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl new file mode 100644 index 0000000..3556c7b --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl | |||
@@ -0,0 +1,107 @@ | |||
1 | /** | ||
2 | * @file postgiF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | uniform sampler2D diffuseGIMap; | ||
9 | uniform sampler2D normalGIMap; | ||
10 | uniform sampler2D depthGIMap; | ||
11 | uniform sampler2D diffuseMap; | ||
12 | |||
13 | uniform sampler2D lastDiffuseGIMap; | ||
14 | uniform sampler2D lastNormalGIMap; | ||
15 | uniform sampler2D lastMinpGIMap; | ||
16 | uniform sampler2D lastMaxpGIMap; | ||
17 | |||
18 | uniform float gi_blend; | ||
19 | |||
20 | uniform mat4 gi_mat; //gPipeline.mGIMatrix - eye space to sun space | ||
21 | uniform mat4 gi_mat_proj; //gPipeline.mGIMatrixProj - eye space to projected sun space | ||
22 | uniform mat4 gi_norm_mat; //gPipeline.mGINormalMatrix - eye space normal to sun space normal matrix | ||
23 | uniform mat4 gi_inv_proj; //gPipeline.mGIInvProj - projected sun space to sun space | ||
24 | uniform float gi_radius; | ||
25 | uniform float gi_intensity; | ||
26 | uniform vec2 gi_kern[16]; | ||
27 | uniform vec2 gi_scale; | ||
28 | |||
29 | |||
30 | vec4 getGIPosition(vec2 gi_tc) | ||
31 | { | ||
32 | float depth = texture2D(depthGIMap, gi_tc).a; | ||
33 | vec2 sc = gi_tc*2.0; | ||
34 | sc -= vec2(1.0, 1.0); | ||
35 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
36 | vec4 pos = gi_inv_proj*ndc; | ||
37 | pos.xyz /= pos.w; | ||
38 | pos.w = 1.0; | ||
39 | return pos; | ||
40 | } | ||
41 | |||
42 | |||
43 | void main() | ||
44 | { | ||
45 | vec2 c_tc = gl_TexCoord[0].xy; | ||
46 | |||
47 | vec3 diff = vec3(0,0,0); | ||
48 | vec3 minp = vec3(1024,1024,1024); | ||
49 | vec3 maxp = vec3(-1024,-1024,-1024); | ||
50 | vec3 norm = vec3(0,0,0); | ||
51 | |||
52 | float dweight = 0.0; | ||
53 | |||
54 | vec3 cnorm = normalize(texture2D(normalGIMap, c_tc).rgb*2.0-1.0); | ||
55 | |||
56 | vec3 cpos = vec3(0,0,0); | ||
57 | float tweight = 0.0; | ||
58 | |||
59 | for (int i = 0; i < 8; ++i) | ||
60 | { | ||
61 | for (int j = 0; j < 8; ++j) | ||
62 | { | ||
63 | vec2 tc = vec2(i-4+0.5, j-4+0.5); | ||
64 | float weight = 1.0-length(tc)/6.0; | ||
65 | tc *= 1.0/(256.0); | ||
66 | tc += c_tc; | ||
67 | |||
68 | vec3 n = texture2D(normalGIMap, tc).rgb*2.0-1.0; | ||
69 | tweight += weight; | ||
70 | |||
71 | diff += weight*texture2D(diffuseGIMap, tc).rgb; | ||
72 | |||
73 | norm += n*weight; | ||
74 | |||
75 | dweight += dot(n, cnorm); | ||
76 | |||
77 | vec3 pos = getGIPosition(tc).xyz; | ||
78 | cpos += pos*weight; | ||
79 | |||
80 | minp = min(pos, minp); | ||
81 | maxp = max(pos, maxp); | ||
82 | } | ||
83 | } | ||
84 | |||
85 | dweight = abs(1.0-dweight/64.0); | ||
86 | float mind = min(sqrt(dweight+0.5), 1.0); | ||
87 | |||
88 | dweight *= dweight; | ||
89 | |||
90 | cpos /= tweight; | ||
91 | |||
92 | diff = clamp(diff/tweight, vec3(1.0/2.2), vec3(1,1,1)); | ||
93 | norm = normalize(norm); | ||
94 | maxp = cpos; | ||
95 | minp = vec3(dweight, mind, cpos.z-minp.z); | ||
96 | |||
97 | //float blend = 1.0; | ||
98 | //diff = mix(texture2D(lastDiffuseGIMap, c_tc).rgb, diff, blend); | ||
99 | //norm = mix(texture2D(lastNormalGIMap, c_tc).rgb, norm, blend); | ||
100 | //maxp = mix(texture2D(lastMaxpGIMap, c_tc).rgb, maxp, blend); | ||
101 | //minp = mix(texture2D(lastMinpGIMap, c_tc).rgb, minp, blend); | ||
102 | |||
103 | gl_FragData[0].rgb = diff; | ||
104 | gl_FragData[2].xyz = normalize(norm); | ||
105 | gl_FragData[1].xyz = maxp; | ||
106 | gl_FragData[3].xyz = minp; | ||
107 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl new file mode 100644 index 0000000..5a8eb65 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl | |||
@@ -0,0 +1,16 @@ | |||
1 | /** | ||
2 | * @file postgiV.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | varying vec3 vary_normal; | ||
9 | |||
10 | void main() | ||
11 | { | ||
12 | //transform vertex | ||
13 | vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
14 | gl_Position = pos; | ||
15 | gl_TexCoord[0].xy = pos.xy*0.5+0.5; | ||
16 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl index b3758c3..b0b31fd 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl | |||
@@ -7,8 +7,11 @@ | |||
7 | 7 | ||
8 | uniform sampler2D diffuseMap; | 8 | uniform sampler2D diffuseMap; |
9 | 9 | ||
10 | varying vec4 post_pos; | ||
10 | 11 | ||
11 | void main() | 12 | void main() |
12 | { | 13 | { |
13 | gl_FragColor = vec4(1,1,1,texture2D(diffuseMap, gl_TexCoord[0].xy).a * gl_Color.a); | 14 | gl_FragColor = vec4(1,1,1,texture2D(diffuseMap, gl_TexCoord[0].xy).a * gl_Color.a); |
15 | |||
16 | gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); | ||
14 | } | 17 | } |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl index aae1bee..7214d24 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl | |||
@@ -5,13 +5,17 @@ | |||
5 | * $License$ | 5 | * $License$ |
6 | */ | 6 | */ |
7 | 7 | ||
8 | varying vec4 post_pos; | ||
9 | |||
8 | void main() | 10 | void main() |
9 | { | 11 | { |
10 | //transform vertex | 12 | //transform vertex |
11 | vec4 pos = gl_ModelViewProjectionMatrix*gl_Vertex; | 13 | vec4 pos = gl_ModelViewProjectionMatrix*gl_Vertex; |
12 | //smash geometry against the near clip plane (great for ortho projections) | 14 | |
13 | pos.z = max(pos.z, -1.0); | 15 | post_pos = pos; |
14 | gl_Position = pos; | 16 | |
17 | gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); | ||
18 | |||
15 | gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; | 19 | gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; |
16 | gl_FrontColor = gl_Color; | 20 | gl_FrontColor = gl_Color; |
17 | } | 21 | } |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index d5671a6..64e263a 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl | |||
@@ -272,8 +272,4 @@ void main() | |||
272 | 272 | ||
273 | gl_FragColor.rgb = col; | 273 | gl_FragColor.rgb = col; |
274 | gl_FragColor.a = 0.0; | 274 | gl_FragColor.a = 0.0; |
275 | //gl_FragColor.rg = scol_ambocc.rg; | ||
276 | //gl_FragColor.rgb = norm.rgb*0.5+0.5; | ||
277 | //gl_FragColor.rgb = vec3(ambocc); | ||
278 | //gl_FragColor.rgb = vec3(scol); | ||
279 | } | 275 | } |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl new file mode 100644 index 0000000..d653408 --- /dev/null +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl | |||
@@ -0,0 +1,199 @@ | |||
1 | /** | ||
2 | * @file spotLightF.glsl | ||
3 | * | ||
4 | * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. | ||
5 | * $License$ | ||
6 | */ | ||
7 | |||
8 | #version 120 | ||
9 | |||
10 | #extension GL_ARB_texture_rectangle : enable | ||
11 | |||
12 | uniform sampler2DRect diffuseRect; | ||
13 | uniform sampler2DRect specularRect; | ||
14 | uniform sampler2DRect depthMap; | ||
15 | uniform sampler2DRect normalMap; | ||
16 | uniform samplerCube environmentMap; | ||
17 | uniform sampler2DRect lightMap; | ||
18 | uniform sampler2D noiseMap; | ||
19 | uniform sampler2D lightFunc; | ||
20 | uniform sampler2D projectionMap; | ||
21 | |||
22 | uniform mat4 proj_mat; //screen space to light space | ||
23 | uniform float proj_near; //near clip for projection | ||
24 | uniform vec3 proj_p; //plane projection is emitting from (in screen space) | ||
25 | uniform vec3 proj_n; | ||
26 | uniform float proj_focus; //distance from plane to begin blurring | ||
27 | uniform float proj_lod; //(number of mips in proj map) | ||
28 | uniform float proj_range; //range between near clip and far clip plane of projection | ||
29 | uniform float proj_ambiance; | ||
30 | uniform float near_clip; | ||
31 | uniform float far_clip; | ||
32 | |||
33 | uniform vec3 proj_origin; //origin of projection to be used for angular attenuation | ||
34 | uniform float sun_wash; | ||
35 | uniform int proj_shadow_idx; | ||
36 | uniform float shadow_fade; | ||
37 | |||
38 | varying vec4 vary_light; | ||
39 | |||
40 | varying vec4 vary_fragcoord; | ||
41 | uniform vec2 screen_res; | ||
42 | |||
43 | uniform mat4 inv_proj; | ||
44 | |||
45 | vec4 getPosition(vec2 pos_screen) | ||
46 | { | ||
47 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
48 | vec2 sc = pos_screen.xy*2.0; | ||
49 | sc /= screen_res; | ||
50 | sc -= vec2(1.0,1.0); | ||
51 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
52 | vec4 pos = inv_proj * ndc; | ||
53 | pos /= pos.w; | ||
54 | pos.w = 1.0; | ||
55 | return pos; | ||
56 | } | ||
57 | |||
58 | void main() | ||
59 | { | ||
60 | vec4 frag = vary_fragcoord; | ||
61 | frag.xyz /= frag.w; | ||
62 | frag.xyz = frag.xyz*0.5+0.5; | ||
63 | frag.xy *= screen_res; | ||
64 | |||
65 | float shadow = 1.0; | ||
66 | |||
67 | if (proj_shadow_idx >= 0) | ||
68 | { | ||
69 | vec4 shd = texture2DRect(lightMap, frag.xy); | ||
70 | float sh[2]; | ||
71 | sh[0] = shd.b; | ||
72 | sh[1] = shd.a; | ||
73 | shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0); | ||
74 | } | ||
75 | |||
76 | vec3 pos = getPosition(frag.xy).xyz; | ||
77 | vec3 lv = vary_light.xyz-pos.xyz; | ||
78 | float dist2 = dot(lv,lv); | ||
79 | dist2 /= vary_light.w; | ||
80 | if (dist2 > 1.0) | ||
81 | { | ||
82 | discard; | ||
83 | } | ||
84 | |||
85 | vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0; | ||
86 | |||
87 | norm = normalize(norm); | ||
88 | float l_dist = -dot(lv, proj_n); | ||
89 | |||
90 | vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0)); | ||
91 | if (proj_tc.z < 0.0) | ||
92 | { | ||
93 | discard; | ||
94 | } | ||
95 | |||
96 | proj_tc.xyz /= proj_tc.w; | ||
97 | |||
98 | float fa = gl_Color.a+1.0; | ||
99 | float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); | ||
100 | |||
101 | lv = proj_origin-pos.xyz; | ||
102 | lv = normalize(lv); | ||
103 | float da = dot(norm, lv); | ||
104 | |||
105 | vec3 col = vec3(0,0,0); | ||
106 | |||
107 | vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; | ||
108 | |||
109 | float noise = texture2D(noiseMap, frag.xy/128.0).b; | ||
110 | if (proj_tc.z > 0.0 && | ||
111 | proj_tc.x < 1.0 && | ||
112 | proj_tc.y < 1.0 && | ||
113 | proj_tc.x > 0.0 && | ||
114 | proj_tc.y > 0.0) | ||
115 | { | ||
116 | float lit = 0.0; | ||
117 | if (da > 0.0) | ||
118 | { | ||
119 | float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0); | ||
120 | float lod = diff * proj_lod; | ||
121 | |||
122 | vec4 plcol = texture2DLod(projectionMap, proj_tc.xy, lod); | ||
123 | |||
124 | vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a; | ||
125 | |||
126 | lit = da * dist_atten * noise; | ||
127 | |||
128 | col = lcol*lit*diff_tex*shadow; | ||
129 | } | ||
130 | |||
131 | float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0); | ||
132 | float lod = diff * proj_lod; | ||
133 | vec4 amb_plcol = texture2DLod(projectionMap, proj_tc.xy, lod); | ||
134 | //float amb_da = mix(proj_ambiance, proj_ambiance*max(-da, 0.0), max(da, 0.0)); | ||
135 | float amb_da = proj_ambiance; | ||
136 | if (da > 0.0) | ||
137 | { | ||
138 | amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; | ||
139 | } | ||
140 | |||
141 | amb_da += (da*da*0.5+0.5)*proj_ambiance; | ||
142 | |||
143 | amb_da *= dist_atten * noise; | ||
144 | |||
145 | amb_da = min(amb_da, 1.0-lit); | ||
146 | |||
147 | col += amb_da*gl_Color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; | ||
148 | } | ||
149 | |||
150 | |||
151 | vec4 spec = texture2DRect(specularRect, frag.xy); | ||
152 | if (spec.a > 0.0) | ||
153 | { | ||
154 | vec3 ref = reflect(normalize(pos), norm); | ||
155 | |||
156 | //project from point pos in direction ref to plane proj_p, proj_n | ||
157 | vec3 pdelta = proj_p-pos; | ||
158 | float ds = dot(ref, proj_n); | ||
159 | |||
160 | if (ds < 0.0) | ||
161 | { | ||
162 | vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds; | ||
163 | |||
164 | vec3 stc = (proj_mat * vec4(pfinal.xyz, 1.0)).xyz; | ||
165 | |||
166 | if (stc.z > 0.0) | ||
167 | { | ||
168 | stc.xy /= stc.z+proj_near; | ||
169 | |||
170 | if (stc.x < 1.0 && | ||
171 | stc.y < 1.0 && | ||
172 | stc.x > 0.0 && | ||
173 | stc.y > 0.0) | ||
174 | { | ||
175 | vec4 scol = texture2DLod(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); | ||
176 | col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb*shadow; | ||
177 | } | ||
178 | } | ||
179 | } | ||
180 | } | ||
181 | |||
182 | /*if (spec.a > 0.0) | ||
183 | { | ||
184 | //vec3 ref = reflect(normalize(pos), norm); | ||
185 | float sa = dot(normalize(lv-normalize(pos)),norm);; | ||
186 | //sa = max(sa, 0.0); | ||
187 | //sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0); | ||
188 | sa = texture2D(lightFunc, vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0); | ||
189 | sa *= noise; | ||
190 | col += da*sa*lcol*spec.rgb; | ||
191 | }*/ | ||
192 | |||
193 | //attenuate point light contribution by SSAO component | ||
194 | col *= texture2DRect(lightMap, frag.xy).g; | ||
195 | |||
196 | |||
197 | gl_FragColor.rgb = col; | ||
198 | gl_FragColor.a = 0.0; | ||
199 | } | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl index d43fe6c..22bdd2c 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl | |||
@@ -7,17 +7,21 @@ | |||
7 | 7 | ||
8 | #extension GL_ARB_texture_rectangle : enable | 8 | #extension GL_ARB_texture_rectangle : enable |
9 | 9 | ||
10 | uniform sampler2DRect positionMap; | ||
11 | uniform sampler2DRect normalMap; | ||
12 | uniform sampler2DRect depthMap; | 10 | uniform sampler2DRect depthMap; |
13 | uniform sampler2DShadow shadowMap0; | 11 | uniform sampler2DRect normalMap; |
14 | uniform sampler2DShadow shadowMap1; | 12 | uniform sampler2DRectShadow shadowMap0; |
15 | uniform sampler2DShadow shadowMap2; | 13 | uniform sampler2DRectShadow shadowMap1; |
16 | uniform sampler2DShadow shadowMap3; | 14 | uniform sampler2DRectShadow shadowMap2; |
15 | uniform sampler2DRectShadow shadowMap3; | ||
16 | uniform sampler2DRectShadow shadowMap4; | ||
17 | uniform sampler2DRectShadow shadowMap5; | ||
17 | uniform sampler2D noiseMap; | 18 | uniform sampler2D noiseMap; |
18 | 19 | ||
20 | uniform sampler2D lightFunc; | ||
21 | |||
22 | |||
19 | // Inputs | 23 | // Inputs |
20 | uniform mat4 shadow_matrix[4]; | 24 | uniform mat4 shadow_matrix[6]; |
21 | uniform vec4 shadow_clip; | 25 | uniform vec4 shadow_clip; |
22 | uniform float ssao_radius; | 26 | uniform float ssao_radius; |
23 | uniform float ssao_max_radius; | 27 | uniform float ssao_max_radius; |
@@ -27,6 +31,25 @@ uniform float ssao_factor_inv; | |||
27 | varying vec2 vary_fragcoord; | 31 | varying vec2 vary_fragcoord; |
28 | varying vec4 vary_light; | 32 | varying vec4 vary_light; |
29 | 33 | ||
34 | uniform mat4 inv_proj; | ||
35 | uniform vec2 screen_res; | ||
36 | |||
37 | uniform float shadow_bias; | ||
38 | uniform float shadow_offset; | ||
39 | |||
40 | vec4 getPosition(vec2 pos_screen) | ||
41 | { | ||
42 | float depth = texture2DRect(depthMap, pos_screen.xy).a; | ||
43 | vec2 sc = pos_screen.xy*2.0; | ||
44 | sc /= screen_res; | ||
45 | sc -= vec2(1.0,1.0); | ||
46 | vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); | ||
47 | vec4 pos = inv_proj * ndc; | ||
48 | pos /= pos.w; | ||
49 | pos.w = 1.0; | ||
50 | return pos; | ||
51 | } | ||
52 | |||
30 | //calculate decreases in ambient lighting when crowded out (SSAO) | 53 | //calculate decreases in ambient lighting when crowded out (SSAO) |
31 | float calcAmbientOcclusion(vec4 pos, vec3 norm) | 54 | float calcAmbientOcclusion(vec4 pos, vec3 norm) |
32 | { | 55 | { |
@@ -54,7 +77,7 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm) | |||
54 | for (int i = 0; i < 8; i++) | 77 | for (int i = 0; i < 8; i++) |
55 | { | 78 | { |
56 | vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect); | 79 | vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect); |
57 | vec3 samppos_world = texture2DRect(positionMap, samppos_screen).xyz; | 80 | vec3 samppos_world = getPosition(samppos_screen).xyz; |
58 | 81 | ||
59 | vec3 diff = pos_world - samppos_world; | 82 | vec3 diff = pos_world - samppos_world; |
60 | float dist2 = dot(diff, diff); | 83 | float dist2 = dot(diff, diff); |
@@ -74,14 +97,18 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm) | |||
74 | 97 | ||
75 | angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0); | 98 | angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0); |
76 | 99 | ||
77 | return 1.0 - (float(points != 0) * angle_hidden); | 100 | return (1.0 - (float(points != 0) * angle_hidden)); |
78 | } | 101 | } |
79 | 102 | ||
80 | void main() | 103 | void main() |
81 | { | 104 | { |
82 | vec2 pos_screen = vary_fragcoord.xy; | 105 | vec2 pos_screen = vary_fragcoord.xy; |
83 | vec4 pos = vec4(texture2DRect(positionMap, pos_screen).xyz, 1.0); | 106 | |
84 | vec3 norm = texture2DRect(normalMap, pos_screen).xyz; | 107 | //try doing an unproject here |
108 | |||
109 | vec4 pos = getPosition(pos_screen); | ||
110 | |||
111 | vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0; | ||
85 | 112 | ||
86 | /*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL | 113 | /*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL |
87 | { | 114 | { |
@@ -90,35 +117,45 @@ void main() | |||
90 | }*/ | 117 | }*/ |
91 | 118 | ||
92 | float shadow = 1.0; | 119 | float shadow = 1.0; |
93 | float dp_directional_light = max(0.0, dot(norm, vary_light.xyz)); | 120 | float dp_directional_light = max(0.0, dot(norm, vary_light.xyz)); |
94 | 121 | ||
122 | vec4 spos = vec4(pos.xyz + norm.xyz * (-pos.z/64.0*shadow_offset+shadow_bias), 1.0); | ||
123 | |||
124 | //vec3 debug = vec3(0,0,0); | ||
125 | |||
95 | if (dp_directional_light == 0.0) | 126 | if (dp_directional_light == 0.0) |
96 | { | 127 | { |
97 | // if we know this point is facing away from the sun then we know it's in shadow without having to do a squirrelly shadow-map lookup | 128 | // if we know this point is facing away from the sun then we know it's in shadow without having to do a squirrelly shadow-map lookup |
98 | shadow = 0.0; | 129 | shadow = 0.0; |
99 | } | 130 | } |
100 | else if (pos.z > -shadow_clip.w) | 131 | else if (spos.z > -shadow_clip.w) |
101 | { | 132 | { |
102 | if (pos.z < -shadow_clip.z) | 133 | vec4 lpos; |
134 | |||
135 | if (spos.z < -shadow_clip.z) | ||
103 | { | 136 | { |
104 | vec4 lpos = shadow_matrix[3]*pos; | 137 | lpos = shadow_matrix[3]*spos; |
105 | shadow = shadow2DProj(shadowMap3, lpos).x; | 138 | lpos.xy *= screen_res; |
139 | shadow = shadow2DRectProj(shadowMap3, lpos).x; | ||
106 | shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); | 140 | shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); |
107 | } | 141 | } |
108 | else if (pos.z < -shadow_clip.y) | 142 | else if (spos.z < -shadow_clip.y) |
109 | { | 143 | { |
110 | vec4 lpos = shadow_matrix[2]*pos; | 144 | lpos = shadow_matrix[2]*spos; |
111 | shadow = shadow2DProj(shadowMap2, lpos).x; | 145 | lpos.xy *= screen_res; |
146 | shadow = shadow2DRectProj(shadowMap2, lpos).x; | ||
112 | } | 147 | } |
113 | else if (pos.z < -shadow_clip.x) | 148 | else if (spos.z < -shadow_clip.x) |
114 | { | 149 | { |
115 | vec4 lpos = shadow_matrix[1]*pos; | 150 | lpos = shadow_matrix[1]*spos; |
116 | shadow = shadow2DProj(shadowMap1, lpos).x; | 151 | lpos.xy *= screen_res; |
152 | shadow = shadow2DRectProj(shadowMap1, lpos).x; | ||
117 | } | 153 | } |
118 | else | 154 | else |
119 | { | 155 | { |
120 | vec4 lpos = shadow_matrix[0]*pos; | 156 | lpos = shadow_matrix[0]*spos; |
121 | shadow = shadow2DProj(shadowMap0, lpos).x; | 157 | lpos.xy *= screen_res; |
158 | shadow = shadow2DRectProj(shadowMap0, lpos).x; | ||
122 | } | 159 | } |
123 | 160 | ||
124 | // take the most-shadowed value out of these two: | 161 | // take the most-shadowed value out of these two: |
@@ -126,6 +163,17 @@ void main() | |||
126 | // * an unblurred dot product between the sun and this norm | 163 | // * an unblurred dot product between the sun and this norm |
127 | // the goal is to err on the side of most-shadow to fill-in shadow holes and reduce artifacting | 164 | // the goal is to err on the side of most-shadow to fill-in shadow holes and reduce artifacting |
128 | shadow = min(shadow, dp_directional_light); | 165 | shadow = min(shadow, dp_directional_light); |
166 | |||
167 | /*debug.r = lpos.y / (lpos.w*screen_res.y); | ||
168 | |||
169 | lpos.xy /= lpos.w*32.0; | ||
170 | if (fract(lpos.x) < 0.1 || fract(lpos.y) < 0.1) | ||
171 | { | ||
172 | debug.gb = vec2(0.5, 0.5); | ||
173 | } | ||
174 | |||
175 | debug += (1.0-shadow)*0.5;*/ | ||
176 | |||
129 | } | 177 | } |
130 | else | 178 | else |
131 | { | 179 | { |
@@ -135,5 +183,18 @@ void main() | |||
135 | 183 | ||
136 | gl_FragColor[0] = shadow; | 184 | gl_FragColor[0] = shadow; |
137 | gl_FragColor[1] = calcAmbientOcclusion(pos, norm); | 185 | gl_FragColor[1] = calcAmbientOcclusion(pos, norm); |
138 | //gl_FragColor[2] is unused as of August 2008, may be used for debugging | 186 | |
187 | //spotlight shadow 1 | ||
188 | vec4 lpos = shadow_matrix[4]*spos; | ||
189 | lpos.xy *= screen_res; | ||
190 | gl_FragColor[2] = shadow2DRectProj(shadowMap4, lpos).x; | ||
191 | |||
192 | //spotlight shadow 2 | ||
193 | lpos = shadow_matrix[5]*spos; | ||
194 | lpos.xy *= screen_res; | ||
195 | gl_FragColor[3] = shadow2DRectProj(shadowMap5, lpos).x; | ||
196 | |||
197 | //gl_FragColor.rgb = pos.xyz; | ||
198 | //gl_FragColor.b = shadow; | ||
199 | //gl_FragColor.rgb = debug; | ||
139 | } | 200 | } |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl index 211b2e0..308b9b1 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl | |||
@@ -12,7 +12,6 @@ uniform sampler2D detail_3; | |||
12 | uniform sampler2D alpha_ramp; | 12 | uniform sampler2D alpha_ramp; |
13 | 13 | ||
14 | varying vec3 vary_normal; | 14 | varying vec3 vary_normal; |
15 | varying vec4 vary_position; | ||
16 | 15 | ||
17 | void main() | 16 | void main() |
18 | { | 17 | { |
@@ -28,9 +27,8 @@ void main() | |||
28 | float alphaFinal = texture2D(alpha_ramp, gl_TexCoord[1].zw).a; | 27 | float alphaFinal = texture2D(alpha_ramp, gl_TexCoord[1].zw).a; |
29 | vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal ); | 28 | vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal ); |
30 | 29 | ||
31 | gl_FragData[0] = vec4(outColor.rgb, 1.0); | 30 | gl_FragData[0] = vec4(outColor.rgb, 0.0); // Kl 0.0 looks fine atm however check grass above waterline when GI enabled in future releases! |
32 | gl_FragData[1] = vec4(outColor.rgb*0.2, 0.2); | 31 | gl_FragData[1] = vec4(outColor.rgb*0.2, 0.2); |
33 | gl_FragData[2] = vec4(normalize(vary_normal), 0.0); | 32 | gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0); |
34 | gl_FragData[3] = vary_position; | ||
35 | } | 33 | } |
36 | 34 | ||
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl index e9d6dca..3038b14 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl | |||
@@ -6,7 +6,6 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | varying vec3 vary_normal; | 8 | varying vec3 vary_normal; |
9 | varying vec4 vary_position; | ||
10 | 9 | ||
11 | vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1) | 10 | vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1) |
12 | { | 11 | { |
@@ -27,7 +26,6 @@ void main() | |||
27 | //transform vertex | 26 | //transform vertex |
28 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; | 27 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; |
29 | 28 | ||
30 | vary_position = gl_ModelViewMatrix * gl_Vertex; | ||
31 | vary_normal = normalize(gl_NormalMatrix * gl_Normal); | 29 | vary_normal = normalize(gl_NormalMatrix * gl_Normal); |
32 | 30 | ||
33 | // Transform and pass tex coords | 31 | // Transform and pass tex coords |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl index bc2c981..49c65f1 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl | |||
@@ -8,13 +8,11 @@ | |||
8 | uniform sampler2D diffuseMap; | 8 | uniform sampler2D diffuseMap; |
9 | 9 | ||
10 | varying vec3 vary_normal; | 10 | varying vec3 vary_normal; |
11 | varying vec4 vary_position; | ||
12 | 11 | ||
13 | void main() | 12 | void main() |
14 | { | 13 | { |
15 | vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy); | 14 | vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy); |
16 | gl_FragData[0] = gl_Color*col; | 15 | gl_FragData[0] = gl_Color*col; |
17 | gl_FragData[1] = vec4(0,0,0,0); | 16 | gl_FragData[1] = vec4(0,0,0,0); |
18 | gl_FragData[2] = vec4(normalize(vary_normal), 0.0); | 17 | gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0); |
19 | gl_FragData[3] = vary_position; | ||
20 | } | 18 | } |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl index 9131d7c..6b9dc2d 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl | |||
@@ -6,7 +6,6 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | varying vec3 vary_normal; | 8 | varying vec3 vary_normal; |
9 | varying vec4 vary_position; | ||
10 | 9 | ||
11 | void main() | 10 | void main() |
12 | { | 11 | { |
@@ -14,8 +13,6 @@ void main() | |||
14 | gl_Position = ftransform(); | 13 | gl_Position = ftransform(); |
15 | gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; | 14 | gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; |
16 | 15 | ||
17 | vary_position = gl_ModelViewMatrix * gl_Vertex; | ||
18 | |||
19 | vary_normal = normalize(gl_NormalMatrix * gl_Normal); | 16 | vary_normal = normalize(gl_NormalMatrix * gl_Normal); |
20 | 17 | ||
21 | gl_FrontColor = gl_Color; | 18 | gl_FrontColor = gl_Color; |
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index 0a1f019..6eea656 100644 --- a/linden/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/linden/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl | |||
@@ -17,7 +17,7 @@ uniform sampler2DShadow shadowMap2; | |||
17 | uniform sampler2DShadow shadowMap3; | 17 | uniform sampler2DShadow shadowMap3; |
18 | uniform sampler2D noiseMap; | 18 | uniform sampler2D noiseMap; |
19 | 19 | ||
20 | uniform mat4 shadow_matrix[4]; | 20 | uniform mat4 shadow_matrix[6]; |
21 | uniform vec4 shadow_clip; | 21 | uniform vec4 shadow_clip; |
22 | 22 | ||
23 | uniform float sunAngle; | 23 | uniform float sunAngle; |