summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llprimitive/llmaterial.cpp6
-rw-r--r--indra/llprimitive/llmaterial.h4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl57
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl54
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl20
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl16
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl8
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl8
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl8
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl8
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl8
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl8
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl9
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/materialF.glsl19
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/skyF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl16
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl8
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/treeF.glsl8
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl17
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl13
-rw-r--r--indra/newview/llpanelface.cpp530
-rw-r--r--indra/newview/llpanelface.h5
-rw-r--r--indra/newview/pipeline.cpp2
31 files changed, 715 insertions, 223 deletions
diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp
index 7d1ce4ab86..1e92847b38 100644
--- a/indra/llprimitive/llmaterial.cpp
+++ b/indra/llprimitive/llmaterial.cpp
@@ -51,6 +51,8 @@
#define MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD "AlphaMaskCutoff"
#define MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD "DiffuseAlphaMode"
+const LLColor4U LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR = LLColor4U::white;
+
/**
* Materials constants
*/
@@ -99,7 +101,8 @@ LLMaterial::LLMaterial()
, mSpecularRepeatX(.0f)
, mSpecularRepeatY(.0f)
, mSpecularRotation(.0f)
- , mSpecularLightExponent(0)
+ , mSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR)
+ , mSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT)
, mEnvironmentIntensity(0)
, mDiffuseAlphaMode(0)
, mAlphaMaskCutoff(0)
@@ -214,3 +217,4 @@ U32 LLMaterial::getShaderMask()
return ret;
}
+
diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h
index dc3484309c..bedfc8f8c2 100644
--- a/indra/llprimitive/llmaterial.h
+++ b/indra/llprimitive/llmaterial.h
@@ -52,6 +52,9 @@ public:
SHADER_COUNT = 16
} eShaderCount;
+ static const U8 DEFAULT_SPECULAR_LIGHT_EXPONENT = ((U8)(0.2f * 255));
+ static const LLColor4U DEFAULT_SPECULAR_LIGHT_COLOR;
+
LLMaterial();
LLMaterial(const LLSD& material_data);
@@ -120,3 +123,4 @@ protected:
typedef LLPointer<LLMaterial> LLMaterialPtr;
#endif // LL_LLMATERIAL_H
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index dd87ddb330..4ef69824a1 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -49,8 +49,53 @@ VARYING vec3 vary_pointlight_col;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
+VARYING vec3 vary_norm;
uniform mat4 inv_proj;
+uniform vec4 light_position[8];
+uniform vec3 light_direction[8];
+uniform vec3 light_attenuation[8];
+uniform vec3 light_diffuse[8];
+
+
+uniform float shadow_offset;
+
+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;
+}
+
void main()
{
vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
@@ -60,14 +105,22 @@ void main()
vec4 diff= diffuseLookup(vary_texcoord0.xy);
- vec4 col = vec4(vary_ambient + vary_directional.rgb, vertex_color.a);
+ 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 color = diff * col;
color.rgb = atmosLighting(color.rgb);
color.rgb = scaleSoftClip(color.rgb);
+ vec3 light_col = vec3(0,0,0);
- color.rgb += diff.rgb * vary_pointlight_col.rgb;
+ 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/class1/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
index beb3290187..10e9670894 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
@@ -47,9 +47,51 @@ VARYING vec3 vary_position;
VARYING vec3 vary_pointlight_col;
VARYING vec2 vary_texcoord0;
VARYING vec4 vertex_color;
+VARYING vec3 vary_norm;
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;
@@ -72,14 +114,22 @@ void main()
vec4 diff= texture2D(diffuseMap,vary_texcoord0.xy);
- vec4 col = vec4(vary_ambient + vary_directional.rgb, vertex_color.a);
+ 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 color = diff * col;
color.rgb = atmosLighting(color.rgb);
color.rgb = scaleSoftClip(color.rgb);
+ vec3 light_col = vec3(0,0,0);
- color.rgb += diff.rgb * vary_pointlight_col.rgb;
+ 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;
//frag_color = vec4(1,0,1,1);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
index 5a0e8ff684..5f93986f1d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
@@ -46,6 +46,7 @@ VARYING vec3 vary_pointlight_col;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
+VARYING vec3 vary_norm;
uniform float near_clip;
@@ -104,7 +105,7 @@ void main()
norm = position.xyz + normal.xyz;
norm = normalize(( trans*vec4(norm, 1.0) ).xyz-pos.xyz);
-
+ vary_norm = norm;
vec4 frag_pos = projection_matrix * pos;
gl_Position = frag_pos;
@@ -112,27 +113,18 @@ void main()
calcAtmospherics(pos.xyz);
+ //vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.));
vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a);
-
- // Collect normal lights
- col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z);
- col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z);
- col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z);
- col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z);
- col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z);
- col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z);
-
- vary_pointlight_col = col.rgb*diffuse_color.rgb;
-
+ vary_pointlight_col = diffuse_color.rgb;
col.rgb = vec3(0,0,0);
// Add windlight lights
col.rgb = atmosAmbient(vec3(0.));
vary_ambient = col.rgb*diffuse_color.rgb;
- vary_directional = diffuse_color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), (1.0-diffuse_color.a)*(1.0-diffuse_color.a)));
+ vary_directional.rgb = atmosAffectDirectionalLight(1);
- col.rgb = min(col.rgb*diffuse_color.rgb, 1.0);
+ col.rgb = col.rgb*diffuse_color.rgb;
vertex_color = col;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index cf38a2f4f7..bc08cc6dbf 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -53,6 +53,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;
@@ -110,7 +111,7 @@ void main()
vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
vec3 norm = normalize(normal_matrix * normal);
-
+ 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;
@@ -118,23 +119,14 @@ void main()
//vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.));
vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a);
-
- // Collect normal lights
- col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z);
- col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z);
- col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z);
- col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z);
- col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z);
- col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z);
-
- vary_pointlight_col = col.rgb*diffuse_color.rgb;
+ vary_pointlight_col = diffuse_color.rgb;
col.rgb = vec3(0,0,0);
// Add windlight lights
col.rgb = atmosAmbient(vec3(0.));
vary_ambient = col.rgb*diffuse_color.rgb;
- vary_directional.rgb = diffuse_color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), (1.0-diffuse_color.a)*(1.0-diffuse_color.a)));
+ vary_directional.rgb = atmosAffectDirectionalLight(1);
col.rgb = col.rgb*diffuse_color.rgb;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
index bfd9b9b3eb..bcccbf77d2 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
@@ -34,6 +34,12 @@ uniform sampler2D diffuseMap;
VARYING vec3 vary_normal;
VARYING vec2 vary_texcoord0;
+vec2 encode_normal(vec3 n)
+{
+ float f = sqrt(8 * n.z + 8);
+ return n.xy / f + 0.5;
+}
+
void main()
{
vec4 diff = texture2D(diffuseMap, vary_texcoord0.xy);
@@ -46,6 +52,6 @@ void main()
frag_data[0] = vec4(diff.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0);
vec3 nvn = normalize(vary_normal);
- frag_data[2] = vec4(nvn.xyz * 0.5 + 0.5, 0.0);
+ frag_data[2] = vec4(encode_normal(nvn.xyz), 0.0, 0.0);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
index a887728493..595c11fae2 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
@@ -39,6 +39,12 @@ VARYING vec3 vary_mat2;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
+vec2 encode_normal(vec3 n)
+{
+ float f = sqrt(8 * n.z + 8);
+ return n.xy / f + 0.5;
+}
+
void main()
{
vec3 col = vertex_color.rgb * texture2D(diffuseMap, vary_texcoord0.xy).rgb;
@@ -52,5 +58,5 @@ void main()
frag_data[1] = vertex_color.aaaa; // spec
//frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
vec3 nvn = normalize(tnorm);
- frag_data[2] = vec4(nvn.xyz * 0.5 + 0.5, vertex_color.a);
+ frag_data[2] = vec4(encode_normal(nvn.xyz), vertex_color.a, 0.0);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
index c1fa9e4aac..7930b5d18b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl
@@ -37,6 +37,12 @@ VARYING vec3 vary_normal;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
+vec2 encode_normal(vec3 n)
+{
+ float f = sqrt(8 * n.z + 8);
+ return n.xy / f + 0.5;
+}
+
void main()
{
vec4 col = texture2D(diffuseMap, vary_texcoord0.xy) * vertex_color;
@@ -49,6 +55,6 @@ void main()
frag_data[0] = vec4(col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0); // spec
vec3 nvn = normalize(vary_normal);
- frag_data[2] = vec4(nvn.xyz * 0.5 + 0.5, 0.0);
+ frag_data[2] = vec4(encode_normal(nvn.xyz), 0.0, 0.0);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl
index 4c68123fac..59d109b886 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl
@@ -36,6 +36,12 @@ uniform float minimum_alpha;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
+vec2 encode_normal(vec3 n)
+{
+ float f = sqrt(8 * n.z + 8);
+ return n.xy / f + 0.5;
+}
+
void main()
{
vec4 col = diffuseLookup(vary_texcoord0.xy) * vertex_color;
@@ -48,5 +54,5 @@ void main()
frag_data[0] = vec4(col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0);
vec3 nvn = normalize(vary_normal);
- frag_data[2] = vec4(nvn.xyz * 0.5 + 0.5, 0.0);
+ frag_data[2] = vec4(encode_normal(nvn.xyz), 0.0, 0.0);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl
index ad65c7d330..37d70a2412 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl
@@ -37,6 +37,12 @@ uniform sampler2D diffuseMap;
VARYING vec3 vary_normal;
VARYING vec2 vary_texcoord0;
+vec2 encode_normal(vec3 n)
+{
+ float f = sqrt(8 * n.z + 8);
+ return n.xy / f + 0.5;
+}
+
void main()
{
vec4 col = texture2D(diffuseMap, vary_texcoord0.xy);
@@ -49,6 +55,6 @@ void main()
frag_data[0] = vec4(col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0); // spec
vec3 nvn = normalize(vary_normal);
- frag_data[2] = vec4(nvn.xyz * 0.5 + 0.5, 0.0);
+ frag_data[2] = vec4(encode_normal(nvn.xyz), 0.0, 0.0);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
index 2e456d00dd..6befb1bd8b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
@@ -35,6 +35,12 @@ VARYING vec3 vary_normal;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
+vec2 encode_normal(vec3 n)
+{
+ float f = sqrt(8 * n.z + 8);
+ return n.xy / f + 0.5;
+}
+
void main()
{
vec3 col = vertex_color.rgb * texture2D(diffuseMap, vary_texcoord0.xy).rgb;
@@ -42,6 +48,6 @@ void main()
frag_data[1] = vertex_color.aaaa; // spec
//frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
vec3 nvn = normalize(vary_normal);
- frag_data[2] = vec4(nvn.xyz * 0.5 + 0.5, vertex_color.a);
+ frag_data[2] = vec4(encode_normal(nvn.xyz), vertex_color.a, 0.0);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
index bb6dc9a57d..40b980bf51 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
@@ -33,6 +33,13 @@ VARYING vec3 vary_normal;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
+vec2 encode_normal(vec3 n)
+{
+ float f = sqrt(8 * n.z + 8);
+ return n.xy / f + 0.5;
+}
+
+
void main()
{
vec3 col = vertex_color.rgb * diffuseLookup(vary_texcoord0.xy).rgb;
@@ -41,5 +48,5 @@ void main()
frag_data[1] = vertex_color.aaaa; // spec
//frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
vec3 nvn = normalize(vary_normal);
- frag_data[2] = vec4(nvn.xyz * 0.5 + 0.5, vertex_color.a);
+ frag_data[2] = vec4(encode_normal(nvn.xyz), vertex_color.a, 0.0);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index e406bf14a9..35b176b457 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -43,11 +43,11 @@ uniform sampler2D bumpMap;
#if HAS_SPECULAR_MAP
uniform sampler2D specularMap;
-uniform float env_intensity;
VARYING vec2 vary_texcoord2;
#endif
+uniform float env_intensity;
uniform vec4 specular_color;
#if DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK
@@ -66,6 +66,11 @@ VARYING vec3 vary_normal;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
+vec2 encode_normal(vec3 n)
+{
+ float f = sqrt(8 * n.z + 8);
+ return n.xy / f + 0.5;
+}
void main()
{
@@ -109,16 +114,14 @@ void main()
//final_color.rgb *= 1 - spec.a * env_intensity;
final_specular.rgb *= specular_color.rgb;
- vec4 final_normal = vec4(normalize(tnorm), spec.a * env_intensity);
- final_specular.a = specular_color.a * spec.a;
+ vec4 final_normal = vec4(encode_normal(normalize(tnorm)), spec.a * env_intensity, 0.0);
+ final_specular.a = specular_color.a * norm.a;
#else
- vec4 final_normal = vec4(normalize(tnorm), 0.0);
- final_specular.a = spec.a;
+ vec4 final_normal = vec4(encode_normal(normalize(tnorm)), env_intensity, 0.0);
+ final_specular.a = specular_color.a;
#endif
-
- final_normal.xyz = final_normal.xyz * 0.5 + 0.5;
frag_data[0] = final_color;
frag_data[1] = final_specular; // XYZ = Specular color. W = Specular exponent.
- frag_data[2] = final_normal; // XYZ = Normal. W = Env. intensity.
+ frag_data[2] = final_normal; // XY = Normal. Z = Env. intensity.
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index c11298aadd..5329ae9dd7 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -56,6 +56,17 @@ uniform float far_z;
uniform mat4 inv_proj;
+vec3 decode_normal (vec2 enc)
+{
+ vec2 fenc = enc*4-2;
+ float f = dot(fenc,fenc);
+ float g = sqrt(1-f/4);
+ vec3 n;
+ n.xy = fenc*g;
+ n.z = 1-f/2;
+ return n;
+}
+
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMap, pos_screen.xy).r;
@@ -79,7 +90,7 @@ void main()
}
vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
- norm = (norm.xyz-0.5)*2.0; // unpack norm
+ norm = decode_normal(norm.xy); // unpack norm
norm = normalize(norm);
vec4 spec = texture2DRect(specularRect, frag.xy);
vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
index 09d23db096..9746218ea6 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
@@ -67,6 +67,17 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
+vec3 decode_normal (vec2 enc)
+{
+ vec2 fenc = enc*4-2;
+ float f = dot(fenc,fenc);
+ float g = sqrt(1-f/4);
+ vec3 n;
+ n.xy = fenc*g;
+ n.z = 1-f/2;
+ return n;
+}
+
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
@@ -143,7 +154,7 @@ void main()
}
vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
- norm = norm = (norm.xyz-0.5)*2.0;
+ norm = decode_normal(norm.xy);
norm = normalize(norm);
float l_dist = -dot(lv, proj_n);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
index e99329bbf2..27863b0095 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
@@ -54,6 +54,17 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
uniform vec4 viewport;
+vec3 decode_normal (vec2 enc)
+{
+ vec2 fenc = enc*4-2;
+ float f = dot(fenc,fenc);
+ float g = sqrt(1-f/4);
+ vec3 n;
+ n.xy = fenc*g;
+ n.z = 1-f/2;
+ return n;
+}
+
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMap, pos_screen.xy).r;
@@ -84,7 +95,7 @@ void main()
}
vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
- norm = (norm.xyz-0.5)*2.0; // unpack norm
+ norm = decode_normal(norm.xy); // unpack norm
float da = dot(norm, lv);
if (da < 0.0)
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl
index faa54a316e..20a756530a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl
@@ -61,6 +61,6 @@ void main()
/// Gamma correct for WL (soft clip effect).
frag_data[0] = vec4(scaleSoftClip(color.rgb), 1.0);
frag_data[1] = vec4(0.0,0.0,0.0,0.0);
- frag_data[2] = vec4(0,0,1,0);
+ frag_data[2] = vec4(0.5,0.5,0.5,0);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 437a06320e..5f88cca30b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -77,6 +77,17 @@ vec3 vary_AtmosAttenuation;
uniform mat4 inv_proj;
uniform vec2 screen_res;
+vec3 decode_normal (vec2 enc)
+{
+ vec2 fenc = enc*4-2;
+ float f = dot(fenc,fenc);
+ float g = sqrt(1-f/4);
+ vec3 n;
+ n.xy = fenc*g;
+ n.z = 1-f/2;
+ return n;
+}
+
vec4 getPosition_d(vec2 pos_screen, float depth)
{
vec2 sc = pos_screen.xy*2.0;
@@ -276,7 +287,8 @@ void main()
float depth = texture2DRect(depthMap, tc.xy).r;
vec3 pos = getPosition_d(tc, depth).xyz;
vec4 norm = texture2DRect(normalMap, tc);
- norm.xyz = (norm.xyz-0.5)*2.0; // unpack norm
+ float envIntensity = norm.z;
+ norm.xyz = decode_normal(norm.xy); // unpack norm
float da = max(dot(norm.xyz, sun_dir.xyz), 0.0);
@@ -312,7 +324,7 @@ void main()
//add environmentmap
vec3 env_vec = env_mat * refnormpersp;
col = mix(col.rgb, textureCube(environmentMap, env_vec).rgb,
- max(norm.a-diffuse.a*2.0, 0.0));
+ max(envIntensity-diffuse.a*2.0, 0.0));
}
col = atmosLighting(col);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index 2f18e1a13d..d7f0ab6d8e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -70,6 +70,17 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
+vec3 decode_normal (vec2 enc)
+{
+ vec2 fenc = enc*4-2;
+ float f = dot(fenc,fenc);
+ float g = sqrt(1-f/4);
+ vec3 n;
+ n.xy = fenc*g;
+ n.z = 1-f/2;
+ return n;
+}
+
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
@@ -146,7 +157,7 @@ void main()
}
vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
- norm = vec3((norm.xy-0.5)*2.0, norm.z);
+ norm = decode_normal(norm.xy);
norm = normalize(norm);
float l_dist = -dot(lv, proj_n);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
index bac74cbbef..1470239a71 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
@@ -49,6 +49,17 @@ VARYING vec2 vary_fragcoord;
uniform mat4 inv_proj;
uniform vec2 screen_res;
+vec3 decode_normal (vec2 enc)
+{
+ vec2 fenc = enc*4-2;
+ float f = dot(fenc,fenc);
+ float g = sqrt(1-f/4);
+ vec3 n;
+ n.xy = fenc*g;
+ n.z = 1-f/2;
+ return n;
+}
+
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMap, pos_screen.xy).r;
@@ -123,7 +134,7 @@ void main()
vec4 pos = getPosition(pos_screen);
vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
- norm = (norm.xyz-0.5)*2.0; // unpack norm
+ norm = decode_normal(norm.xy);
frag_color[0] = 1.0;
frag_color[1] = calcAmbientOcclusion(pos, norm);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
index daf1cc7ea2..52a429465f 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
@@ -39,6 +39,12 @@ VARYING vec3 vary_normal;
VARYING vec4 vary_texcoord0;
VARYING vec4 vary_texcoord1;
+vec2 encode_normal(vec3 n)
+{
+ float f = sqrt(8 * n.z + 8);
+ return n.xy / f + 0.5;
+}
+
void main()
{
/// Note: This should duplicate the blending functionality currently used for the terrain rendering.
@@ -56,6 +62,6 @@ void main()
frag_data[0] = vec4(outColor.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0);
vec3 nvn = normalize(vary_normal);
- frag_data[2] = vec4(nvn.xyz * 0.5 + 0.5, 0.0);
+ frag_data[2] = vec4(encode_normal(nvn.xyz), 0.0, 0.0);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
index da253846ef..808750496f 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
@@ -37,6 +37,12 @@ VARYING vec2 vary_texcoord0;
uniform float minimum_alpha;
+vec2 encode_normal(vec3 n)
+{
+ float f = sqrt(8 * n.z + 8);
+ return n.xy / f + 0.5;
+}
+
void main()
{
vec4 col = texture2D(diffuseMap, vary_texcoord0.xy);
@@ -48,5 +54,5 @@ void main()
frag_data[0] = vec4(vertex_color.rgb*col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0);
vec3 nvn = normalize(vary_normal);
- frag_data[2] = vec4(nvn.xyz * 0.5 + 0.5, 0.0);
+ frag_data[2] = vec4(encode_normal(nvn.xyz), 0.0, 0.0);
}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index d237ec6236..b3ab8fd510 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -68,6 +68,17 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
+vec3 decode_normal (vec2 enc)
+{
+ vec2 fenc = enc*4-2;
+ float f = dot(fenc,fenc);
+ float g = sqrt(1-f/4);
+ vec3 n;
+ n.xy = fenc*g;
+ n.z = 1-f/2;
+ return n;
+}
+
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
@@ -155,7 +166,7 @@ void main()
}
vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
- norm = (norm.xyz-0.5)*2.0; // unpack norm
+ norm = decode_normal(norm.xy);
norm = normalize(norm);
float l_dist = -dot(lv, proj_n);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index eafb7d9c75..de9b2cd0d1 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -79,6 +79,17 @@ vec3 vary_AmblitColor;
vec3 vary_AdditiveColor;
vec3 vary_AtmosAttenuation;
+vec3 decode_normal (vec2 enc)
+{
+ vec2 fenc = enc*4-2;
+ float f = dot(fenc,fenc);
+ float g = sqrt(1-f/4);
+ vec3 n;
+ n.xy = fenc*g;
+ n.z = 1-f/2;
+ return n;
+}
+
vec4 getPosition_d(vec2 pos_screen, float depth)
{
vec2 sc = pos_screen.xy*2.0;
@@ -279,8 +290,8 @@ void main()
float depth = texture2DRect(depthMap, tc.xy).r;
vec3 pos = getPosition_d(tc, depth).xyz;
vec4 norm = texture2DRect(normalMap, tc);
- norm.xyz = (norm.xyz-0.5)*2.0; // unpack norm
-
+ float envIntensity = norm.z;
+ norm.xyz = decode_normal(norm.xy);
float da = max(dot(norm.xyz, sun_dir.xyz), 0.0);
da = pow(da, 0.7);
@@ -320,7 +331,7 @@ void main()
//add environmentmap
vec3 env_vec = env_mat * refnormpersp;
col = mix(col.rgb, textureCube(environmentMap, env_vec).rgb,
- max(norm.a-diffuse.a*2.0, 0.0));
+ max(envIntensity-diffuse.a*2.0, 0.0));
}
col = atmosLighting(col);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
index af8089ce67..43fc5dbc5e 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -69,6 +69,17 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
+vec3 decode_normal (vec2 enc)
+{
+ vec2 fenc = enc*4-2;
+ float f = dot(fenc,fenc);
+ float g = sqrt(1-f/4);
+ vec3 n;
+ n.xy = fenc*g;
+ n.z = 1-f/2;
+ return n;
+}
+
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
@@ -156,7 +167,7 @@ void main()
}
vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
- norm = (norm.xyz-0.5)*2.0; // unpack norm
+ norm = decode_normal(norm.xy);
norm = normalize(norm);
float l_dist = -dot(lv, proj_n);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 147fb4562e..1e835ae49e 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -65,6 +65,17 @@ uniform float shadow_offset;
uniform float spot_shadow_bias;
uniform float spot_shadow_offset;
+vec3 decode_normal (vec2 enc)
+{
+ vec2 fenc = enc*4-2;
+ float f = dot(fenc,fenc);
+ float g = sqrt(1-f/4);
+ vec3 n;
+ n.xy = fenc*g;
+ n.z = 1-f/2;
+ return n;
+}
+
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMap, pos_screen.xy).r;
@@ -126,7 +137,7 @@ void main()
vec4 pos = getPosition(pos_screen);
vec4 nmap4 = texture2DRect(normalMap, pos_screen);
- nmap4 = vec4((nmap4.xyz-0.5)*2.0,nmap4.w); // unpack norm
+ nmap4 = vec4(decode_normal(nmap4.xy),nmap4.w); // unpack norm
float displace = nmap4.w;
vec3 norm = nmap4.xyz;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
index 907b96ffe4..a995e9cba1 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
@@ -66,6 +66,17 @@ uniform float shadow_offset;
uniform float spot_shadow_bias;
uniform float spot_shadow_offset;
+vec3 decode_normal (vec2 enc)
+{
+ vec2 fenc = enc*4-2;
+ float f = dot(fenc,fenc);
+ float g = sqrt(1-f/4);
+ vec3 n;
+ n.xy = fenc*g;
+ n.z = 1-f/2;
+ return n;
+}
+
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMap, pos_screen.xy).r;
@@ -187,7 +198,7 @@ void main()
vec4 pos = getPosition(pos_screen);
vec4 nmap4 = texture2DRect(normalMap, pos_screen);
- nmap4 = vec4((nmap4.xyz-0.5)*2.0,nmap4.w); // unpack norm
+ nmap4 = vec4(decode_normal(nmap4.xy),nmap4.w); // unpack norm
float displace = nmap4.w;
vec3 norm = nmap4.xyz;
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 3853cfde9e..9af4bed918 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -638,6 +638,7 @@ void LLPanelFace::getState()
llwarns << "failed getChild for 'combobox mattype'" << llendl;
}
getChildView("combobox mattype")->setEnabled(editable);
+
onCommitMaterialsMedia(NULL, this);
//if ( LLMediaEngine::getInstance()->getMediaRenderer () )
@@ -819,43 +820,28 @@ void LLPanelFace::getState()
texture_ctrl->setTentative( FALSE );
texture_ctrl->setEnabled( editable );
texture_ctrl->setImageAssetID( id );
- shinytexture_ctrl->setTentative( FALSE );
- shinytexture_ctrl->setEnabled( editable );
- if (!editable)
- {
- shinytexture_ctrl->setImageAssetID( LLUUID::null );
- bumpytexture_ctrl->setImageAssetID( LLUUID::null );
- }
- bumpytexture_ctrl->setTentative( FALSE );
- bumpytexture_ctrl->setEnabled( editable );
getChildView("combobox alphamode")->setEnabled(editable && mIsAlpha);
getChildView("label alphamode")->setEnabled(editable && mIsAlpha);
getChildView("maskcutoff")->setEnabled(editable && mIsAlpha);
getChildView("label maskcutoff")->setEnabled(editable && mIsAlpha);
}
else if (id.isNull())
- {
- // None selected
- texture_ctrl->setTentative( FALSE );
- texture_ctrl->setEnabled( FALSE );
- texture_ctrl->setImageAssetID( LLUUID::null );
- shinytexture_ctrl->setTentative( FALSE );
- shinytexture_ctrl->setEnabled( FALSE );
- shinytexture_ctrl->setImageAssetID( LLUUID::null );
- bumpytexture_ctrl->setTentative( FALSE );
- bumpytexture_ctrl->setEnabled( FALSE );
- bumpytexture_ctrl->setImageAssetID( LLUUID::null );
- getChildView("combobox alphamode")->setEnabled( FALSE );
- getChildView("label alphamode")->setEnabled( FALSE );
- getChildView("maskcutoff")->setEnabled( FALSE);
- getChildView("label maskcutoff")->setEnabled( FALSE );
- }
- else
- {
- // Tentative: multiple selected with different textures
- texture_ctrl->setTentative( TRUE );
- texture_ctrl->setEnabled( editable );
- texture_ctrl->setImageAssetID( id );
+ {
+ // None selected
+ texture_ctrl->setTentative( FALSE );
+ texture_ctrl->setEnabled( FALSE );
+ texture_ctrl->setImageAssetID( LLUUID::null );
+ getChildView("combobox alphamode")->setEnabled( FALSE );
+ getChildView("label alphamode")->setEnabled( FALSE );
+ getChildView("maskcutoff")->setEnabled( FALSE);
+ getChildView("label maskcutoff")->setEnabled( FALSE );
+ }
+ else
+ {
+ // Tentative: multiple selected with different textures
+ texture_ctrl->setTentative( TRUE );
+ texture_ctrl->setEnabled( editable );
+ texture_ctrl->setImageAssetID( id );
getChildView("combobox alphamode")->setEnabled(editable && mIsAlpha);
getChildView("label alphamode")->setEnabled(editable && mIsAlpha);
getChildView("maskcutoff")->setEnabled(editable && mIsAlpha);
@@ -879,8 +865,8 @@ void LLPanelFace::getState()
}
else
{
- shinytexture_ctrl->setTentative( TRUE );
- shinytexture_ctrl->setEnabled( editable );
+ shinytexture_ctrl->setTentative( TRUE );
+ shinytexture_ctrl->setEnabled( editable );
shinytexture_ctrl->setImageAssetID( specmap_id );
}
}
@@ -888,7 +874,7 @@ void LLPanelFace::getState()
if (bumpytexture_ctrl)
{
if (identical_norm)
- {
+ {
bumpytexture_ctrl->setTentative( FALSE );
bumpytexture_ctrl->setEnabled( editable );
bumpytexture_ctrl->setImageAssetID( normmap_id );
@@ -897,16 +883,16 @@ void LLPanelFace::getState()
{
bumpytexture_ctrl->setTentative( FALSE );
bumpytexture_ctrl->setEnabled( FALSE );
- bumpytexture_ctrl->setImageAssetID( LLUUID::null );
- }
+ bumpytexture_ctrl->setImageAssetID( LLUUID::null );
+ }
else
{
- bumpytexture_ctrl->setTentative( TRUE );
- bumpytexture_ctrl->setEnabled( editable );
+ bumpytexture_ctrl->setTentative( TRUE );
+ bumpytexture_ctrl->setEnabled( editable );
bumpytexture_ctrl->setImageAssetID( normmap_id );
- }
}
}
+ }
// planar align
bool align_planar = false;
@@ -945,6 +931,26 @@ void LLPanelFace::getState()
}
}
+ // Needs to be public and before tex scale settings below to properly reflect
+ // behavior when in planar vs default texgen modes in the
+ // NORSPEC-84 et al
+ //
+ LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT;
+ bool identical_texgen = true;
+ bool identical_planar_texgen = false;
+
+ {
+ struct f11 : public LLSelectedTEGetFunctor<LLTextureEntry::e_texgen>
+ {
+ LLTextureEntry::e_texgen get(LLViewerObject* object, S32 face)
+ {
+ return (LLTextureEntry::e_texgen)(object->getTE(face)->getTexGen());
+ }
+ } func;
+ identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen );
+ identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR));
+ }
+
// Texture scale
{
F32 scale_s = 1.f;
@@ -958,7 +964,11 @@ void LLPanelFace::getState()
identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, scale_s );
identical = align_planar ? identical_planar_aligned : identical;
- getChild<LLUICtrl>("TexScaleU")->setValue(editable ? scale_s : 0);
+
+ F32 scale_u = editable ? scale_s : 0;
+ scale_u *= identical_planar_texgen ? 2.0f : 1.0f;
+
+ getChild<LLUICtrl>("TexScaleU")->setValue(scale_u);
getChild<LLUICtrl>("TexScaleU")->setTentative(LLSD((BOOL)(!identical)));
getChildView("TexScaleU")->setEnabled(editable);
@@ -981,7 +991,10 @@ void LLPanelFace::getState()
identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &shiny_func, scale_s );
identical = align_planar ? identical_planar_aligned : identical;
- getChild<LLUICtrl>("shinyScaleU")->setValue(editable ? scale_s : 0);
+ F32 scale_s_value = editable ? scale_s : 0;
+ scale_s_value *= identical_planar_texgen ? 2.0f : 1.0f;
+
+ getChild<LLUICtrl>("shinyScaleU")->setValue(scale_s_value);
getChild<LLUICtrl>("shinyScaleU")->setTentative(LLSD((BOOL)(!identical)));
getChildView("shinyScaleU")->setEnabled(editable && specmap_id.notNull());
@@ -1004,9 +1017,10 @@ void LLPanelFace::getState()
identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &bump_func, scale_s );
identical = align_planar ? identical_planar_aligned : identical;
-
+ scale_s_value = editable ? scale_s : 0;
+ scale_s_value *= identical_planar_texgen ? 2.0f : 1.0f;
- getChild<LLUICtrl>("bumpyScaleU")->setValue(editable ? scale_s : 0);
+ getChild<LLUICtrl>("bumpyScaleU")->setValue(scale_s_value);
getChild<LLUICtrl>("bumpyScaleU")->setTentative(LLSD((BOOL)(!identical)));
getChildView("bumpyScaleU")->setEnabled(editable && normmap_id.notNull());
}
@@ -1023,7 +1037,10 @@ void LLPanelFace::getState()
identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, scale_t );
identical = align_planar ? identical_planar_aligned : identical;
- getChild<LLUICtrl>("TexScaleV")->setValue(editable ? scale_t : 0);
+ F32 scale_t_value = editable ? scale_t : 0;
+ scale_t_value *= identical_planar_texgen ? 2.0f : 1.0f;
+
+ getChild<LLUICtrl>("TexScaleV")->setValue(scale_t_value);
getChild<LLUICtrl>("TexScaleV")->setTentative(LLSD((BOOL)(!identical)));
getChildView("TexScaleV")->setEnabled(editable);
@@ -1045,7 +1062,11 @@ void LLPanelFace::getState()
identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &shiny_func, scale_t );
identical = align_planar ? identical_planar_aligned : identical;
- getChild<LLUICtrl>("shinyScaleV")->setValue(editable ? scale_t : 0);
+
+ scale_t_value = editable ? scale_t : 0;
+ scale_t_value *= identical_planar_texgen ? 2.0f : 1.0f;
+
+ getChild<LLUICtrl>("shinyScaleV")->setValue(scale_t_value);
getChild<LLUICtrl>("shinyScaleV")->setTentative(LLSD((BOOL)(!identical)));
getChildView("shinyScaleV")->setEnabled(editable && specmap_id.notNull());
@@ -1068,7 +1089,10 @@ void LLPanelFace::getState()
identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &bump_func, scale_t );
identical = align_planar ? identical_planar_aligned : identical;
- getChild<LLUICtrl>("bumpyScaleV")->setValue(editable ? scale_t : 0);
+ scale_t_value = editable ? scale_t : 0.0f;
+ scale_t_value *= identical_planar_texgen ? 2.0f : 1.0f;
+
+ getChild<LLUICtrl>("bumpyScaleV")->setValue(scale_t_value);
getChild<LLUICtrl>("bumpyScaleV")->setTentative(LLSD((BOOL)(!identical)));
getChildView("bumpyScaleV")->setEnabled(editable && normmap_id.notNull());
@@ -1096,7 +1120,7 @@ void LLPanelFace::getState()
{
F32 get(LLViewerObject* object, S32 face)
{
- F32 s = 1.f, t = 1.f;
+ F32 s = 0.f, t = 0.f;
LLMaterial* mat = object->getTE(face)->getMaterialParams().get();
if (mat)
@@ -1118,7 +1142,7 @@ void LLPanelFace::getState()
{
F32 get(LLViewerObject* object, S32 face)
{
- F32 s = 1.f, t = 1.f;
+ F32 s = 0.f, t = 0.f;
LLMaterial* mat = object->getTE(face)->getMaterialParams().get();
if (mat)
@@ -1316,22 +1340,26 @@ void LLPanelFace::getState()
}
+ U8 shiny = 0;
+
// Shiny
- {
- F32 shinyf = 0.f;
- struct f9 : public LLSelectedTEGetFunctor<F32>
+ {
+ struct f9 : public LLSelectedTEGetFunctor<U8>
{
- F32 get(LLViewerObject* object, S32 face)
+ U8 get(LLViewerObject* object, S32 face)
{
- return (F32)(object->getTE(face)->getShiny());
+ return (U8)(object->getTE(face)->getShiny());
}
} func;
- identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, shinyf );
+ identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, shiny );
+
+ LLUUID spec_map_id = getChild<LLTextureCtrl>("shinytexture control")->getImageAssetID();
+
LLCtrlSelectionInterface* combobox_shininess =
childGetSelectionInterface("combobox shininess");
if (combobox_shininess)
{
- combobox_shininess->selectNthItem((S32)shinyf);
+ combobox_shininess->selectNthItem(spec_map_id.isNull() ? (S32)shiny : SHINY_TEXTURE);
}
else
{
@@ -1351,22 +1379,27 @@ void LLPanelFace::getState()
getChildView("label shinycolor")->setEnabled(editable);
}
+ U8 bumpy = 0;
+
// Bumpy
- {
- F32 bumpf = 0.f;
- struct f10 : public LLSelectedTEGetFunctor<F32>
+ {
+ struct f10 : public LLSelectedTEGetFunctor<U8>
{
- F32 get(LLViewerObject* object, S32 face)
+ U8 get(LLViewerObject* object, S32 face)
{
- return (F32)(object->getTE(face)->getBumpmap());
+ return object->getTE(face)->getBumpmap();
}
} func;
- identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, bumpf );
- LLCtrlSelectionInterface* combobox_bumpiness =
- childGetSelectionInterface("combobox bumpiness");
+ identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, bumpy );
+
+ LLUUID norm_map_id = getChild<LLTextureCtrl>("bumpytexture control")->getImageAssetID();
+
+ bumpy = norm_map_id.isNull() ? (S32)bumpy : BUMPY_TEXTURE;
+
+ LLCtrlSelectionInterface* combobox_bumpiness = childGetSelectionInterface("combobox bumpiness");
if (combobox_bumpiness)
- {
- combobox_bumpiness->selectNthItem((S32)bumpf);
+ {
+ combobox_bumpiness->selectNthItem(bumpy);
}
else
{
@@ -1377,22 +1410,12 @@ void LLPanelFace::getState()
getChildView("label bumpiness")->setEnabled(editable);
}
- {
- F32 genf = 0.f;
- struct f11 : public LLSelectedTEGetFunctor<F32>
- {
- F32 get(LLViewerObject* object, S32 face)
- {
- return (F32)(object->getTE(face)->getTexGen());
- }
- } func;
- identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, genf );
- S32 selected_texgen = ((S32) genf) >> TEM_TEX_GEN_SHIFT;
+ {
LLCtrlSelectionInterface* combobox_texgen =
childGetSelectionInterface("combobox texgen");
if (combobox_texgen)
{
- combobox_texgen->selectNthItem(selected_texgen);
+ combobox_texgen->selectNthItem(((S32)selected_texgen) >> 1); // Maps from enum to combobox entry index
}
else
{
@@ -1402,44 +1425,40 @@ void LLPanelFace::getState()
getChild<LLUICtrl>("combobox texgen")->setTentative(!identical);
getChildView("tex gen")->setEnabled(editable);
- if (selected_texgen == 1)
+ if (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)
{
- getChild<LLUICtrl>("TexScaleU")->setValue(2.0f * getChild<LLUICtrl>("TexScaleU")->getValue().asReal() );
- getChild<LLUICtrl>("TexScaleV")->setValue(2.0f * getChild<LLUICtrl>("TexScaleV")->getValue().asReal() );
- getChild<LLUICtrl>("shinyScaleU")->setValue(2.0f * getChild<LLUICtrl>("shinyScaleU")->getValue().asReal() );
- getChild<LLUICtrl>("shinyScaleV")->setValue(2.0f * getChild<LLUICtrl>("shinyScaleV")->getValue().asReal() );
- getChild<LLUICtrl>("bumpyScaleU")->setValue(2.0f * getChild<LLUICtrl>("bumpScaleU")->getValue().asReal() );
- getChild<LLUICtrl>("bumpyScaleV")->setValue(2.0f * getChild<LLUICtrl>("bumpScaleV")->getValue().asReal() );
-
// EXP-1507 (change label based on the mapping mode)
getChild<LLUICtrl>("rpt")->setValue(getString("string repeats per meter"));
}
else
- if (selected_texgen == 0) // FIXME: should not be magic numbers
+ if (selected_texgen == LLTextureEntry::TEX_GEN_DEFAULT)
{
getChild<LLUICtrl>("rpt")->setValue(getString("string repeats per face"));
}
}
{
- F32 fullbrightf = 0.f;
- struct f12 : public LLSelectedTEGetFunctor<F32>
+ U8 fullbright_flag = 0;
+ struct f12 : public LLSelectedTEGetFunctor<U8>
{
- F32 get(LLViewerObject* object, S32 face)
+ U8 get(LLViewerObject* object, S32 face)
{
- return (F32)(object->getTE(face)->getFullbright());
+ return object->getTE(face)->getFullbright();
}
} func;
- identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, fullbrightf );
+ identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, fullbright_flag );
- getChild<LLUICtrl>("checkbox fullbright")->setValue((S32)fullbrightf);
+ getChild<LLUICtrl>("checkbox fullbright")->setValue((S32)(fullbright_flag != 0));
getChildView("checkbox fullbright")->setEnabled(editable);
getChild<LLUICtrl>("checkbox fullbright")->setTentative(!identical);
}
// Repeats per meter
{
- F32 repeats = 1.f;
+ F32 repeats_diff = 1.f;
+ F32 repeats_norm = 1.f;
+ F32 repeats_spec = 1.f;
+
struct f13 : public LLSelectedTEGetFunctor<F32>
{
F32 get(LLViewerObject* object, S32 face)
@@ -1449,18 +1468,97 @@ void LLPanelFace::getState()
// BUG: Only repeats along S axis
// BUG: Only works for boxes.
LLPrimitive::getTESTAxes(face, &s_axis, &t_axis);
- return object->getTE(face)->mScaleS / object->getScale().mV[s_axis];
+ F32 repeats_s = object->getTE(face)->mScaleS / object->getScale().mV[s_axis];
+ F32 repeats_t = object->getTE(face)->mScaleT / object->getScale().mV[t_axis];
+ return llmax(repeats_s, repeats_t);
+ }
+
+ } func_diff;
+ bool identical_diff_repeats = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func_diff, repeats_diff );
+
+ struct f14 : public LLSelectedTEGetFunctor<F32>
+ {
+ F32 get(LLViewerObject* object, S32 face)
+ {
+ LLMaterial* mat = object->getTE(face)->getMaterialParams().get();
+ U32 s_axis = VX;
+ U32 t_axis = VY;
+ F32 repeats_s = 1.0f;
+ F32 repeats_t = 1.0f;
+ if (mat)
+ {
+ mat->getNormalRepeat(repeats_s, repeats_t);
+ repeats_s /= object->getScale().mV[s_axis];
+ repeats_t /= object->getScale().mV[t_axis];
+ }
+ return llmax(repeats_s, repeats_t);
+ }
+
+ } func_norm;
+ BOOL identical_norm_repeats = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func_norm, repeats_norm );
+
+ struct f15 : public LLSelectedTEGetFunctor<F32>
+ {
+ F32 get(LLViewerObject* object, S32 face)
+ {
+ LLMaterial* mat = object->getTE(face)->getMaterialParams().get();
+ U32 s_axis = VX;
+ U32 t_axis = VY;
+ F32 repeats_s = 1.0f;
+ F32 repeats_t = 1.0f;
+ if (mat)
+ {
+ mat->getSpecularRepeat(repeats_s, repeats_t);
+ repeats_s /= object->getScale().mV[s_axis];
+ repeats_t /= object->getScale().mV[t_axis];
+ }
+ return llmax(repeats_s, repeats_t);
}
- } func;
- identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, repeats );
+
+ } func_spec;
+ BOOL identical_spec_repeats = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func_spec, repeats_spec );
- getChild<LLUICtrl>("rptctrl")->setValue(editable ? repeats : 0);
- getChild<LLUICtrl>("rptctrl")->setTentative(!identical);
+
LLComboBox* mComboTexGen = getChild<LLComboBox>("combobox texgen");
if (mComboTexGen)
{
- BOOL enabled = editable && (!mComboTexGen || mComboTexGen->getCurrentIndex() != 1);
+ S32 index = mComboTexGen ? mComboTexGen->getCurrentIndex() : 0;
+ BOOL enabled = editable && (index != 1);
+ BOOL identical = true;
+ F32 repeats = 1.0f;
+
+ U32 material_type = combobox_mattype->getCurrentIndex();
+ switch (material_type)
+ {
+ default:
+ case MATTYPE_DIFFUSE:
+ {
+ enabled = editable && !id.isNull();
+ identical = identical_diff_repeats;
+ repeats = repeats_diff;
+ }
+ break;
+
+ case MATTYPE_SPECULAR:
+ {
+ enabled = (editable && ((shiny == SHINY_TEXTURE) && !specmap_id.isNull()));
+ identical = identical_spec_repeats;
+ repeats = repeats_spec;
+ }
+ break;
+
+ case MATTYPE_NORMAL:
+ {
+ enabled = (editable && ((bumpy == BUMPY_TEXTURE) && !normmap_id.isNull()));
+ identical = identical_norm_repeats;
+ repeats = repeats_norm;
+ }
+ break;
+ }
+
getChildView("rptctrl")->setEnabled(enabled);
+ getChild<LLUICtrl>("rptctrl")->setValue(editable ? repeats : 1.0f);
+ getChild<LLUICtrl>("rptctrl")->setTentative(!identical);
}
}
@@ -1556,7 +1654,8 @@ void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMate
//make a local copy of the material for editing
// (prevents local edits from overwriting client state on shared materials)
- mMaterial = new LLMaterial(*material);
+ mMaterial = new LLMaterial(*material);
+ mMaterialID = material_id;
// Alpha
LLCtrlSelectionInterface* combobox_alphamode =
@@ -1572,6 +1671,20 @@ void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMate
getChild<LLUICtrl>("maskcutoff")->setValue(material->getAlphaMaskCutoff());
updateAlphaControls(getChild<LLComboBox>("combobox alphamode"),this);
+ LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT;
+ bool identical_texgen = true;
+ bool identical_planar_texgen = false;
+
+ struct f44 : public LLSelectedTEGetFunctor<LLTextureEntry::e_texgen>
+ {
+ LLTextureEntry::e_texgen get(LLViewerObject* object, S32 face)
+ {
+ return (LLTextureEntry::e_texgen)(object->getTE(face)->getTexGen());
+ }
+ } func;
+ identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen );
+ identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR));
+
// Shiny (specular)
F32 offset_x, offset_y, repeat_x, repeat_y, rot;
LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("shinytexture control");
@@ -1581,6 +1694,13 @@ void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMate
{
material->getSpecularOffset(offset_x,offset_y);
material->getSpecularRepeat(repeat_x,repeat_y);
+
+ if (identical_planar_texgen)
+ {
+ repeat_x *= 2.0f;
+ repeat_y *= 2.0f;
+ }
+
rot = material->getSpecularRotation();
getChild<LLUICtrl>("shinyScaleU")->setValue(repeat_x);
getChild<LLUICtrl>("shinyScaleV")->setValue(repeat_y);
@@ -1592,7 +1712,7 @@ void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMate
getChild<LLUICtrl>("glossiness")->setValue((F32)(material->getSpecularLightExponent())/255.0);
getChild<LLUICtrl>("environment")->setValue((F32)(material->getEnvironmentIntensity())/255.0);
}
- updateShinyControls(combobox_shininess,this);
+ updateShinyControls(combobox_shininess,this, true);
// Bumpy (normal)
texture_ctrl = getChild<LLTextureCtrl>("bumpytexture control");
@@ -1602,6 +1722,13 @@ void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMate
{
material->getNormalOffset(offset_x,offset_y);
material->getNormalRepeat(repeat_x,repeat_y);
+
+ if (identical_planar_texgen)
+ {
+ repeat_x *= 2.0f;
+ repeat_y *= 2.0f;
+ }
+
rot = material->getNormalRotation();
getChild<LLUICtrl>("bumpyScaleU")->setValue(repeat_x);
getChild<LLUICtrl>("bumpyScaleV")->setValue(repeat_y);
@@ -1609,11 +1736,11 @@ void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMate
getChild<LLUICtrl>("bumpyOffsetU")->setValue(offset_x);
getChild<LLUICtrl>("bumpyOffsetV")->setValue(offset_y);
}
- updateBumpyControls(combobox_bumpiness,this);
+ updateBumpyControls(combobox_bumpiness,this, true);
}
void LLPanelFace::updateMaterial()
-{
+{ // assign current state of UI to material definition for submit to sim
LL_DEBUGS("Materials") << "Entered." << LL_ENDL;
LLComboBox* comboAlphaMode = getChild<LLComboBox>("combobox alphamode");
LLComboBox* comboBumpiness = getChild<LLComboBox>("combobox bumpiness");
@@ -1625,6 +1752,18 @@ void LLPanelFace::updateMaterial()
U32 alpha_mode = comboAlphaMode->getCurrentIndex();
U32 bumpiness = comboBumpiness->getCurrentIndex();
U32 shininess = comboShininess->getCurrentIndex();
+
+ LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT;
+ struct f45 : public LLSelectedTEGetFunctor<LLTextureEntry::e_texgen>
+ {
+ LLTextureEntry::e_texgen get(LLViewerObject* object, S32 face)
+ {
+ return (LLTextureEntry::e_texgen)(object->getTE(face)->getTexGen());
+ }
+ } func;
+ bool identical_texgen = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, selected_texgen );
+ bool identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR));
+
if ((mIsAlpha && (alpha_mode != LLMaterial::DIFFUSE_ALPHA_MODE_BLEND))
|| (bumpiness == BUMPY_TEXTURE)
|| (shininess == SHINY_TEXTURE))
@@ -1637,17 +1776,27 @@ void LLPanelFace::updateMaterial()
mMaterial = LLMaterialPtr(new LLMaterial());
}
- mMaterial->setDiffuseAlphaMode(getChild<LLComboBox>("combobox alphamode")->getCurrentIndex());
- mMaterial->setAlphaMaskCutoff((U8)(getChild<LLUICtrl>("maskcutoff")->getValue().asInteger()));
+ mMaterial->setDiffuseAlphaMode(getChild<LLComboBox>("combobox alphamode")->getCurrentIndex());
+ mMaterial->setAlphaMaskCutoff((U8)(getChild<LLUICtrl>("maskcutoff")->getValue().asInteger()));
+ LLUUID norm_map_id = getChild<LLTextureCtrl>("bumpytexture control")->getImageAssetID();
if (bumpiness == BUMPY_TEXTURE)
{
LL_DEBUGS("Materials") << "Setting bumpy texture, bumpiness = " << bumpiness << LL_ENDL;
- mMaterial->setNormalID(getChild<LLTextureCtrl>("bumpytexture control")->getImageAssetID());
+ mMaterial->setNormalID(norm_map_id);
+
+ F32 bumpy_scale_u = getChild<LLUICtrl>("bumpyScaleU")->getValue().asReal();
+ F32 bumpy_scale_v = getChild<LLUICtrl>("bumpyScaleV")->getValue().asReal();
+
+ if (identical_planar_texgen)
+ {
+ bumpy_scale_u *= 0.5f;
+ bumpy_scale_v *= 0.5f;
+ }
+
mMaterial->setNormalOffset(getChild<LLUICtrl>("bumpyOffsetU")->getValue().asReal(),
getChild<LLUICtrl>("bumpyOffsetV")->getValue().asReal());
- mMaterial->setNormalRepeat(getChild<LLUICtrl>("bumpyScaleU")->getValue().asReal(),
- getChild<LLUICtrl>("bumpyScaleV")->getValue().asReal());
+ mMaterial->setNormalRepeat(bumpy_scale_u, bumpy_scale_v);
mMaterial->setNormalRotation(getChild<LLUICtrl>("bumpyRot")->getValue().asReal()*DEG_TO_RAD);
}
else
@@ -1659,24 +1808,29 @@ void LLPanelFace::updateMaterial()
mMaterial->setNormalRotation(0.0f);
}
+ LLUUID spec_map_id = getChild<LLTextureCtrl>("shinytexture control")->getImageAssetID();
+
if (shininess == SHINY_TEXTURE)
{
LL_DEBUGS("Materials") << "Setting shiny texture, shininess = " << shininess << LL_ENDL;
- mMaterial->setSpecularID(getChild<LLTextureCtrl>("shinytexture control")->getImageAssetID());
+ mMaterial->setSpecularID(spec_map_id);
mMaterial->setSpecularOffset(getChild<LLUICtrl>("shinyOffsetU")->getValue().asReal(),
getChild<LLUICtrl>("shinyOffsetV")->getValue().asReal());
- mMaterial->setSpecularRepeat(getChild<LLUICtrl>("shinyScaleU")->getValue().asReal(),
- getChild<LLUICtrl>("shinyScaleV")->getValue().asReal());
- mMaterial->setSpecularRotation(getChild<LLUICtrl>("shinyRot")->getValue().asReal()*DEG_TO_RAD);
- //override shininess to 0.2f if this is a new material
- if (new_material)
+ F32 shiny_scale_u = getChild<LLUICtrl>("shinyScaleU")->getValue().asReal();
+ F32 shiny_scale_v = getChild<LLUICtrl>("shinyScaleV")->getValue().asReal();
+
+ if (identical_planar_texgen)
{
- mMaterial->setSpecularLightColor(LLColor4U::white);
- mMaterial->setSpecularLightExponent((U8) (0.2f*255.f));
- mMaterial->setEnvironmentIntensity(0);
+ shiny_scale_u *= 0.5f;
+ shiny_scale_v *= 0.5f;
}
- else
+
+ mMaterial->setSpecularRepeat(shiny_scale_u, shiny_scale_v);
+ mMaterial->setSpecularRotation(getChild<LLUICtrl>("shinyRot")->getValue().asReal()*DEG_TO_RAD);
+
+ //override shininess to 0.2f if this is a new material
+ if (!new_material)
{
mMaterial->setSpecularLightColor(getChild<LLColorSwatchCtrl>("shinycolorswatch")->get());
mMaterial->setSpecularLightExponent((U8)(255*getChild<LLUICtrl>("glossiness")->getValue().asReal()));
@@ -1690,7 +1844,8 @@ void LLPanelFace::updateMaterial()
mMaterial->setSpecularOffset(0.0f,0.0f);
mMaterial->setSpecularRepeat(1.0f,1.0f);
mMaterial->setSpecularRotation(0.0f);
- mMaterial->setSpecularLightExponent(0);
+ mMaterial->setSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR);
+ mMaterial->setSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT);
mMaterial->setEnvironmentIntensity(0);
}
@@ -1850,6 +2005,10 @@ void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata)
self->getChildView("bumpyOffsetU")->setEnabled(texParmsEnable);
self->getChildView("bumpyOffsetV")->setEnabled(texParmsEnable);
self->getChildView("checkbox planar align")->setEnabled(texParmsEnable);
+
+ // Needed to handle transitions to/from media mode
+ // NORSPEC-84
+ updateAlphaControls(ctrl,userdata);
}
// static
@@ -1859,9 +2018,8 @@ void LLPanelFace::onCommitMaterialType(LLUICtrl* ctrl, void* userdata)
// This is here to insure that we properly update shared UI elements
// like the texture ctrls for diffuse/norm/spec so that they are correct
// when switching modes
- //
+ //
self->getState();
- onCommitMaterialsMedia(ctrl, userdata);
}
// static
@@ -1869,6 +2027,13 @@ void LLPanelFace::onCommitBump(LLUICtrl* ctrl, void* userdata)
{
LLPanelFace* self = (LLPanelFace*) userdata;
self->sendBump();
+
+ LLComboBox* combo_bumpy = self->getChild<LLComboBox>("combobox bumpiness");
+ // Need 'true' here to insure that the 'Use Texture' choice is removed
+ // when we select something other than a spec texture
+ //
+ updateBumpyControls(combo_bumpy,self, true);
+ self->updateMaterial();
}
// static
@@ -1879,34 +2044,39 @@ void LLPanelFace::onCommitTexGen(LLUICtrl* ctrl, void* userdata)
}
// static
-void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata)
+void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata, bool mess_with_shiny_combobox)
{
LLPanelFace* self = (LLPanelFace*) userdata;
LLTextureCtrl* texture_ctrl = self->getChild<LLTextureCtrl>("shinytexture control");
LLUUID shiny_texture_ID = texture_ctrl->getImageAssetID();
LL_DEBUGS("Materials") << "Shiny texture selected: " << shiny_texture_ID << LL_ENDL;
LLComboBox* comboShiny = self->getChild<LLComboBox>("combobox shininess");
- if (!comboShiny)
- {
- return;
- }
- if (!shiny_texture_ID.isNull())
+
+ if(mess_with_shiny_combobox)
{
- if (!comboShiny->itemExists(USE_TEXTURE))
+ if (!comboShiny)
{
- comboShiny->add(USE_TEXTURE);
+ return;
}
- comboShiny->setSimple(USE_TEXTURE);
- }
- else
- {
- if (comboShiny->itemExists(USE_TEXTURE))
+ if (!shiny_texture_ID.isNull())
+ {
+ if (!comboShiny->itemExists(USE_TEXTURE))
+ {
+ comboShiny->add(USE_TEXTURE);
+ }
+ comboShiny->setSimple(USE_TEXTURE);
+ }
+ else
{
- // HACK: This depends on adding the "Use texture"
- // item at the end of a list of known length.
- comboShiny->remove(SHINY_TEXTURE);
+ if (comboShiny->itemExists(USE_TEXTURE))
+ {
+ // HACK: This depends on adding the "Use texture"
+ // item at the end of a list of known length.
+ comboShiny->remove(SHINY_TEXTURE);
+ }
}
}
+
LLComboBox* combo_matmedia = self->getChild<LLComboBox>("combobox matmedia");
LLComboBox* combo_mattype = self->getChild<LLComboBox>("combobox mattype");
U32 materials_media = combo_matmedia->getCurrentIndex();
@@ -1924,7 +2094,7 @@ void LLPanelFace::updateShinyControls(LLUICtrl* ctrl, void* userdata)
}
// static
-void LLPanelFace::updateBumpyControls(LLUICtrl* ctrl, void* userdata)
+void LLPanelFace::updateBumpyControls(LLUICtrl* ctrl, void* userdata, bool mess_with_combobox)
{
LLPanelFace* self = (LLPanelFace*) userdata;
LLTextureCtrl* texture_ctrl = self->getChild<LLTextureCtrl>("bumpytexture control");
@@ -1935,21 +2105,25 @@ void LLPanelFace::updateBumpyControls(LLUICtrl* ctrl, void* userdata)
{
return;
}
- if (!bumpy_texture_ID.isNull())
+
+ if (mess_with_combobox)
{
- if (!comboBumpy->itemExists(USE_TEXTURE))
+ if (!bumpy_texture_ID.isNull())
{
- comboBumpy->add(USE_TEXTURE);
+ if (!comboBumpy->itemExists(USE_TEXTURE))
+ {
+ comboBumpy->add(USE_TEXTURE);
+ }
+ comboBumpy->setSimple(USE_TEXTURE);
}
- comboBumpy->setSimple(USE_TEXTURE);
- }
- else
- {
- if (comboBumpy->itemExists(USE_TEXTURE))
+ else
{
- // HACK: This depends on adding the "Use texture"
- // item at the end of a list of known length.
- comboBumpy->remove(BUMPY_TEXTURE);
+ if (comboBumpy->itemExists(USE_TEXTURE))
+ {
+ // HACK: This depends on adding the "Use texture"
+ // item at the end of a list of known length.
+ comboBumpy->remove(BUMPY_TEXTURE);
+ }
}
}
}
@@ -1958,7 +2132,12 @@ void LLPanelFace::updateBumpyControls(LLUICtrl* ctrl, void* userdata)
void LLPanelFace::onCommitShiny(LLUICtrl* ctrl, void* userdata)
{
LLPanelFace* self = (LLPanelFace*) userdata;
- self->sendShiny();
+ self->sendShiny();
+ LLComboBox* combo_shiny = self->getChild<LLComboBox>("combobox shininess");
+ // Need 'true' here to insure that the 'Use Texture' choice is removed
+ // when we select something other than a spec texture
+ //
+ updateShinyControls(combo_shiny,self, true);
self->updateMaterial();
}
@@ -2057,9 +2236,9 @@ void LLPanelFace::onCommitMaterialTexture( const LLSD& data )
LL_DEBUGS("Materials") << data << LL_ENDL;
updateMaterial();
LLComboBox* combo_shiny = getChild<LLComboBox>("combobox shininess");
- updateShinyControls(combo_shiny,this);
+ updateShinyControls(combo_shiny,this, true);
LLComboBox* combo_bumpy = getChild<LLComboBox>("combobox bumpiness");
- updateBumpyControls(combo_bumpy,this);
+ updateBumpyControls(combo_bumpy,this, true);
}
void LLPanelFace::onCancelMaterialTexture(const LLSD& data)
@@ -2067,9 +2246,9 @@ void LLPanelFace::onCancelMaterialTexture(const LLSD& data)
// not sure what to do here other than
updateMaterial();
LLComboBox* combo_shiny = getChild<LLComboBox>("combobox shininess");
- updateShinyControls(combo_shiny,this);
+ updateShinyControls(combo_shiny,this, true);
LLComboBox* combo_bumpy = getChild<LLComboBox>("combobox bumpiness");
- updateBumpyControls(combo_bumpy,this);
+ updateBumpyControls(combo_bumpy,this, true);
}
void LLPanelFace::onSelectMaterialTexture(const LLSD& data)
@@ -2077,9 +2256,9 @@ void LLPanelFace::onSelectMaterialTexture(const LLSD& data)
LL_DEBUGS("Materials") << data << LL_ENDL;
updateMaterial();
LLComboBox* combo_shiny = getChild<LLComboBox>("combobox shininess");
- updateShinyControls(combo_shiny,this);
+ updateShinyControls(combo_shiny,this, true);
LLComboBox* combo_bumpy = getChild<LLComboBox>("combobox bumpiness");
- updateBumpyControls(combo_bumpy,this);
+ updateBumpyControls(combo_bumpy,this, true);
}
//static
@@ -2106,7 +2285,43 @@ void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata)
//F32 repeats_per_meter = self->mCtrlRepeatsPerMeter->get();
F32 repeats_per_meter = (F32)self->getChild<LLUICtrl>("rptctrl")->getValue().asReal();//self->mCtrlRepeatsPerMeter->get();
- LLSelectMgr::getInstance()->selectionTexScaleAutofit( repeats_per_meter );
+
+ LLComboBox* combo_mattype = self->getChild<LLComboBox>("combobox mattype");
+
+ U32 material_type = combo_mattype->getCurrentIndex();
+
+ switch (material_type)
+ {
+ case MATTYPE_DIFFUSE:
+ {
+ LLSelectMgr::getInstance()->selectionTexScaleAutofit( repeats_per_meter );
+ }
+ break;
+
+ case MATTYPE_NORMAL:
+ {
+ LLUICtrl* bumpy_scale_u = self->getChild<LLUICtrl>("bumpyScaleU");
+ LLUICtrl* bumpy_scale_v = self->getChild<LLUICtrl>("bumpyScaleV");
+ bumpy_scale_u->setValue(bumpy_scale_u->getValue().asReal() * repeats_per_meter);
+ bumpy_scale_v->setValue(bumpy_scale_v->getValue().asReal() * repeats_per_meter);
+ self->updateMaterial();
+ }
+ break;
+
+ case MATTYPE_SPECULAR:
+ {
+ LLUICtrl* shiny_scale_u = self->getChild<LLUICtrl>("shinyScaleU");
+ LLUICtrl* shiny_scale_v = self->getChild<LLUICtrl>("shinyScaleV");
+ shiny_scale_u->setValue(shiny_scale_u->getValue().asReal() * repeats_per_meter);
+ shiny_scale_v->setValue(shiny_scale_v->getValue().asReal() * repeats_per_meter);
+ self->updateMaterial();
+ }
+ break;
+
+ default:
+ llassert(false);
+ break;
+ }
}
struct LLPanelFaceSetMediaFunctor : public LLSelectedTEFunctor
@@ -2228,3 +2443,4 @@ void LLPanelFace::onTextureSelectionChanged(LLInventoryItem* itemp)
}
}
}
+
diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h
index a99b4e772f..2138319365 100644
--- a/indra/newview/llpanelface.h
+++ b/indra/newview/llpanelface.h
@@ -93,8 +93,8 @@ protected:
static void onCommitMaterialType( LLUICtrl* ctrl, void* userdata);
static void onCommitBump( LLUICtrl* ctrl, void* userdata);
static void onCommitTexGen( LLUICtrl* ctrl, void* userdata);
- static void updateShinyControls( LLUICtrl* ctrl, void* userdata);
- static void updateBumpyControls( LLUICtrl* ctrl, void* userdata);
+ static void updateShinyControls( LLUICtrl* ctrl, void* userdata, bool mess_with_combobox = false);
+ static void updateBumpyControls( LLUICtrl* ctrl, void* userdata, bool mess_with_combobox = false);
static void onCommitShiny( LLUICtrl* ctrl, void* userdata);
static void updateAlphaControls( LLUICtrl* ctrl, void* userdata);
static void onCommitAlphaMode( LLUICtrl* ctrl, void* userdata);
@@ -134,3 +134,4 @@ private:
};
#endif
+
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index f664e06dd5..b9b4ec9198 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -399,7 +399,7 @@ void validate_framebuffer_object();
bool addDeferredAttachments(LLRenderTarget& target)
{
return target.addColorAttachment(GL_RGBA) && //specular
- target.addColorAttachment(GL_RGBA); //normal+z
+ target.addColorAttachment(GL_RGB10_A2); //normal+z
}
LLPipeline::LLPipeline() :