summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorGeenz <geenz@geenzo.com>2013-04-11 14:57:11 -0400
committerGeenz <geenz@geenzo.com>2013-04-11 14:57:11 -0400
commitcfc375777871ec3d04b9969793379d0cd78a012e (patch)
tree851d39612b82e18f82fe47961e4e9fbf70713ff4 /indra/newview
parent84475635b9c3db8d42f2f0a256d34c08274f53ed (diff)
First pass on alpha blended materials
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl27
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl35
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl226
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl232
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl5
-rw-r--r--indra/newview/lldrawpoolalpha.cpp60
-rw-r--r--indra/newview/llviewershadermgr.cpp10
-rw-r--r--indra/newview/llviewertexture.cpp2
-rw-r--r--indra/newview/llviewertexture.h1
-rw-r--r--indra/newview/llviewertexturelist.cpp3
-rw-r--r--indra/newview/llvovolume.cpp8
-rw-r--r--indra/newview/skins/default/textures/flatnormal.tgabin0 -> 92 bytes
13 files changed, 121 insertions, 490 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 4ef69824a1..55dda06b46 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -25,6 +25,10 @@
#extension GL_ARB_texture_rectangle : enable
+#define INDEXED 1
+#define NON_INDEXED 2
+#define NON_INDEXED_NO_COLOR 3
+
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
@@ -33,7 +37,13 @@ out vec4 frag_color;
uniform sampler2DRect depthMap;
+#if INDEX_MODE != INDEXED
+uniform sampler2D diffuseMap;
+#endif
+
+#if INDEX_MODE == INDEXED
vec4 diffuseLookup(vec2 texcoord);
+#endif
uniform vec2 screen_res;
@@ -46,7 +56,10 @@ VARYING vec3 vary_fragcoord;
VARYING vec3 vary_position;
VARYING vec3 vary_pointlight_col;
+#if INDEX_MODE != NON_INDEXED_NO_COLOR
VARYING vec4 vertex_color;
+#endif
+
VARYING vec2 vary_texcoord0;
VARYING vec3 vary_norm;
@@ -103,11 +116,21 @@ void main()
vec4 pos = vec4(vary_position, 1.0);
- vec4 diff= diffuseLookup(vary_texcoord0.xy);
+#if INDEX_MODE == INDEXED
+ vec4 diff = diffuseLookup(vary_texcoord0.xy);
+#else
+ vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy);
+#endif
+
+#if INDEX_MODE == NON_INDEXED_NO_COLOR
+ float vertex_color_alpha = 1.0;
+#else
+ float vertex_color_alpha = vertex_color.a;
+#endif
vec3 dlight = calcDirectionalLight(vary_norm, light_position[0].xyz) * vary_directional.rgb * vary_pointlight_col;
- vec4 col = vec4(vary_ambient + dlight, vertex_color.a);
+ vec4 col = vec4(vary_ambient + dlight, vertex_color_alpha);
vec4 color = diff * col;
color.rgb = atmosLighting(color.rgb);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl
index 5f395801e5..c8ddefac26 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl
@@ -47,6 +47,7 @@ VARYING vec3 vary_directional;
VARYING vec3 vary_fragcoord;
VARYING vec3 vary_pointlight_col;
VARYING vec2 vary_texcoord0;
+VARYING vec3 vary_norm;
uniform float near_clip;
@@ -112,6 +113,7 @@ void main()
norm.y = dot(trans[1].xyz, normal);
norm.z = dot(trans[2].xyz, normal);
norm = normalize(norm);
+ vary_norm = norm;
vec4 frag_pos = projection_matrix * pos;
gl_Position = frag_pos;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
index 6f10ff8451..a349981ea2 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
@@ -25,25 +25,27 @@
#extension GL_ARB_texture_rectangle : enable
+#define INDEXED 1
+#define NON_INDEXED 2
+#define NON_INDEXED_NO_COLOR 3
+
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
-VARYING vec4 vertex_color;
-VARYING vec2 vary_texcoord0;
-
uniform sampler2DShadow shadowMap0;
uniform sampler2DShadow shadowMap1;
uniform sampler2DShadow shadowMap2;
uniform sampler2DShadow shadowMap3;
uniform sampler2DRect depthMap;
-uniform mat4 shadow_matrix[6];
-uniform vec4 shadow_clip;
+#if INDEX_MODE != INDEXED
+uniform sampler2D diffuseMap;
+#endif
+
uniform vec2 screen_res;
-uniform vec2 shadow_res;
vec3 atmosLighting(vec3 light);
vec3 scaleSoftClip(vec3 light);
@@ -53,8 +55,16 @@ VARYING vec3 vary_directional;
VARYING vec3 vary_fragcoord;
VARYING vec3 vary_position;
VARYING vec3 vary_pointlight_col;
+VARYING vec2 vary_texcoord0;
VARYING vec3 vary_norm;
+#if INDEX_MODE != NON_INDEXED_NO_COLOR
+VARYING vec4 vertex_color;
+#endif
+
+uniform mat4 shadow_matrix[6];
+uniform vec4 shadow_clip;
+uniform vec2 shadow_res;
uniform float shadow_bias;
uniform mat4 inv_proj;
@@ -190,9 +200,20 @@ void main()
shadow = 1.0;
}
vec3 dlight = calcDirectionalLight(vary_norm, light_position[0].xyz) * vary_directional.rgb * vary_pointlight_col;
+
+#if INDEX_MODE == INDEXED
vec4 diff = diffuseLookup(vary_texcoord0.xy);
+#else
+ vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy);
+#endif
+
+#if INDEX_MODE == NON_INDEXED_NO_COLOR
+ float vertex_color_alpha = 1.0;
+#else
+ float vertex_color_alpha = vertex_color.a;
+#endif
- vec4 col = vec4(vary_ambient + dlight *shadow, vertex_color.a);
+ vec4 col = vec4(vary_ambient + dlight *shadow, vertex_color_alpha);
vec4 color = diff * col;
color.rgb = atmosLighting(color.rgb);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl
deleted file mode 100644
index 8fd8bb8066..0000000000
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl
+++ /dev/null
@@ -1,226 +0,0 @@
-/**
- * @file alphaF.glsl
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2007, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#extension GL_ARB_texture_rectangle : enable
-
-#ifdef DEFINE_GL_FRAGCOLOR
-out vec4 frag_color;
-#else
-#define frag_color gl_FragColor
-#endif
-
-uniform sampler2DShadow shadowMap0;
-uniform sampler2DShadow shadowMap1;
-uniform sampler2DShadow shadowMap2;
-uniform sampler2DShadow shadowMap3;
-uniform sampler2DRect depthMap;
-uniform sampler2D diffuseMap;
-
-uniform mat4 shadow_matrix[6];
-uniform vec4 shadow_clip;
-uniform vec2 screen_res;
-
-vec3 atmosLighting(vec3 light);
-vec3 scaleSoftClip(vec3 light);
-
-VARYING vec3 vary_ambient;
-VARYING vec3 vary_directional;
-VARYING vec3 vary_fragcoord;
-VARYING vec3 vary_position;
-VARYING vec3 vary_pointlight_col;
-VARYING vec2 vary_texcoord0;
-VARYING vec4 vertex_color;
-VARYING vec3 vary_norm;
-
-uniform vec2 shadow_res;
-uniform float shadow_bias;
-
-uniform mat4 inv_proj;
-
-uniform vec4 light_position[8];
-uniform vec3 light_direction[8];
-uniform vec3 light_attenuation[8];
-uniform vec3 light_diffuse[8];
-
-float calcDirectionalLight(vec3 n, vec3 l)
-{
- float a = pow(max(dot(n,l),0.0), 0.7);
- return a;
-}
-
-float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
-{
- //get light vector
- vec3 lv = lp.xyz-v;
-
- //get distance
- float d = dot(lv,lv);
-
- float da = 0.0;
-
- if (d > 0.0 && la > 0.0 && fa > 0.0)
- {
- //normalize light vector
- lv = normalize(lv);
-
- //distance attenuation
- float dist2 = d/la;
- da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
-
- // spotlight coefficient.
- float spot = max(dot(-ln, lv), is_pointlight);
- da *= spot*spot; // GL_SPOT_EXPONENT=2
-
- //angular attenuation
- da *= max(pow(dot(n, lv), 0.7), 0.0);
- }
-
- return da;
-}
-
-vec4 getPosition(vec2 pos_screen)
-{
- float depth = texture2DRect(depthMap, pos_screen.xy).a;
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos.xyz /= pos.w;
- pos.w = 1.0;
- return pos;
-}
-
-float pcfShadow(sampler2DShadow shadowMap, vec4 stc)
-{
- stc.xyz /= stc.w;
- stc.z += shadow_bias;
-
- stc.x = floor(stc.x*shadow_res.x + fract(stc.y*12345))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here
-
- float cs = shadow2D(shadowMap, stc.xyz).x;
- float shadow = cs;
-
- shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x;
- shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x;
- shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x;
- shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x;
-
- return shadow*0.2;
-}
-
-
-void main()
-{
- vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
- frag *= screen_res;
-
- float shadow = 0.0;
- vec4 pos = vec4(vary_position, 1.0);
-
- vec4 spos = pos;
-
- if (spos.z > -shadow_clip.w)
- {
- vec4 lpos;
-
- vec4 near_split = shadow_clip*-0.75;
- vec4 far_split = shadow_clip*-1.25;
- vec4 transition_domain = near_split-far_split;
- float weight = 0.0;
-
- if (spos.z < near_split.z)
- {
- lpos = shadow_matrix[3]*spos;
-
- float w = 1.0;
- w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
- shadow += pcfShadow(shadowMap3, lpos)*w;
- weight += w;
- shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
- }
-
- if (spos.z < near_split.y && spos.z > far_split.z)
- {
- lpos = shadow_matrix[2]*spos;
-
- float w = 1.0;
- w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;
- w -= max(near_split.z-spos.z, 0.0)/transition_domain.z;
- shadow += pcfShadow(shadowMap2, lpos)*w;
- weight += w;
- }
-
- if (spos.z < near_split.x && spos.z > far_split.y)
- {
- lpos = shadow_matrix[1]*spos;
-
- float w = 1.0;
- w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;
- w -= max(near_split.y-spos.z, 0.0)/transition_domain.y;
- shadow += pcfShadow(shadowMap1, lpos)*w;
- weight += w;
- }
-
- if (spos.z > far_split.x)
- {
- lpos = shadow_matrix[0]*spos;
-
- float w = 1.0;
- w -= max(near_split.x-spos.z, 0.0)/transition_domain.x;
-
- shadow += pcfShadow(shadowMap0, lpos)*w;
- weight += w;
- }
-
-
- shadow /= weight;
-
- }
- else
- {
- shadow = 1.0;
- }
- vec3 dlight = calcDirectionalLight(vary_norm, light_position[0].xyz) * vary_directional.rgb * vary_pointlight_col;
- vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy);
-
- vec4 col = vec4(vary_ambient + dlight*shadow, vertex_color.a);
- vec4 color = diff * col;
-
- color.rgb = atmosLighting(color.rgb);
-
- color.rgb = scaleSoftClip(color.rgb);
- vec3 light_col = vec3(0,0,0);
-
- for (int i = 2; i < 8; i++)
- {
- light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z);
- }
-
- color.rgb += diff.rgb * vary_pointlight_col * light_col;
-
- frag_color = color;
-}
-
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl
deleted file mode 100644
index ff75b039b2..0000000000
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedNoColorF.glsl
+++ /dev/null
@@ -1,232 +0,0 @@
-/**
- * @file alphaNonIndexedNoColorF.glsl
- *
- * $LicenseInfo:firstyear=2005&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2005, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#extension GL_ARB_texture_rectangle : enable
-
-#ifdef DEFINE_GL_FRAGCOLOR
-out vec4 frag_color;
-#else
-#define frag_color gl_FragColor
-#endif
-
-uniform float minimum_alpha;
-
-uniform sampler2DShadow shadowMap0;
-uniform sampler2DShadow shadowMap1;
-uniform sampler2DShadow shadowMap2;
-uniform sampler2DShadow shadowMap3;
-uniform sampler2DRect depthMap;
-uniform sampler2D diffuseMap;
-
-uniform mat4 shadow_matrix[6];
-uniform vec4 shadow_clip;
-uniform vec2 screen_res;
-
-vec3 atmosLighting(vec3 light);
-vec3 scaleSoftClip(vec3 light);
-
-VARYING vec3 vary_ambient;
-VARYING vec3 vary_directional;
-VARYING vec3 vary_fragcoord;
-VARYING vec3 vary_position;
-VARYING vec3 vary_pointlight_col;
-VARYING vec2 vary_texcoord0;
-
-uniform vec2 shadow_res;
-
-uniform float shadow_bias;
-
-uniform mat4 inv_proj;
-
-uniform vec4 light_position[8];
-uniform vec3 light_direction[8];
-uniform vec3 light_attenuation[8];
-uniform vec3 light_diffuse[8];
-
-float calcDirectionalLight(vec3 n, vec3 l)
-{
- float a = pow(max(dot(n,l),0.0), 0.7);
- return a;
-}
-
-float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
-{
- //get light vector
- vec3 lv = lp.xyz-v;
-
- //get distance
- float d = dot(lv,lv);
-
- float da = 0.0;
-
- if (d > 0.0 && la > 0.0 && fa > 0.0)
- {
- //normalize light vector
- lv = normalize(lv);
-
- //distance attenuation
- float dist2 = d/la;
- da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
-
- // spotlight coefficient.
- float spot = max(dot(-ln, lv), is_pointlight);
- da *= spot*spot; // GL_SPOT_EXPONENT=2
-
- //angular attenuation
- da *= max(pow(dot(n, lv), 0.7), 0.0);
- }
-
- return da;
-}
-
-vec4 getPosition(vec2 pos_screen)
-{
- float depth = texture2DRect(depthMap, pos_screen.xy).a;
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos.xyz /= pos.w;
- pos.w = 1.0;
- return pos;
-}
-
-float pcfShadow(sampler2DShadow shadowMap, vec4 stc)
-{
- stc.xyz /= stc.w;
- stc.z += shadow_bias;
-
- stc.x = floor(stc.x*shadow_res.x + fract(stc.y*12345))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here
- float cs = shadow2D(shadowMap, stc.xyz).x;
-
- float shadow = cs;
-
- shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x;
- shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x;
- shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x;
- shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x;
-
- return shadow*0.2;
-}
-
-
-void main()
-{
- vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
- frag *= screen_res;
-
- float shadow = 0.0;
- vec4 pos = vec4(vary_position, 1.0);
-
- vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy);
-
- if (diff.a < minimum_alpha)
- {
- discard;
- }
-
- vec4 spos = pos;
-
- if (spos.z > -shadow_clip.w)
- {
- vec4 lpos;
-
- vec4 near_split = shadow_clip*-0.75;
- vec4 far_split = shadow_clip*-1.25;
- vec4 transition_domain = near_split-far_split;
- float weight = 0.0;
-
- if (spos.z < near_split.z)
- {
- lpos = shadow_matrix[3]*spos;
-
- float w = 1.0;
- w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
- shadow += pcfShadow(shadowMap3, lpos)*w;
- weight += w;
- shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
- }
-
- if (spos.z < near_split.y && spos.z > far_split.z)
- {
- lpos = shadow_matrix[2]*spos;
-
- float w = 1.0;
- w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;
- w -= max(near_split.z-spos.z, 0.0)/transition_domain.z;
- shadow += pcfShadow(shadowMap2, lpos)*w;
- weight += w;
- }
-
- if (spos.z < near_split.x && spos.z > far_split.y)
- {
- lpos = shadow_matrix[1]*spos;
-
- float w = 1.0;
- w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;
- w -= max(near_split.y-spos.z, 0.0)/transition_domain.y;
- shadow += pcfShadow(shadowMap1, lpos)*w;
- weight += w;
- }
-
- if (spos.z > far_split.x)
- {
- lpos = shadow_matrix[0]*spos;
-
- float w = 1.0;
- w -= max(near_split.x-spos.z, 0.0)/transition_domain.x;
-
- shadow += pcfShadow(shadowMap0, lpos)*w;
- weight += w;
- }
-
-
- shadow /= weight;
- }
- else
- {
- shadow = 1.0;
- }
- vec3 dlight = calcDirectionalLight(vary_norm, light_position[0].xyz) * vary_directional.rgb * vary_pointlight_col;
-
- vec4 col = vec4(vary_ambient + dlight*shadow, 1.0);
- vec4 color = diff * col;
-
- color.rgb = atmosLighting(color.rgb);
-
- color.rgb = scaleSoftClip(color.rgb);
- vec3 light_col = vec3(0,0,0);
-
- for (int i = 2; i < 8; i++)
- {
- light_col += light_diffuse[i].rgb * calcPointLightOrSpotLight(pos.xyz, vary_norm, light_position[i], light_direction[i], light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z);
- }
-
- color.rgb += diff.rgb * vary_pointlight_col * light_col;
-
- frag_color = color;
-}
-
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl
index 9629cfe824..7f4d82ecc6 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl
@@ -50,7 +50,7 @@ VARYING vec3 vary_pointlight_col;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
-
+VARYING vec3 vary_norm;
uniform float near_clip;
uniform float shadow_offset;
@@ -115,7 +115,8 @@ void main()
n.xyz = normalize(n.xyz-pos.xyz);
vec3 norm = n.xyz;
-
+ vary_norm = norm;
+
float dp_directional_light = max(0.0, dot(norm, light_position[0].xyz));
vary_position = pos.xyz + light_position[0].xyz * (1.0-dp_directional_light)*shadow_offset;
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index a8abe9a267..291bdfebe6 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -436,7 +436,6 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
}
LLRenderPass::applyModelMatrix(params);
-
if (params.mFullbright)
{
@@ -447,20 +446,6 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
if (use_shaders)
{
target_shader = fullbright_shader;
- if (target_shader)
- {
- if (LLPipeline::sRenderDeferred)
- {
- if (params.mFace->getViewerObject()->isHUDAttachment())
- {
- target_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0);
- } else {
- target_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2);
- }
- } else {
- target_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 1.0);
- }
- }
}
else
{
@@ -497,6 +482,51 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
LLGLSLShader::bindNoShader();
current_shader = NULL;
}
+
+ if (params.mMaterialID != LLMaterialID::null && current_shader == simple_shader)
+ {
+ // I apologize in advance for not giving this its own shader.
+ // We have a material. Supply the appropriate data here.
+ if (LLPipeline::sRenderDeferred)
+ {
+ current_shader->uniform4f(LLShaderMgr::SPECULAR_COLOR, params.mSpecColor.mV[0], params.mSpecColor.mV[1], params.mSpecColor.mV[2], params.mSpecColor.mV[3]);
+
+ current_shader->uniform1f(LLShaderMgr::ENVIRONMENT_INTENSITY, params.mEnvIntensity);
+
+ if (params.mNormalMap)
+ {
+ params.mNormalMap->addTextureStats(params.mVSize);
+ current_shader->bindTexture(LLShaderMgr::BUMP_MAP, params.mNormalMap);
+ } else {
+ LLViewerFetchedTexture::sFlatNormalImagep->addTextureStats(params.mVSize);
+ current_shader->bindTexture(LLShaderMgr::BUMP_MAP, params.mNormalMap);
+ }
+
+ if (params.mSpecularMap)
+ {
+ params.mSpecularMap->addTextureStats(params.mVSize);
+ current_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, params.mSpecularMap);
+ } else {
+ LLViewerFetchedTexture::sWhiteImagep->addTextureStats(params.mVSize);
+ current_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep);
+ }
+ }
+ } else if (current_shader == simple_shader)
+ {
+ // No material. Propegate with default parameters.
+ if (LLPipeline::sRenderDeferred)
+ {
+ current_shader->uniform4f(LLShaderMgr::SPECULAR_COLOR, 0.0f, 0.0f, 0.0f, 0.0f);
+
+ current_shader->uniform1f(LLShaderMgr::ENVIRONMENT_INTENSITY, 0.0f);
+
+ LLViewerFetchedTexture::sFlatNormalImagep->addTextureStats(params.mVSize);
+ current_shader->bindTexture(LLShaderMgr::BUMP_MAP, params.mNormalMap);
+
+ LLViewerFetchedTexture::sWhiteImagep->addTextureStats(params.mVSize);
+ current_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep);
+ }
+ }
if (params.mGroup)
{
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 286152867f..22ff78c639 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -1206,9 +1206,9 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredSkinnedAlphaProgram.mFeatures.disableTextureIndex = true;
gDeferredSkinnedAlphaProgram.mShaderFiles.clear();
gDeferredSkinnedAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
- gDeferredSkinnedAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaNonIndexedF.glsl", GL_FRAGMENT_SHADER_ARB));
+ gDeferredSkinnedAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredSkinnedAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
-
+ gDeferredSkinnedAlphaProgram.addPermutation("INDEX_MODE", "2");
success = gDeferredSkinnedAlphaProgram.createShader(NULL, NULL);
// Hack to include uniforms for lighting without linking in lighting file
@@ -1385,6 +1385,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
+ gDeferredAlphaProgram.addPermutation("INDEX_MODE", "1");
success = gDeferredAlphaProgram.createShader(NULL, NULL);
@@ -1554,9 +1555,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredAvatarAlphaProgram.mFeatures.disableTextureIndex = true;
gDeferredAvatarAlphaProgram.mShaderFiles.clear();
gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaNoColorV.glsl", GL_VERTEX_SHADER_ARB));
- gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaNonIndexedNoColorF.glsl", GL_FRAGMENT_SHADER_ARB));
+ gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredAvatarAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
-
+ gDeferredAvatarAlphaProgram.addPermutation("INDEX_MODE", "3");
+
success = gDeferredAvatarAlphaProgram.createShader(NULL, &mAvatarUniforms);
gDeferredAvatarAlphaProgram.mFeatures.calculatesLighting = true;
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index a57270caeb..a13cccd86b 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -70,6 +70,7 @@ LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sMissingAssetImagep =
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sWhiteImagep = NULL;
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultImagep = NULL;
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sSmokeImagep = NULL;
+LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sFlatNormalImagep = NULL;
LLViewerMediaTexture::media_map_t LLViewerMediaTexture::sMediaMap ;
LLTexturePipelineTester* LLViewerTextureManager::sTesterp = NULL ;
const std::string sTesterName("TextureTester");
@@ -394,6 +395,7 @@ void LLViewerTextureManager::cleanup()
LLViewerFetchedTexture::sSmokeImagep = NULL;
LLViewerFetchedTexture::sMissingAssetImagep = NULL;
LLViewerFetchedTexture::sWhiteImagep = NULL;
+ LLViewerFetchedTexture::sFlatNormalImagep = NULL;
LLViewerMediaTexture::cleanUpClass() ;
}
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index eb30139cb8..ebace4b583 100644
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -596,6 +596,7 @@ public:
static LLPointer<LLViewerFetchedTexture> sWhiteImagep; // Texture to show NOTHING (whiteness)
static LLPointer<LLViewerFetchedTexture> sDefaultImagep; // "Default" texture for error cases, the only case of fetched texture which is generated in local.
static LLPointer<LLViewerFetchedTexture> sSmokeImagep; // Old "Default" translucent texture
+ static LLPointer<LLViewerFetchedTexture> sFlatNormalImagep; // Flat normal map denoting no bumpiness on a surface
};
//
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index b9f5c432d0..8d71761f92 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -119,6 +119,9 @@ void LLViewerTextureList::doPreloadImages()
LLTexUnit::sWhiteTexture = LLViewerFetchedTexture::sWhiteImagep->getTexName();
LLUIImageList* image_list = LLUIImageList::getInstance();
+ // Set the default flat normal map
+ LLViewerFetchedTexture::sFlatNormalImagep = LLViewerTextureManager::getFetchedTextureFromFile("flatnormal.tga", MIPMAP_NO, LLViewerFetchedTexture::BOOST_BUMP);
+
image_list->initFromFile();
// turn off clamping and bilinear filtering for uv picking images
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index b46f4d7351..34bed6a7f3 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -4015,7 +4015,11 @@ static LLFastTimer::DeclareTimer FTM_REGISTER_FACE("Register Face");
void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, U32 type)
{
LLFastTimer t(FTM_REGISTER_FACE);
-
+ if (type == LLRenderPass::PASS_ALPHA && facep->getTextureEntry()->getMaterialParams().notNull() && !facep->getVertexBuffer()->hasDataType(LLVertexBuffer::TYPE_BINORMAL))
+ {
+ LL_WARNS("RenderMaterials") << "Oh no! No binormals for this alpha blended face!" << LL_ENDL;
+ }
+
if (facep->getViewerObject()->isSelected() && LLSelectMgr::getInstance()->mHideSelectedObjects)
{
return;
@@ -4758,7 +4762,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
{
bump_mask = bump_mask | LLVertexBuffer::MAP_BINORMAL;
simple_mask = simple_mask | LLVertexBuffer::MAP_TEXTURE_INDEX;
- alpha_mask = alpha_mask | LLVertexBuffer::MAP_TEXTURE_INDEX;
+ alpha_mask = alpha_mask | LLVertexBuffer::MAP_TEXTURE_INDEX | LLVertexBuffer::MAP_BINORMAL;
fullbright_mask = fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX;
}
diff --git a/indra/newview/skins/default/textures/flatnormal.tga b/indra/newview/skins/default/textures/flatnormal.tga
new file mode 100644
index 0000000000..6d5abd1782
--- /dev/null
+++ b/indra/newview/skins/default/textures/flatnormal.tga
Binary files differ