diff options
author | Dave Parks <davep@lindenlab.com> | 2013-03-27 21:59:14 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2013-03-27 21:59:14 -0500 |
commit | 6300f4f768de13823a754831797cb34022f87b60 (patch) | |
tree | ae847221ee1a68535e58562cb291441489ab0f82 /indra/newview/app_settings | |
parent | 7be396cc985c0274ff05b375a8bf27c0e630666a (diff) |
NORSPEC-61 Hook up material parameters to shaders.
Diffstat (limited to 'indra/newview/app_settings')
4 files changed, 58 insertions, 15 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 4f7fc6a411..5392466b25 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -23,6 +23,12 @@ * $/LicenseInfo$ */ +#define DIFFUSE_ALPHA_MODE_IGNORE 0 +#define DIFFUSE_ALPHA_MODE_BLEND 1 +#define DIFFUSE_ALPHA_MODE_MASK 2 +#define DIFFUSE_ALPHA_MODE_GLOW 3 + + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; #else @@ -31,36 +37,52 @@ out vec4 frag_data[3]; uniform sampler2D diffuseMap; +#if HAS_NORMAL_MAP uniform sampler2D bumpMap; +#endif +#if HAS_SPECULAR_MAP uniform sampler2D specularMap; uniform float env_intensity; +#endif + uniform vec4 specular_color; -#ifdef ALPHA_TEST +#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK uniform float minimum_alpha; #endif +#if HAS_NORMAL_MAP VARYING vec3 vary_mat0; VARYING vec3 vary_mat1; VARYING vec3 vary_mat2; +#else +VARYING vec3 vary_normal; +#endif VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; + void main() { - vec4 col = texture2D(diffuseMap, vary_texcoord0.xy) * vertex_color; + vec4 col = texture2D(diffuseMap, vary_texcoord0.xy); + col.rgb *= vertex_color.rgb; - #ifdef ALPHA_TEST +#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK if (col.a < minimum_alpha) { discard; } - #endif - +#endif + +#if HAS_SPECULAR_MAP vec4 spec = texture2D(specularMap, vary_texcoord0.xy); +#else + vec4 spec = specular_color; +#endif +#if HAS_NORMAL_MAP vec4 norm = texture2D(bumpMap, vary_texcoord0.xy); norm.xyz = norm.xyz * 2 - 1; @@ -68,19 +90,29 @@ void main() vec3 tnorm = vec3(dot(norm.xyz,vary_mat0), dot(norm.xyz,vary_mat1), dot(norm.xyz,vary_mat2)); +#else + vec4 norm = vec4(0,0,0,1.0); + vec3 tnorm = vary_normal; +#endif vec4 final_color = col; - final_color.rgb *= 1 - spec.a * env_intensity; - - #ifndef EMISSIVE_MASK + +#if DIFFUSE_ALPHA_MODE != DIFFUSE_ALPHA_MODE_GLOW final_color.a = 0; - #endif +#endif vec4 final_specular = spec; +#if HAS_SPECULAR_MAP + //final_color.rgb *= 1 - spec.a * env_intensity; final_specular.rgb *= specular_color.rgb; - final_specular.a = specular_color.a * norm.a; - + vec4 final_normal = vec4(normalize(tnorm), spec.a * env_intensity); + final_specular.a = specular_color.a * spec.a; +#else + vec4 final_normal = vec4(normalize(tnorm), 0.0); + final_specular.a = spec.a; +#endif + final_normal.xyz = final_normal.xyz * 0.5 + 0.5; frag_data[0] = final_color; diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl index c8d38bb8f7..f92ad63100 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl @@ -31,11 +31,17 @@ ATTRIBUTE vec3 position; ATTRIBUTE vec4 diffuse_color; ATTRIBUTE vec3 normal; ATTRIBUTE vec2 texcoord0; + +#if HAS_NORMAL_MAP ATTRIBUTE vec3 binormal; VARYING vec3 vary_mat0; VARYING vec3 vary_mat1; VARYING vec3 vary_mat2; +#else +VARYING vec3 vary_normal; +#endif + VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; @@ -45,13 +51,18 @@ void main() gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; + vec3 n = normalize(normal_matrix * normal); +#if HAS_NORMAL_MAP vec3 b = normalize(normal_matrix * binormal); vec3 t = cross(b, n); vary_mat0 = vec3(t.x, b.x, n.x); vary_mat1 = vec3(t.y, b.y, n.y); vary_mat2 = vec3(t.z, b.z, n.z); +#else + vary_normal = n; +#endif vertex_color = diffuse_color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 2905cc91b6..f50935c1a8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -310,7 +310,7 @@ void main() //add environmentmap vec3 env_vec = env_mat * refnormpersp; col = mix(col.rgb, textureCube(environmentMap, env_vec).rgb, - max(spec.a-diffuse.a*2.0, 0.0)); + max(norm.a-diffuse.a*2.0, 0.0)); } col = atmosLighting(col); diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 9df9d75905..ff20b63972 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -278,8 +278,8 @@ void main() vec2 tc = vary_fragcoord.xy; float depth = texture2DRect(depthMap, tc.xy).r; vec3 pos = getPosition_d(tc, depth).xyz; - vec3 norm = texture2DRect(normalMap, tc).xyz; - norm = (norm.xyz-0.5)*2.0; // unpack norm + vec4 norm = texture2DRect(normalMap, tc); + norm.xyz = (norm.xyz-0.5)*2.0; // unpack norm float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); @@ -319,7 +319,7 @@ void main() //add environmentmap vec3 env_vec = env_mat * refnormpersp; col = mix(col.rgb, textureCube(environmentMap, env_vec).rgb, - max(spec.a-diffuse.a*2.0, 0.0)); + max(norm.a-diffuse.a*2.0, 0.0)); } col = atmosLighting(col); |