From f61f5d1c10ee5bb493355ce9a96beb455199e8b3 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Mon, 1 Apr 2013 16:28:28 -0400 Subject: fix typo: Advance -> Advanced --- indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml index 545bd94ddd..708dcf4e95 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml @@ -262,7 +262,7 @@ control_name="RenderDeferred" height="16" initial_value="true" - label="Advance Lighting Model" + label="Advanced Lighting Model" layout="topleft" left_delta="0" name="UseLightShaders" -- cgit v1.2.3 From 8da8e05964710bea633af2bee36a7aa89f3a8656 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 2 Apr 2013 01:47:12 -0500 Subject: NORSPEC-58 Followup -- put back blinn phong, and do gamma correction approximation in light curves. Fix fresnel math. --- .../shaders/class1/deferred/multiPointLightF.glsl | 21 +++++++----- .../shaders/class1/deferred/multiSpotLightF.glsl | 29 +++++++++++++++-- .../shaders/class1/deferred/pointLightF.glsl | 10 +++--- .../shaders/class1/deferred/softenLightF.glsl | 4 ++- .../shaders/class1/deferred/spotLightF.glsl | 25 +++++++++++++-- .../shaders/class2/deferred/multiSpotLightF.glsl | 31 ++++++++++++++++-- .../shaders/class2/deferred/softenLightF.glsl | 5 +-- .../shaders/class2/deferred/spotLightF.glsl | 25 +++++++++++++-- .../shaders/class2/deferred/sunLightF.glsl | 1 + .../shaders/class2/deferred/sunLightSSAOF.glsl | 1 + indra/newview/pipeline.cpp | 37 +++++++++++++++++----- 11 files changed, 156 insertions(+), 33 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl index ad50690c02..c11298aadd 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl @@ -110,14 +110,18 @@ void main() { lv = normalize(lv); da = dot(norm, lv); - + float fa = light_col[i].a+1.0; float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); + dist_atten *= noise; float lit = da * dist_atten; - + + lit = pow(lit,0.7); + vec3 col = light_col[i].rgb*lit*diff; + //vec3 col = vec3(dist2, light_col[i].a, lit); if (spec.a > 0.0) @@ -128,15 +132,16 @@ void main() float nv = dot(norm, npos); float vh = dot(npos, h); float sa = nh; - vec3 fres = spec.rgb + pow(1 - dot(h, npos), 5) * (1 - spec.rgb); + float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + float gtdenom = 2 * nh; float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); - - - if (sa > 0.0) + + if (nh > 0.0) { - vec3 scol = (fres * texture2D(lightFunc, vec2(nh, spec.a)).r * gt) / (nh * da); - col += lit*scol*light_col[i].rgb; + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + col += lit*scol*light_col[i].rgb*spec.rgb; + //col += spec.rgb; } } diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl index bff87cb6aa..09d23db096 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl @@ -40,6 +40,7 @@ uniform sampler2DRect normalMap; uniform samplerCube environmentMap; uniform sampler2D noiseMap; uniform sampler2D projectionMap; +uniform sampler2D lightFunc; uniform mat4 proj_mat; //screen space to light space uniform float proj_near; //near clip for projection @@ -142,7 +143,7 @@ void main() } vec3 norm = texture2DRect(normalMap, frag.xy).xyz; - norm = vec3((norm.xy-0.5)*2.0, norm.z); + norm = norm = (norm.xyz-0.5)*2.0; norm = normalize(norm); float l_dist = -dot(lv, proj_n); @@ -190,6 +191,8 @@ void main() vec3 lcol = color.rgb * plcol.rgb * plcol.a; lit = da * dist_atten * noise; + + lit = pow(lit, 0.7); col = lcol*lit*diff_tex; amb_da += (da*0.5)*proj_ambiance; @@ -236,8 +239,28 @@ void main() stc.x > 0.0 && stc.y > 0.0) { - vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); - col += dist_atten*scol.rgb*color.rgb*scol.a*spec.rgb; + + vec3 npos = -normalize(pos); + lv = pfinal-pos.xyz; + lv = normalize(lv); + + vec3 h = normalize(lv+npos); + float nh = dot(norm, h); + float nv = dot(norm, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + float gtdenom = 2 * nh; + float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh))); + + if (sa > 0.0) + { + float scol = fres * texture2D(lightFunc, vec2(nh, spec.a)).r * gt / (nh * da); + col += scol*color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod).rgb*spec.rgb; + } + + //vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); + //col += dist_atten*scol.rgb*color.rgb*scol.a*spec.rgb; } } } diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index 03b036375b..e99329bbf2 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -102,6 +102,8 @@ void main() float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0); float lit = da * dist_atten * noise; + lit = pow(lit, 0.7); + col = color.rgb*lit*col; vec4 spec = texture2DRect(specularRect, frag.xy); @@ -113,14 +115,14 @@ void main() float nv = dot(norm, npos); float vh = dot(npos, h); float sa = nh; - vec3 fres = spec.rgb + pow(1 - dot(h, npos), 5) * (1 - spec.rgb); + float fres = pow(1 - dot(h, npos), 5) * 0.4+0.5; float gtdenom = 2 * nh; float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh))); - if (sa > 0.0) + if (nh > 0.0) { - vec3 scol = (fres * texture2D(lightFunc, vec2(nh, spec.a)).r * gt) / (nh * da); - col += lit*scol*color.rgb; + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + col += lit*scol*color.rgb*spec.rgb; } } diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index f50935c1a8..437a06320e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -280,6 +280,8 @@ void main() float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); + da = pow(da, 0.7); + vec4 diffuse = texture2DRect(diffuseRect, tc); vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); @@ -300,7 +302,7 @@ void main() // vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); float sa = dot(refnormpersp, sun_dir.xyz); - vec3 dumbshiny = vary_SunlitColor*(6 * texture2D(lightFunc, vec2(sa, spec.a)).r); + vec3 dumbshiny = vary_SunlitColor*(texture2D(lightFunc, vec2(sa, spec.a)).r); // add the two types of shiny together vec3 spec_contrib = dumbshiny * spec.rgb; diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl index cca63872de..2f18e1a13d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl @@ -41,6 +41,8 @@ uniform sampler2DRect normalMap; uniform samplerCube environmentMap; uniform sampler2D noiseMap; uniform sampler2D projectionMap; +uniform sampler2D lightFunc; + uniform mat4 proj_mat; //screen space to light space uniform float proj_near; //near clip for projection @@ -193,6 +195,8 @@ void main() lit = da * dist_atten * noise; + lit = pow(lit, 0.7); + col = lcol*lit*diff_tex; amb_da += (da*0.5)*proj_ambiance; } @@ -238,8 +242,25 @@ void main() stc.x > 0.0 && stc.y > 0.0) { - vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); - col += dist_atten*scol.rgb*color.rgb*scol.a*spec.rgb; + vec3 npos = -normalize(pos); + lv = pfinal-pos.xyz; + lv = normalize(lv); + + vec3 h = normalize(lv+npos); + float nh = dot(norm, h); + float nv = dot(norm, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + + float gtdenom = 2 * nh; + float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh))); + + if (nh > 0.0) + { + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + col += scol*color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod).rgb*spec.rgb; + } } } } diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 5621e47ab7..d237ec6236 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -39,6 +39,7 @@ uniform samplerCube environmentMap; uniform sampler2DRect lightMap; uniform sampler2D noiseMap; uniform sampler2D projectionMap; +uniform sampler2D lightFunc; uniform mat4 proj_mat; //screen space to light space uniform float proj_near; //near clip for projection @@ -177,7 +178,7 @@ void main() lv = proj_origin-pos.xyz; lv = normalize(lv); float da = dot(norm, lv); - + vec3 col = vec3(0,0,0); vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; @@ -203,6 +204,8 @@ void main() lit = da * dist_atten * noise; + lit = pow(lit, 0.7); + col = lcol*lit*diff_tex*shadow; amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; } @@ -241,6 +244,7 @@ void main() float fatten = clamp(spec.a*spec.a+spec.a*0.5, 0.25, 1.0); + //stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5); stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5); if (stc.x < 1.0 && @@ -248,8 +252,29 @@ void main() stc.x > 0.0 && stc.y > 0.0) { - vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); - col += dist_atten*scol.rgb*color.rgb*scol.a*spec.rgb*shadow; + + vec3 npos = -normalize(pos); + lv = pfinal-pos.xyz; + lv = normalize(lv); + + vec3 h = normalize(lv+npos); + float nh = dot(norm, h); + float nv = dot(norm, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + + float gtdenom = 2 * nh; + float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh))); + + if (nh > 0.0) + { + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + col += scol*color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod).rgb*shadow*spec.rgb; + } + + //vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); + //col += dist_atten*scol.rgb*color.rgb*scol.a*spec.rgb*shadow; } } } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index ff20b63972..eafb7d9c75 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -282,7 +282,8 @@ void main() norm.xyz = (norm.xyz-0.5)*2.0; // unpack norm float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); - + da = pow(da, 0.7); + vec4 diffuse = texture2DRect(diffuseRect, tc); vec3 col; @@ -309,7 +310,7 @@ void main() // vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); float sa = dot(refnormpersp, sun_dir.xyz); - vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*(6 * texture2D(lightFunc, vec2(sa, spec.a)).r); + vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*(texture2D(lightFunc, vec2(sa, spec.a)).r); // add the two types of shiny together vec3 spec_contrib = dumbshiny * spec.rgb; diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 6d6ad6d565..af8089ce67 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -39,6 +39,8 @@ uniform samplerCube environmentMap; uniform sampler2DRect lightMap; uniform sampler2D noiseMap; uniform sampler2D projectionMap; +uniform sampler2D lightFunc; + uniform mat4 proj_mat; //screen space to light space uniform float proj_near; //near clip for projection @@ -203,6 +205,8 @@ void main() lit = da * dist_atten * noise; + lit = pow(lit, 0.7); + col = lcol*lit*diff_tex*shadow; amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; } @@ -248,8 +252,25 @@ void main() stc.x > 0.0 && stc.y > 0.0) { - vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod); - col += dist_atten*scol.rgb*color.rgb*scol.a*spec.rgb*shadow; + vec3 npos = -normalize(pos); + lv = pfinal-pos.xyz; + lv = normalize(lv); + + vec3 h = normalize(lv+npos); + float nh = dot(norm, h); + float nv = dot(norm, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + + float gtdenom = 2 * nh; + float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh))); + + if (nh > 0.0) + { + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + col += scol*color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod).rgb*shadow*spec.rgb; + } } } } diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl index 890486c4b1..147fb4562e 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl @@ -138,6 +138,7 @@ void main() float shadow = 0.0; float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz)); + dp_directional_light = pow(dp_directional_light, 0.7); vec3 shadow_pos = pos.xyz + displace*norm; vec3 offset = sun_dir.xyz * (1.0-dp_directional_light); diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl index 2dcd3d656f..907b96ffe4 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl @@ -199,6 +199,7 @@ void main() float shadow = 0.0; float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz)); + dp_directional_light = pow(dp_directional_light, 0.7); vec3 shadow_pos = pos.xyz + displace*norm; vec3 offset = sun_dir.xyz * (1.0-dp_directional_light); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 84fc6a12ec..090d3f8950 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1266,7 +1266,7 @@ void LLPipeline::createLUTBuffers() { if (!mLightFunc) { - U32 lightResX = gSavedSettings.getU32("RenderSpecularResX"); + /*U32 lightResX = gSavedSettings.getU32("RenderSpecularResX"); U32 lightResY = gSavedSettings.getU32("RenderSpecularResY"); U8* ls = new U8[lightResX*lightResY]; F32 specExp = gSavedSettings.getF32("RenderSpecularExponent"); @@ -1302,10 +1302,10 @@ void LLPipeline::createLUTBuffers() // Combined with a bit of noise and trilinear filtering, the banding is hardly noticable. ls[y*lightResX+x] = (U8)(llclamp(spec * (1.f / 6), 0.f, 1.f) * 255); } - } + }*/ - /*U32 lightResX = gSavedSettings.getU32("RenderSpecularResX"); + U32 lightResX = gSavedSettings.getU32("RenderSpecularResX"); U32 lightResY = gSavedSettings.getU32("RenderSpecularResY"); F32* ls = new F32[lightResX*lightResY]; //F32 specExp = gSavedSettings.getF32("RenderSpecularExponent"); // Note: only use this when creating new specular lighting functions. @@ -1327,15 +1327,36 @@ void LLPipeline::createLUTBuffers() // This is fine, given we only need to create our LUT once per buffer initialization. spec *= (((n + 2) * (n + 4)) / (8 * F_PI * (powf(2, -n/2) + n))); + spec = llclamp(spec, 0.f, 1.f); + spec = powf(spec, 0.6f); + // Since we use R16F, we no longer have a dynamic range issue we need to work around here. // Though some older drivers may not like this, newer drivers shouldn't have this problem. ls[y*lightResX+x] = spec; + + + //beckmann distribution + /*F32 alpha = acosf((F32) x/(lightResX-1)); + F32 m = 1.f - (F32) y/(lightResY-1); + + F32 cos4_alpha = cosf(alpha); + cos4_alpha *= cos4_alpha; + cos4_alpha *= cos4_alpha; + + F32 tan_alpha = tanf(alpha); + F32 tan2_alpha = tan_alpha*tan_alpha; + + F32 k = expf(-(tan2_alpha)/(m*m)) / + (3.14159f*m*m*cos4_alpha); + + ls[y*lightResX+x] = k;*/ } - }*/ + } LLImageGL::generateTextures(LLTexUnit::TT_TEXTURE, GL_R8, 1, &mLightFunc); gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc); - LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_R16F, lightResX, lightResY, GL_RED, GL_UNSIGNED_BYTE, ls, false); + LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_R16F, lightResX, lightResY, GL_RED, GL_FLOAT, ls, false); + //LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_UNSIGNED_BYTE, lightResX, lightResY, GL_RED, GL_UNSIGNED_BYTE, ls, false); gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_TRILINEAR); @@ -8255,7 +8276,7 @@ void LLPipeline::renderDeferredLighting() LLFastTimer ftm(FTM_LOCAL_LIGHTS); gDeferredLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s*s); - gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, pow3f(col, 2.2f).mV); + gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); gGL.syncMatrices(); @@ -8311,7 +8332,7 @@ void LLPipeline::renderDeferredLighting() gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s*s); - gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, pow3f(col, 2.2f).mV); + gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); gGL.syncMatrices(); @@ -8402,7 +8423,7 @@ void LLPipeline::renderDeferredLighting() gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, tc.v); gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s*s); - gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, pow3f(col, 2.2f).mV); + gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV); gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f); mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); } -- cgit v1.2.3 From a1a6699684d3f80bd0c3fbb9e845ac9ff0986cec Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Tue, 2 Apr 2013 09:41:57 -0700 Subject: NORSPEC-23 and NORSPEC-47 fix llpanelface issues with reflecting default alpha blend state and presence of multiple textures when editing at face level --- indra/newview/llpanelface.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 754a13dd4c..44f45e9995 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -693,8 +693,25 @@ void LLPanelFace::getState() return image_format; } } func2; - identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func2, image_format ); - mIsAlpha = image_format != GL_RGB; + identical &= LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func2, image_format ); + + mIsAlpha = FALSE; + switch (image_format) + { + case GL_RGBA: + case GL_ALPHA: + { + mIsAlpha = TRUE; + } + break; + + case GL_RGB: break; + default: + { + llinfos << "Unexpected tex format in LLPanelFace...resorting to no alpha" << llendl; + } + break; + } if(LLViewerMedia::textureHasMedia(id)) { -- cgit v1.2.3 From 38ad100a83c7fce40cb6e5b111ad424ee288c88e Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Tue, 2 Apr 2013 09:45:31 -0700 Subject: NORSPEC-73 mac crash on startup with RenderDebugGL on due to false alarm from cubemap unbind --- indra/newview/lldrawpoolbump.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 1b0b11298c..8d1db7b9ad 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -449,9 +449,6 @@ void LLDrawPoolBump::unbindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; if( cube_map ) { - cube_map->disable(); - cube_map->restoreMatrix(); - if (!invisible && shader_level > 1) { shader->disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); @@ -464,6 +461,8 @@ void LLDrawPoolBump::unbindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& } } } + cube_map->disable(); + cube_map->restoreMatrix(); } if (!LLGLSLShader::sNoFixedFunction) -- cgit v1.2.3 From f03899562cc53c59a080b396b2dc7729887422d8 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Tue, 2 Apr 2013 09:47:04 -0700 Subject: Remove redundant fwrite of stats data tripping up linux builds and likely the stats themselves --- indra/newview/llviewerstatsrecorder.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewerstatsrecorder.cpp b/indra/newview/llviewerstatsrecorder.cpp index 97ca08f694..728f04af78 100644 --- a/indra/newview/llviewerstatsrecorder.cpp +++ b/indra/newview/llviewerstatsrecorder.cpp @@ -258,7 +258,6 @@ void LLViewerStatsRecorder::writeToLog( F32 interval ) { llwarns << "Unable to write complete stats record to " << STATS_FILE_NAME << llendl; } - fwrite(data_msg.str().c_str(), 1, data_size, mObjectCacheFile ); clearStats(); } -- cgit v1.2.3 From 53d7db98ffadce190995833b9f785d5ebfa7cf4d Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 2 Apr 2013 15:45:17 -0500 Subject: NORSPEC-74 Fix for assert when Debug GL enabled when rendering materials. --- indra/newview/lldrawpoolmaterials.cpp | 5 ++++- indra/newview/llvovolume.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/lldrawpoolmaterials.cpp b/indra/newview/lldrawpoolmaterials.cpp index d6cca9abe2..3e0f9c9d4d 100644 --- a/indra/newview/lldrawpoolmaterials.cpp +++ b/indra/newview/lldrawpoolmaterials.cpp @@ -113,6 +113,9 @@ void LLDrawPoolMaterials::renderDeferred(S32 pass) llassert(pass < sizeof(type_list)/sizeof(U32)); U32 type = type_list[pass]; + + U32 mask = mShader->mAttributeMask; + LLCullResult::drawinfo_iterator begin = gPipeline.beginRenderMap(type); LLCullResult::drawinfo_iterator end = gPipeline.endRenderMap(type); @@ -137,7 +140,7 @@ void LLDrawPoolMaterials::renderDeferred(S32 pass) mShader->setMinimumAlpha(params.mAlphaMaskCutoff); - pushBatch(params, VERTEX_DATA_MASK, TRUE); + pushBatch(params, mask, TRUE); } } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index fd9f3dc486..8a1f00aa0e 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4771,10 +4771,10 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) genDrawInfo(group, simple_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, simple_faces, FALSE, batch_textures); genDrawInfo(group, fullbright_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, fullbright_faces, FALSE, batch_textures); genDrawInfo(group, alpha_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, alpha_faces, TRUE, batch_textures); - genDrawInfo(group, bump_mask, bump_faces, FALSE, FALSE); - genDrawInfo(group, norm_mask, norm_faces, FALSE, FALSE); - genDrawInfo(group, spec_mask, spec_faces, FALSE, FALSE); - genDrawInfo(group, normspec_mask, normspec_faces, FALSE, FALSE); + genDrawInfo(group, bump_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, bump_faces, FALSE, FALSE); + genDrawInfo(group, norm_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, norm_faces, FALSE, FALSE); + genDrawInfo(group, spec_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, spec_faces, FALSE, FALSE); + genDrawInfo(group, normspec_mask | LLVertexBuffer::MAP_TEXTURE_INDEX, normspec_faces, FALSE, FALSE); if (!LLPipeline::sDelayVBUpdate) { -- cgit v1.2.3 From d0b12d0af50d55d16328ec70833204094adb8bcb Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 2 Apr 2013 18:23:22 -0500 Subject: NORSPEC-70 Hook up material texture parameters to build UI in a way that isn't infuriating to the user. --- indra/newview/llpanelface.cpp | 364 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 316 insertions(+), 48 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 44f45e9995..5f9ddb4e9b 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -647,9 +647,12 @@ void LLPanelFace::getState() LLTextureCtrl* shinytexture_ctrl = getChild("shinytexture control"); LLTextureCtrl* bumpytexture_ctrl = getChild("bumpytexture control"); + LLUUID id; + LLUUID normmap_id; + LLUUID specmap_id; + // Texture { - LLUUID id; struct f1 : public LLSelectedTEGetFunctor { LLUUID get(LLViewerObject* object, S32 te_index) @@ -680,6 +683,45 @@ void LLPanelFace::getState() } func; identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, id ); + // Normal map + struct norm_get : public LLSelectedTEGetFunctor + { + LLUUID get(LLViewerObject* object, S32 te_index) + { + LLUUID id; + + LLMaterial* mat = object->getTE(te_index)->getMaterialParams().get(); + + if (mat) + { + id = mat->getNormalID(); + } + + return id; + } + } norm_get_func; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &norm_get_func, normmap_id ) && identical; + + // Specular map + struct spec_get : public LLSelectedTEGetFunctor + { + LLUUID get(LLViewerObject* object, S32 te_index) + { + LLUUID id; + + LLMaterial* mat = object->getTE(te_index)->getMaterialParams().get(); + + if (mat) + { + id = mat->getSpecularID(); + } + + return id; + } + } spec_get_func; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &spec_get_func, specmap_id ) && identical; + + mIsAlpha = FALSE; LLGLenum image_format; struct f2 : public LLSelectedTEGetFunctor @@ -693,7 +735,7 @@ void LLPanelFace::getState() return image_format; } } func2; - identical &= LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func2, image_format ); + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func2, image_format ) && identical; mIsAlpha = FALSE; switch (image_format) @@ -747,20 +789,27 @@ void LLPanelFace::getState() texture_ctrl->setTentative( FALSE ); texture_ctrl->setEnabled( editable ); texture_ctrl->setImageAssetID( id ); + } + + if (shinytexture_ctrl) + { shinytexture_ctrl->setTentative( FALSE ); shinytexture_ctrl->setEnabled( editable ); - if (!editable) - { - shinytexture_ctrl->setImageAssetID( LLUUID::null ); - bumpytexture_ctrl->setImageAssetID( LLUUID::null ); - } + shinytexture_ctrl->setImageAssetID(specmap_id); + } + + if (bumpytexture_ctrl) + { 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); + bumpytexture_ctrl->setImageAssetID(normmap_id); } + + getChildView("combobox alphamode")->setEnabled(editable && mIsAlpha); + getChildView("label alphamode")->setEnabled(editable && mIsAlpha); + getChildView("maskcutoff")->setEnabled(editable && mIsAlpha); + getChildView("label maskcutoff")->setEnabled(editable && mIsAlpha); + } else { @@ -772,12 +821,6 @@ void LLPanelFace::getState() 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); @@ -789,25 +832,47 @@ void LLPanelFace::getState() texture_ctrl->setTentative( TRUE ); texture_ctrl->setEnabled( editable ); texture_ctrl->setImageAssetID( id ); - shinytexture_ctrl->setTentative( TRUE ); - shinytexture_ctrl->setEnabled( editable ); - if (!editable) - { - shinytexture_ctrl->setImageAssetID( LLUUID::null ); - bumpytexture_ctrl->setImageAssetID( LLUUID::null ); - } - bumpytexture_ctrl->setTentative( TRUE ); - 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); } } + + if (shinytexture_ctrl) + { + if (specmap_id.isNull()) + { + shinytexture_ctrl->setTentative( FALSE ); + shinytexture_ctrl->setEnabled( FALSE ); + shinytexture_ctrl->setImageAssetID( LLUUID::null ); + } + else + { + shinytexture_ctrl->setTentative( FALSE ); + shinytexture_ctrl->setEnabled( FALSE ); + shinytexture_ctrl->setImageAssetID( specmap_id ); + } + } + + if (bumpytexture_ctrl) + { + if (normmap_id.isNull()) + { + bumpytexture_ctrl->setTentative( FALSE ); + bumpytexture_ctrl->setEnabled( FALSE ); + bumpytexture_ctrl->setImageAssetID( LLUUID::null ); + } + else + { + shinytexture_ctrl->setTentative( TRUE ); + shinytexture_ctrl->setEnabled( FALSE ); + shinytexture_ctrl->setImageAssetID( normmap_id); + } + } } } - - + // planar align bool align_planar = false; bool identical_planar_aligned = false; @@ -855,17 +920,60 @@ void LLPanelFace::getState() return object->getTE(face)->mScaleS; } } func; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, scale_s ); identical = align_planar ? identical_planar_aligned : identical; getChild("TexScaleU")->setValue(editable ? scale_s : 0); getChild("TexScaleU")->setTentative(LLSD((BOOL)(!identical))); getChildView("TexScaleU")->setEnabled(editable); + + scale_s = 1.f; + struct f3 : public LLSelectedTEGetFunctor + { + F32 get(LLViewerObject* object, S32 face) + { + F32 s = 1.f, t = 1.f; + + LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); + if (mat) + { + mat->getSpecularRepeat(s, t); + } + return s; + } + } shiny_func; + + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &shiny_func, scale_s ); + identical = align_planar ? identical_planar_aligned : identical; + getChild("shinyScaleU")->setValue(editable ? scale_s : 0); getChild("shinyScaleU")->setTentative(LLSD((BOOL)(!identical))); - getChildView("shinyScaleU")->setEnabled(FALSE); + getChildView("shinyScaleU")->setEnabled(editable && specmap_id.notNull()); + + scale_s = 1.f; + struct f4 : public LLSelectedTEGetFunctor + { + F32 get(LLViewerObject* object, S32 face) + { + F32 s = 1.f, t = 1.f; + + LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); + if (mat) + { + mat->getNormalRepeat(s, t); + } + return s; + } + } bump_func; + + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &bump_func, scale_s ); + identical = align_planar ? identical_planar_aligned : identical; + + + getChild("bumpyScaleU")->setValue(editable ? scale_s : 0); getChild("bumpyScaleU")->setTentative(LLSD((BOOL)(!identical))); - getChildView("bumpyScaleU")->setEnabled(FALSE); + getChildView("bumpyScaleU")->setEnabled(editable && normmap_id.notNull()); } { @@ -883,12 +991,52 @@ void LLPanelFace::getState() getChild("TexScaleV")->setValue(editable ? scale_t : 0); getChild("TexScaleV")->setTentative(LLSD((BOOL)(!identical))); getChildView("TexScaleV")->setEnabled(editable); + + scale_t = 1.f; + struct f4 : public LLSelectedTEGetFunctor + { + F32 get(LLViewerObject* object, S32 face) + { + F32 s = 1.f, t = 1.f; + + LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); + if (mat) + { + mat->getSpecularRepeat(s, t); + } + return t; + } + } shiny_func; + + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &shiny_func, scale_t ); + identical = align_planar ? identical_planar_aligned : identical; getChild("shinyScaleV")->setValue(editable ? scale_t : 0); getChild("shinyScaleV")->setTentative(LLSD((BOOL)(!identical))); - getChildView("shinyScaleV")->setEnabled(FALSE); + getChildView("shinyScaleV")->setEnabled(editable && specmap_id.notNull()); + + scale_t = 1.f; + struct f5 : public LLSelectedTEGetFunctor + { + F32 get(LLViewerObject* object, S32 face) + { + F32 s = 1.f, t = 1.f; + + LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); + if (mat) + { + mat->getNormalRepeat(s, t); + } + return t; + } + } bump_func; + + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &bump_func, scale_t ); + identical = align_planar ? identical_planar_aligned : identical; + getChild("bumpyScaleV")->setValue(editable ? scale_t : 0); getChild("bumpyScaleV")->setTentative(LLSD((BOOL)(!identical))); - getChildView("bumpyScaleV")->setEnabled(FALSE); + getChildView("bumpyScaleV")->setEnabled(editable && normmap_id.notNull()); + } // Texture offset @@ -907,12 +1055,51 @@ void LLPanelFace::getState() getChild("TexOffsetU")->setValue(editable ? offset_s : 0); getChild("TexOffsetU")->setTentative(!identical); getChildView("TexOffsetU")->setEnabled(editable); + + offset_s = 1.f; + struct f3 : public LLSelectedTEGetFunctor + { + F32 get(LLViewerObject* object, S32 face) + { + F32 s = 1.f, t = 1.f; + + LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); + if (mat) + { + mat->getSpecularOffset(s, t); + } + return s; + } + } shiny_func; + + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &shiny_func, offset_s ); + identical = align_planar ? identical_planar_aligned : identical; getChild("shinyOffsetU")->setValue(editable ? offset_s : 0); - getChild("shinyOffsetU")->setTentative(!identical); - getChildView("shinyOffsetU")->setEnabled(FALSE); + getChild("shinyOffsetU")->setTentative(LLSD((BOOL)(!identical))); + getChildView("shinyOffsetU")->setEnabled(editable && specmap_id.notNull()); + + offset_s = 1.f; + struct f5 : public LLSelectedTEGetFunctor + { + F32 get(LLViewerObject* object, S32 face) + { + F32 s = 1.f, t = 1.f; + + LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); + if (mat) + { + mat->getNormalOffset(s, t); + } + return s; + } + } bump_func; + + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &bump_func, offset_s ); + identical = align_planar ? identical_planar_aligned : identical; + getChild("bumpyOffsetU")->setValue(editable ? offset_s : 0); - getChild("bumpyOffsetU")->setTentative(!identical); - getChildView("bumpyOffsetU")->setEnabled(FALSE); + getChild("bumpyOffsetU")->setTentative(LLSD((BOOL)(!identical))); + getChildView("bumpyOffsetU")->setEnabled(editable && normmap_id.notNull()); } { @@ -929,12 +1116,52 @@ void LLPanelFace::getState() getChild("TexOffsetV")->setValue(editable ? offset_t : 0); getChild("TexOffsetV")->setTentative(!identical); getChildView("TexOffsetV")->setEnabled(editable); + + + offset_t = 1.f; + struct f3 : public LLSelectedTEGetFunctor + { + F32 get(LLViewerObject* object, S32 face) + { + F32 s = 1.f, t = 1.f; + + LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); + if (mat) + { + mat->getSpecularOffset(s, t); + } + return t; + } + } shiny_func; + + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &shiny_func, offset_t ); + identical = align_planar ? identical_planar_aligned : identical; getChild("shinyOffsetV")->setValue(editable ? offset_t : 0); - getChild("shinyOffsetV")->setTentative(!identical); - getChildView("shinyOffsetV")->setEnabled(FALSE); + getChild("shinyOffsetV")->setTentative(LLSD((BOOL)(!identical))); + getChildView("shinyOffsetV")->setEnabled(editable && specmap_id.notNull()); + + offset_t = 1.f; + struct f4 : public LLSelectedTEGetFunctor + { + F32 get(LLViewerObject* object, S32 face) + { + F32 s = 1.f, t = 1.f; + + LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); + if (mat) + { + mat->getNormalOffset(s, t); + } + return t; + } + } bump_func; + + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &bump_func, offset_t ); + identical = align_planar ? identical_planar_aligned : identical; + getChild("bumpyOffsetV")->setValue(editable ? offset_t : 0); - getChild("bumpyOffsetV")->setTentative(!identical); - getChildView("bumpyOffsetV")->setEnabled(FALSE); + getChild("bumpyOffsetV")->setTentative(LLSD((BOOL)(!identical))); + getChildView("bumpyOffsetV")->setEnabled(editable && normmap_id.notNull()); } // Texture rotation @@ -952,12 +1179,53 @@ void LLPanelFace::getState() getChild("TexRot")->setValue(editable ? rotation * RAD_TO_DEG : 0); getChild("TexRot")->setTentative(!identical); getChildView("TexRot")->setEnabled(editable); + + + + rotation = 1.f; + struct f3 : public LLSelectedTEGetFunctor + { + F32 get(LLViewerObject* object, S32 face) + { + F32 ret = 0.f; + + LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); + if (mat) + { + ret = mat->getSpecularRotation(); + } + return ret; + } + } shiny_func; + + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &shiny_func, rotation ); + identical = align_planar ? identical_planar_aligned : identical; getChild("shinyRot")->setValue(editable ? rotation * RAD_TO_DEG : 0); - getChild("shinyRot")->setTentative(!identical); - getChildView("shinyRot")->setEnabled(FALSE); + getChild("shinyRot")->setTentative(LLSD((BOOL)(!identical))); + getChildView("shinyRot")->setEnabled(editable && specmap_id.notNull()); + + rotation = 1.f; + struct f4 : public LLSelectedTEGetFunctor + { + F32 get(LLViewerObject* object, S32 face) + { + F32 ret = 0.f; + + LLMaterial* mat = object->getTE(face)->getMaterialParams().get(); + if (mat) + { + ret = mat->getNormalRotation(); + } + return ret; + } + } bump_func; + + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &bump_func, rotation ); + identical = align_planar ? identical_planar_aligned : identical; + getChild("bumpyRot")->setValue(editable ? rotation * RAD_TO_DEG : 0); - getChild("bumpyRot")->setTentative(!identical); - getChildView("bumpyRot")->setEnabled(FALSE); + getChild("bumpyRot")->setTentative(LLSD((BOOL)(!identical))); + getChildView("bumpyRot")->setEnabled(editable && normmap_id.notNull()); } // Color swatch @@ -1103,10 +1371,10 @@ void LLPanelFace::getState() { getChild("TexScaleU")->setValue(2.0f * getChild("TexScaleU")->getValue().asReal() ); getChild("TexScaleV")->setValue(2.0f * getChild("TexScaleV")->getValue().asReal() ); - getChild("shinyScaleU")->setValue(2.0f * getChild("TexScaleU")->getValue().asReal() ); - getChild("shinyScaleV")->setValue(2.0f * getChild("TexScaleV")->getValue().asReal() ); - getChild("bumpyScaleU")->setValue(2.0f * getChild("TexScaleU")->getValue().asReal() ); - getChild("bumpyScaleV")->setValue(2.0f * getChild("TexScaleV")->getValue().asReal() ); + getChild("shinyScaleU")->setValue(2.0f * getChild("shinyScaleU")->getValue().asReal() ); + getChild("shinyScaleV")->setValue(2.0f * getChild("shinyScaleV")->getValue().asReal() ); + getChild("bumpyScaleU")->setValue(2.0f * getChild("bumpScaleU")->getValue().asReal() ); + getChild("bumpyScaleV")->setValue(2.0f * getChild("bumpScaleV")->getValue().asReal() ); // EXP-1507 (change label based on the mapping mode) getChild("rpt")->setValue(getString("string repeats per meter")); -- cgit v1.2.3 From 7a820b88fc45a4a16573387782e1c3f7e412da68 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 3 Apr 2013 16:56:59 -0500 Subject: NORSPEC-71 Lots more UI hookups Written with and Reviewed By Graham --- indra/newview/llpanelface.cpp | 97 +++++++++++++++------- indra/newview/llviewerobject.cpp | 16 +++- indra/newview/llvovolume.cpp | 60 ++++++------- .../skins/default/xui/en/panel_tools_texture.xml | 3 + 4 files changed, 111 insertions(+), 65 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 5f9ddb4e9b..c0aed0f63b 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -301,10 +301,17 @@ void LLPanelFace::sendBump() if (bumpiness < BUMPY_TEXTURE) { LLTextureCtrl* texture_ctrl = getChild("bumpytexture control"); - texture_ctrl->setImageAssetID(LLUUID()); + //texture_ctrl->setImageAssetID(LLUUID()); + texture_ctrl->clear(); + LLSD dummy_data; + onSelectMaterialTexture(dummy_data); } U8 bump = (U8) bumpiness & TEM_BUMP_MASK; LLSelectMgr::getInstance()->selectionSetBumpmap( bump ); + + //refresh material state (in case this change impacts material params) + LLSD dummy_data; + onCommitMaterialTexture(dummy_data); } void LLPanelFace::sendTexGen() @@ -592,7 +599,7 @@ void LLPanelFace::sendTextureInfo() } void LLPanelFace::getState() -{ +{ //set state of UI to match state of texture entry(ies) (calls setEnabled, setValue, etc, but NOT setVisible) LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); if( objectp @@ -760,24 +767,45 @@ void LLPanelFace::getState() getChildView("button align")->setEnabled(editable); } + // Specular map + struct alpha_get : public LLSelectedTEGetFunctor { - // Default alpha mode to None if texture has no alpha, or Alpha Blending if present - // Will be overridden later if a material is present for this face - S32 default_alpha = ALPHAMODE_NONE; - if (mIsAlpha) + U8 get(LLViewerObject* object, S32 te_index) { - default_alpha = ALPHAMODE_BLEND; + U8 ret = 1; + + LLMaterial* mat = object->getTE(te_index)->getMaterialParams().get(); + + if (mat) + { + ret = mat->getDiffuseAlphaMode(); + } + + return ret; } + } alpha_get_func; + + U8 alpha_mode = 1; + LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &alpha_get_func, alpha_mode); + + { LLCtrlSelectionInterface* combobox_alphamode = - childGetSelectionInterface("combobox alphamode"); + childGetSelectionInterface("combobox alphamode"); + if (combobox_alphamode) { - combobox_alphamode->selectNthItem(default_alpha); + if (!mIsAlpha) + { + alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_NONE; + } + + combobox_alphamode->selectNthItem(alpha_mode); } else { llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl; } + updateAlphaControls(getChild("combobox alphamode"),this); } @@ -1432,7 +1460,8 @@ void LLPanelFace::getState() // Materials { mMaterialID = LLMaterialID::null; - mMaterial.reset(); + mMaterial = NULL; + struct f1 : public LLSelectedTEGetFunctor { LLMaterialID get(LLViewerObject* object, S32 te_index) @@ -1515,10 +1544,13 @@ void LLPanelFace::refresh() } void LLPanelFace::onMaterialLoaded(const LLMaterialID& material_id, const LLMaterialPtr material) -{ +{ //laying out UI based on material parameters (calls setVisible on various components) LL_DEBUGS("Materials") << "Loaded material " << material_id.asString() << material->asLLSD() << LL_ENDL; - mMaterial = material; - + + //make a local copy of the material for editing + // (prevents local edits from overwriting client state on shared materials) + mMaterial = new LLMaterial(*material); + // Alpha LLCtrlSelectionInterface* combobox_alphamode = childGetSelectionInterface("combobox alphamode"); @@ -1586,30 +1618,21 @@ void LLPanelFace::updateMaterial() U32 alpha_mode = comboAlphaMode->getCurrentIndex(); U32 bumpiness = comboBumpiness->getCurrentIndex(); U32 shininess = comboShininess->getCurrentIndex(); - if ((mIsAlpha && (alpha_mode != ALPHAMODE_BLEND)) + if ((mIsAlpha && (alpha_mode != LLMaterial::DIFFUSE_ALPHA_MODE_BLEND)) || (bumpiness == BUMPY_TEXTURE) || (shininess == SHINY_TEXTURE)) { // The user's specified something that needs a material. + bool new_material = false; if (!mMaterial) { + new_material = true; mMaterial = LLMaterialPtr(new LLMaterial()); - //set defaults according to UI spec - mMaterial->setSpecularLightColor(LLColor4U::white); - mMaterial->setSpecularLightExponent((U8) (255*0.2f)); - mMaterial->setEnvironmentIntensity(0); - mMaterial->setDiffuseAlphaMode(LLMaterial::DIFFUSE_ALPHA_MODE_NONE); - mMaterial->setAlphaMaskCutoff(0); - } - else - { - mMaterial->setSpecularLightColor(getChild("shinycolorswatch")->get()); - mMaterial->setSpecularLightExponent((U8)(255*getChild("glossiness")->getValue().asReal())); - mMaterial->setEnvironmentIntensity((U8)(255*getChild("environment")->getValue().asReal())); - mMaterial->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); - mMaterial->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); } + mMaterial->setDiffuseAlphaMode(getChild("combobox alphamode")->getCurrentIndex()); + mMaterial->setAlphaMaskCutoff((U8)(getChild("maskcutoff")->getValue().asInteger())); + if (bumpiness == BUMPY_TEXTURE) { LL_DEBUGS("Materials") << "Setting bumpy texture, bumpiness = " << bumpiness << LL_ENDL; @@ -1637,6 +1660,20 @@ void LLPanelFace::updateMaterial() mMaterial->setSpecularRepeat(getChild("shinyScaleU")->getValue().asReal(), getChild("shinyScaleV")->getValue().asReal()); mMaterial->setSpecularRotation(getChild("shinyRot")->getValue().asReal()*DEG_TO_RAD); + + //override shininess to 0.2f if this is a new material + if (new_material) + { + mMaterial->setSpecularLightColor(LLColor4U::white); + mMaterial->setSpecularLightExponent((U8) (0.2f*255.f)); + mMaterial->setEnvironmentIntensity(0); + } + else + { + mMaterial->setSpecularLightColor(getChild("shinycolorswatch")->get()); + mMaterial->setSpecularLightExponent((U8)(255*getChild("glossiness")->getValue().asReal())); + mMaterial->setEnvironmentIntensity((U8)(255*getChild("environment")->getValue().asReal())); + } } else { @@ -1645,6 +1682,8 @@ void LLPanelFace::updateMaterial() mMaterial->setSpecularOffset(0.0f,0.0f); mMaterial->setSpecularRepeat(1.0f,1.0f); mMaterial->setSpecularRotation(0.0f); + mMaterial->setSpecularLightExponent(0); + mMaterial->setEnvironmentIntensity(0); } LL_DEBUGS("Materials") << "Updating material: " << mMaterial->asLLSD() << LL_ENDL; @@ -1656,7 +1695,7 @@ void LLPanelFace::updateMaterial() if (mMaterial || !mMaterialID.isNull()) { LL_DEBUGS("Materials") << "Resetting material entry" << LL_ENDL; - mMaterial.reset(); + mMaterial = NULL; mMaterialID = LLMaterialID::null; // Delete existing material entry... LLSelectMgr::getInstance()->selectionRemoveMaterial(); diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index f1b54e0e01..286604e367 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4045,7 +4045,7 @@ void LLViewerObject::setTE(const U8 te, const LLTextureEntry &texture_entry) const LLUUID& image_id = getTE(te)->getID(); mTEImages[te] = LLViewerTextureManager::getFetchedTexture(image_id, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); - if (getTE(te)->getMaterialParams() != NULL) + if (getTE(te)->getMaterialParams().notNull()) { const LLUUID& norm_id = getTE(te)->getMaterialParams()->getNormalID(); mTENormalMaps[te] = LLViewerTextureManager::getFetchedTexture(norm_id, TRUE, LLViewerTexture::BOOST_BUMP, LLViewerTexture::LOD_TEXTURE); @@ -4094,7 +4094,12 @@ S32 LLViewerObject::setTENormalMapCore(const U8 te, const LLUUID& uuid, LLHost h // uuid == LLUUID::null) { retval = TEM_CHANGE_TEXTURE; - getTE(te)->getMaterialParams()->setNormalID(uuid); + LLTextureEntry* tep = getTE(te); + LLMaterial* mat = tep->getMaterialParams(); + if (mat) + { + mat->setNormalID(uuid); + } mTENormalMaps[te] = LLViewerTextureManager::getFetchedTexture(uuid, TRUE, LLViewerTexture::BOOST_BUMP, LLViewerTexture::LOD_TEXTURE, 0, 0, host); setChanged(TEXTURE); if (mDrawable.notNull()) @@ -4112,7 +4117,12 @@ S32 LLViewerObject::setTESpecularMapCore(const U8 te, const LLUUID& uuid, LLHost // uuid == LLUUID::null) { retval = TEM_CHANGE_TEXTURE; - getTE(te)->getMaterialParams()->setSpecularID(uuid); + LLTextureEntry* tep = getTE(te); + LLMaterial* mat = tep->getMaterialParams(); + if (mat) + { + mat->setSpecularID(uuid); + } mTESpecularMaps[te] = LLViewerTextureManager::getFetchedTexture(uuid, TRUE, LLViewerTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, host); setChanged(TEXTURE); if (mDrawable.notNull()) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 8a1f00aa0e..43c57602f5 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -892,7 +892,7 @@ LLFace* LLVOVolume::addFace(S32 f) { const LLTextureEntry* te = getTE(f); LLViewerTexture* imagep = getTEImage(f); - if (te->getMaterialParams() != NULL) + if (te->getMaterialParams().notNull()) { LLViewerTexture* normalp = getTENormalMap(f); LLViewerTexture* specularp = getTESpecularMap(f); @@ -1395,7 +1395,7 @@ void LLVOVolume::regenFaces() facep->setTEOffset(i); facep->setTexture(getTEImage(i)); - if (facep->getTextureEntry()->getMaterialParams() != NULL) + if (facep->getTextureEntry()->getMaterialParams().notNull()) { facep->setNormalMap(getTENormalMap(i)); facep->setSpecularMap(getTESpecularMap(i)); @@ -1986,19 +1986,15 @@ void LLVOVolume::setTEMaterialParamsCallback(const LLMaterialID &pMaterialID, co S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID) { - if (!pMaterialID.isNull()) + S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); + if (res) { - S32 res = LLViewerObject::setTEMaterialID(te, pMaterialID); - if (res) - { - LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; - LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2)); - gPipeline.markTextured(mDrawable); - mFaceMappingChanged = TRUE; - } - return res; + LL_DEBUGS("MaterialTEs") << " " << pMaterialID.asString() << LL_ENDL; + LLMaterialMgr::instance().get(getRegion()->getRegionID(), pMaterialID, boost::bind(&LLVOVolume::setTEMaterialParamsCallback, this, _1, _2)); + gPipeline.markTextured(mDrawable); + mFaceMappingChanged = TRUE; } - return 0; + return res; } S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams) @@ -4135,26 +4131,24 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, draw_vec.push_back(draw_info); draw_info->mTextureMatrix = tex_mat; draw_info->mModelMatrix = model_mat; - if (!facep->getTextureEntry()->getMaterialID().isNull()) + if (facep->getTextureEntry()->getMaterialParams().notNull()) + { + // We have a material. Update our draw info accordingly. + draw_info->mMaterialID = matid; + LLVector4 specColor; + specColor.mV[0] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[0] * (1.f / 255.f); + specColor.mV[1] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[1] * (1.f / 255.f); + specColor.mV[2] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[2] * (1.f / 255.f); + specColor.mV[3] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightExponent() * (1.f / 255.f); + draw_info->mSpecColor = specColor; + draw_info->mEnvIntensity = facep->getTextureEntry()->getMaterialParams()->getEnvironmentIntensity() * (1.f / 255.f); + draw_info->mAlphaMaskCutoff = facep->getTextureEntry()->getMaterialParams()->getAlphaMaskCutoff() * (1.f / 255.f); + draw_info->mDiffuseAlphaMode = facep->getTextureEntry()->getMaterialParams()->getDiffuseAlphaMode(); + draw_info->mNormalMap = facep->getViewerObject()->getTENormalMap(facep->getTEOffset()); + draw_info->mSpecularMap = facep->getViewerObject()->getTESpecularMap(facep->getTEOffset()); + } + else { - - if (facep->getTextureEntry()->getMaterialParams() != NULL) - { - // We have a material. Update our draw info accordingly. - draw_info->mMaterialID = matid; - LLVector4 specColor; - specColor.mV[0] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[0] * (1.f / 255.f); - specColor.mV[1] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[1] * (1.f / 255.f); - specColor.mV[2] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightColor().mV[2] * (1.f / 255.f); - specColor.mV[3] = facep->getTextureEntry()->getMaterialParams()->getSpecularLightExponent() * (1.f / 255.f); - draw_info->mSpecColor = specColor; - draw_info->mEnvIntensity = facep->getTextureEntry()->getMaterialParams()->getEnvironmentIntensity() * (1.f / 255.f); - draw_info->mAlphaMaskCutoff = facep->getTextureEntry()->getMaterialParams()->getAlphaMaskCutoff() * (1.f / 255.f); - draw_info->mDiffuseAlphaMode = facep->getTextureEntry()->getMaterialParams()->getDiffuseAlphaMode(); - draw_info->mNormalMap = facep->getViewerObject()->getTENormalMap(facep->getTEOffset()); - draw_info->mSpecularMap = facep->getViewerObject()->getTESpecularMap(facep->getTEOffset()); - } - } else { U8 shiny = facep->getTextureEntry()->getShiny(); float alpha[4] = { @@ -4662,7 +4656,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (gPipeline.canUseWindLightShadersOnObjects() && LLPipeline::sRenderBump) { - if (LLPipeline::sRenderDeferred && te->getMaterialParams() != NULL) + if (LLPipeline::sRenderDeferred && te->getMaterialParams().notNull()) { LLMaterial* mat = te->getMaterialParams().get(); if (mat->getNormalID().notNull()) diff --git a/indra/newview/skins/default/xui/en/panel_tools_texture.xml b/indra/newview/skins/default/xui/en/panel_tools_texture.xml index e156b3e07c..5e2caa28a9 100644 --- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml +++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml @@ -209,9 +209,11 @@ layout="topleft" top_pad="4" left_delta="0" + increment="1" name="maskcutoff" width="80" />