From 9ce481a5ac41777539416da3e0ec92b098af3e49 Mon Sep 17 00:00:00 2001 From: Adam Moss Date: Sat, 21 Apr 2012 17:35:50 +0100 Subject: STORM-1819: Ternary/graded shadow support Coalesced patchset. --- .../shaders/class1/deferred/shadowAlphaMaskF.glsl | 21 ++++++++++++++++++--- .../shaders/class1/deferred/shadowAlphaMaskV.glsl | 17 ++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1') diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl index cf8cf8364a..07d5b08191 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl @@ -29,11 +29,18 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif +uniform mat4 modelview_projection_matrix; + uniform float minimum_alpha; uniform sampler2D diffuseMap; -VARYING vec4 post_pos; +//flat VARYING int foo; +VARYING float pos_zd2; +VARYING float pos_w; +VARYING float target_pos_x; +//VARYING vec4 pre_pos; +//VARYING vec4 post_pos; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; @@ -41,12 +48,20 @@ void main() { float alpha = diffuseLookup(vary_texcoord0.xy).a * vertex_color.a; - if (alpha < minimum_alpha) + if (alpha < 0.05) // treat as totally transparent { discard; } + if (alpha < 0.88) // treat as semi-transparent + { + if (fract(0.5*floor(target_pos_x / pos_w )) < 0.25) + { + discard; + } + } + frag_color = vec4(1,1,1,1); - gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0); + gl_FragDepth = max(pos_zd2/pos_w+0.5, 0.0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl index 7d3b06c56e..6397a5c461 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl @@ -25,12 +25,18 @@ uniform mat4 texture_matrix0; uniform mat4 modelview_projection_matrix; +uniform float shadow_target_width; ATTRIBUTE vec3 position; ATTRIBUTE vec4 diffuse_color; ATTRIBUTE vec2 texcoord0; -VARYING vec4 post_pos; +VARYING float pos_zd2; +VARYING float pos_w; +VARYING float target_pos_x; +//flat VARYING int foo; +//VARYING vec4 pre_pos; +//VARYING vec4 post_pos; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; @@ -39,8 +45,13 @@ void passTextureIndex(); void main() { //transform vertex - vec4 pos = modelview_projection_matrix*vec4(position.xyz, 1.0); - post_pos = pos; + vec4 pre_pos = vec4(position.xyz, 1.0); + vec4 pos = modelview_projection_matrix * pre_pos; + //post_pos = pos; + target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x; + pos_w = pos.w; + pos_zd2 = pos.z * 0.5; + //foo = int(posxw.x); gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); -- cgit v1.2.3 From 442c5cf339ddffb10db9f819704bf77ad941bc28 Mon Sep 17 00:00:00 2001 From: Adam Moss Date: Sat, 21 Apr 2012 18:33:07 +0100 Subject: STORM-1819: Ternary/graded shadow support a bunch of trivial clean-ups and commentary. --- .../app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl | 5 ----- .../app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl | 5 ----- 2 files changed, 10 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1') diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl index 07d5b08191..6269a051f1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl @@ -29,18 +29,13 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -uniform mat4 modelview_projection_matrix; - uniform float minimum_alpha; uniform sampler2D diffuseMap; -//flat VARYING int foo; VARYING float pos_zd2; VARYING float pos_w; VARYING float target_pos_x; -//VARYING vec4 pre_pos; -//VARYING vec4 post_pos; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl index 6397a5c461..c1f2d90712 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl @@ -34,9 +34,6 @@ ATTRIBUTE vec2 texcoord0; VARYING float pos_zd2; VARYING float pos_w; VARYING float target_pos_x; -//flat VARYING int foo; -//VARYING vec4 pre_pos; -//VARYING vec4 post_pos; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; @@ -47,11 +44,9 @@ void main() //transform vertex vec4 pre_pos = vec4(position.xyz, 1.0); vec4 pos = modelview_projection_matrix * pre_pos; - //post_pos = pos; target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x; pos_w = pos.w; pos_zd2 = pos.z * 0.5; - //foo = int(posxw.x); gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w); -- cgit v1.2.3 From b6f2b2f399fc004806e525851e86d04bf446564d Mon Sep 17 00:00:00 2001 From: Adam Moss Date: Sun, 22 Apr 2012 19:58:14 +0100 Subject: remove a now-unused uniform. --- .../newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1') diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl index 6269a051f1..bced4a5577 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl @@ -29,8 +29,6 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -uniform float minimum_alpha; - uniform sampler2D diffuseMap; VARYING float pos_zd2; -- cgit v1.2.3