diff options
Diffstat (limited to 'indra/newview')
26 files changed, 1384 insertions, 602 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index cd33690075..9508c1dc2d 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10558,6 +10558,17 @@ <key>Value</key> <integer>0</integer> </map> + <key>RenderUseMikktSpace</key> + <map> + <key>Comment</key> + <string>Use Mikkt Space tangents on GLTF materials.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> <key>RenderUseTriStrips</key> <map> <key>Comment</key> diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl index 67f4c59c3f..51afda2791 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl @@ -41,6 +41,7 @@ uniform sampler2D specularMap; VARYING vec2 vary_texcoord0; vec3 linear_to_srgb(vec3 c); +vec2 encode_normal (vec3 n); void main() { @@ -56,5 +57,5 @@ void main() frag_data[0] = vec4(col.rgb, 0.0); frag_data[1] = spec; - frag_data[2] = norm; // TODO: Should .w be set? + frag_data[2] = vec4(encode_normal(norm.xyz),0,GBUFFER_FLAG_HAS_ATMOS); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl new file mode 100644 index 0000000000..c14a30ef39 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl @@ -0,0 +1,359 @@ +/** + * @file class1\deferred\pbralphaF.glsl + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2022, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +/*[EXTRA_CODE_HERE]*/ + +#define PBR_USE_IBL 1 +#define PBR_USE_SUN 1 +#define PBR_USE_IRRADIANCE_HACK 1 + +#define DIFFUSE_ALPHA_MODE_NONE 0 +#define DIFFUSE_ALPHA_MODE_BLEND 1 +#define DIFFUSE_ALPHA_MODE_MASK 2 +#define DIFFUSE_ALPHA_MODE_EMISSIVE 3 + +#define DEBUG_PBR_LIGHT_TYPE 0 // Output Diffuse=0.75, Emissive=0, ORM=0,0,0 + +#define DEBUG_BASIC 0 +#define DEBUG_VERTEX 0 +#define DEBUG_NORMAL_MAP 0 // Output packed normal map "as is" to diffuse +#define DEBUG_NORMAL_OUT 0 // Output unpacked normal to diffuse +#define DEBUG_ORM 0 // Output Occlusion Roughness Metal "as is" to diffuse +#define DEBUG_POSITION 0 + +uniform sampler2D diffuseMap; //always in sRGB space +uniform sampler2D bumpMap; +uniform sampler2D emissiveMap; +uniform sampler2D specularMap; // PBR: Packed: Occlusion, Metal, Roughness + +uniform float metallicFactor; +uniform float roughnessFactor; +uniform vec3 emissiveColor; + +#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO) +uniform sampler2DRect lightMap; +#endif + +uniform samplerCube environmentMap; +uniform mat3 env_mat; +uniform int sun_up_factor; +uniform vec3 sun_dir; +uniform vec3 moon_dir; + +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) + #ifdef DEFINE_GL_FRAGCOLOR + out vec4 frag_color; + #else + #define frag_color gl_FragColor + #endif +#else + #ifdef DEFINE_GL_FRAGCOLOR + out vec4 frag_data[4]; + #else + #define frag_data gl_FragData + #endif +#endif + + +VARYING vec3 vary_position; +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; +#ifdef HAS_NORMAL_MAP +VARYING vec3 vary_normal; +VARYING vec3 vary_mat0; +VARYING vec3 vary_mat1; +VARYING vec3 vary_mat2; +VARYING vec2 vary_texcoord1; +#endif + +#ifdef HAS_SPECULAR_MAP + VARYING vec2 vary_texcoord2; +#endif + +#ifdef HAS_ALPHA_MASK +uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlphaCutoff() +#endif + +// Lights +// See: LLRender::syncLightState() +uniform vec4 light_position[8]; +uniform vec3 light_direction[8]; // spot direction +uniform vec4 light_attenuation[8]; // linear, quadratic, ?, ? +uniform vec3 light_diffuse[8]; + +vec2 encode_normal(vec3 n); +vec3 srgb_to_linear(vec3 c); +vec3 linear_to_srgb(vec3 c); + +// These are in deferredUtil.glsl but we can't set: mFeatures.isDeferred to include it +vec3 BRDFLambertian( vec3 reflect0, vec3 reflect90, vec3 c_diff, float specWeight, float vh ); +vec3 BRDFSpecularGGX( vec3 reflect0, vec3 reflect90, float alphaRoughness, float specWeight, float vh, float nl, float nv, float nh ); +void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao); +void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float nh, out float nl, out float nv, out float vh, out float lightDist); +float calcLegacyDistanceAttenuation(float distance, float falloff); +vec2 getGGX( vec2 brdfPoint ); +void initMaterial( vec3 diffuse, vec3 packedORM, + out float alphaRough, out vec3 c_diff, out vec3 reflect0, out vec3 reflect90, out float specWeight ); +void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyEnv, + vec3 pos, vec3 norm, float glossiness, float envIntensity); + +vec3 hue_to_rgb(float hue); + +// lp = light position +// la = light radius +// fa = falloff +vec3 calcPointLightOrSpotLight(vec3 reflect0, vec3 c_diff, + vec3 lightColor, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, + float la, float fa, float is_pointlight, float ambiance) +{ + vec3 intensity = vec3(0); + + vec3 lv = lp.xyz - v; + vec3 h, l; + float nh, nl, nv, vh, lightDist; + calcHalfVectors(lv,n,v,h,l,nh,nl,nv,vh,lightDist); + + if (lightDist > 0.0) + { + float falloff_factor = (12.0 * fa) - 9.0; + float inverted_la = falloff_factor / la; + + float dist = lightDist / inverted_la; + + float dist_atten = calcLegacyDistanceAttenuation(dist,fa); + if (dist_atten <= 0.0) + return intensity; + + vec3 reflect90 = vec3(1); + float specWeight = 1.0; + + lv = normalize(lv); + float spot = max(dot(-ln, lv), is_pointlight); + nl *= spot * spot; + + if (nl > 0.0) + intensity = dist_atten * nl * lightColor * BRDFLambertian(reflect0, reflect90, c_diff, specWeight, vh); + } + return intensity; +} + +void main() +{ + vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; + vec3 pos = vary_position; + +#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO) + vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; + scol_ambocc = pow(scol_ambocc, vec2(light_gamma)); + float scol = max(scol_ambocc.r, diffuse.a); + float ambocc = scol_ambocc.g; +#else + float scol = 1.0; + float ambocc = 1.0; +#endif + + vec3 sunlit; + vec3 amblit; + vec3 additive; + vec3 atten; + calcAtmosphericVars(pos.xyz, light_dir, ambocc, sunlit, amblit, additive, atten, true); + +// IF .mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; +// vec3 col = vertex_color.rgb * diffuseLookup(vary_texcoord0.xy).rgb; +// else + vec4 albedo = texture2D(diffuseMap, vary_texcoord0.xy).rgba; + albedo.rgb = srgb_to_linear(albedo.rgb); +#ifdef HAS_ALPHA_MASK + if (albedo.a < minimum_alpha) + { + discard; + } +#endif + +// vec3 base = vertex_color.rgb * albedo.rgb * albedo.a; + vec3 base = vertex_color.rgb * albedo.rgb; + +#ifdef HAS_NORMAL_MAP + vec4 norm = texture2D(bumpMap, vary_texcoord1.xy); + norm.xyz = normalize(norm.xyz * 2 - 1); + + vec3 tnorm = vec3(dot(norm.xyz,vary_mat0), + dot(norm.xyz,vary_mat1), + dot(norm.xyz,vary_mat2)); +#else + vec4 norm = vec4(0,0,0,1.0); +// vec3 tnorm = vary_normal; + vec3 tnorm = vec3(0,0,1); +#endif + + tnorm = normalize(tnorm.xyz); + norm.xyz = tnorm.xyz; + + // RGB = Occlusion, Roughness, Metal + // default values, see LLViewerFetchedTexture::sWhiteImagep since roughnessFactor and metallicFactor are multiplied in + // occlusion 1.0 + // roughness 0.0 + // metal 0.0 +#ifdef HAS_SPECULAR_MAP + vec3 packedORM = texture2D(specularMap, vary_texcoord2.xy).rgb; // PBR linear packed Occlusion, Roughness, Metal. See: lldrawpoolapha.cpp +#else + vec3 packedORM = vec3(1,0,0); +#endif + + packedORM.g *= roughnessFactor; + packedORM.b *= metallicFactor; + + vec3 colorEmissive = emissiveColor; +#ifdef HAS_EMISSIVE_MAP + colorEmissive *= texture2D(emissiveMap, vary_texcoord0.xy).rgb; +#endif + + vec3 colorDiffuse = vec3(0); + vec3 colorSpec = vec3(0); + + float IOR = 1.5; // default Index Of Refraction 1.5 (dielectrics) + float ao = packedORM.r; + float perceptualRough = packedORM.g; + float metal = packedORM.b; + + vec3 v = -normalize(vary_position.xyz); + vec3 n = norm.xyz; + vec3 t = vec3(1,0,0); + vec3 b = normalize(cross(n,t)); + vec3 reflectVN = normalize(reflect(-v,n)); + + vec3 h, l; + float nh, nl, nv, vh, lightDist; + calcHalfVectors(light_dir, n, v, h, l, nh, nl, nv, vh, lightDist); + + vec3 c_diff, reflect0, reflect90; + float alphaRough, specWeight; + initMaterial( base, packedORM, alphaRough, c_diff, reflect0, reflect90, specWeight ); + + // Common to RadianceGGX and RadianceLambertian + vec2 brdfPoint = clamp(vec2(nv, perceptualRough), vec2(0,0), vec2(1,1)); + vec2 vScaleBias = getGGX( brdfPoint); // Environment BRDF: scale and bias applied to reflect0 + vec3 fresnelR = max(vec3(1.0 - perceptualRough), reflect0) - reflect0; // roughness dependent fresnel + vec3 kSpec = reflect0 + fresnelR*pow(1.0 - nv, 5.0); + + vec3 legacyenv; + + vec3 irradiance = vec3(0); + vec3 specLight = vec3(0); + float gloss = 1.0 - perceptualRough; + sampleReflectionProbes(irradiance, specLight, legacyenv, pos.xyz, norm.xyz, gloss, 0.0); +#if PBR_USE_IRRADIANCE_HACK + irradiance = max(amblit,irradiance) * ambocc; +#else +irradiance = vec3(amblit); +#endif + + vec3 FssEssGGX = kSpec*vScaleBias.x + vScaleBias.y; +#if PBR_USE_IBL + colorSpec += specWeight * specLight * FssEssGGX; +#endif + + vec3 FssEssLambert = specWeight * kSpec * vScaleBias.x + vScaleBias.y; // NOTE: Very similar to FssEssRadiance but with extra specWeight term + float Ems = 1.0 - (vScaleBias.x + vScaleBias.y); + vec3 avg = specWeight * (reflect0 + (1.0 - reflect0) / 21.0); + vec3 AvgEms = avg * Ems; + vec3 FmsEms = AvgEms * FssEssLambert / (1.0 - AvgEms); + vec3 kDiffuse = c_diff * (1.0 - FssEssLambert + FmsEms); +#if PBR_USE_IBL + colorDiffuse += (FmsEms + kDiffuse) * irradiance; +#endif + + colorDiffuse *= ao; + colorSpec *= ao; + + // Sun/Moon Lighting + if (nl > 0.0 || nv > 0.0) + { + float scale = 4.9; + vec3 sunColor = srgb_to_linear(sunlit * scale); // NOTE: Midday should have strong sunlight + + // scol = sun shadow + vec3 intensity = ambocc * sunColor * nl * scol; + vec3 sunDiffuse = intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh); + vec3 sunSpec = intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh); +#if PBR_USE_SUN + colorDiffuse += sunDiffuse; + colorSpec += sunSpec; +#endif + } + vec3 col = colorDiffuse + colorEmissive + colorSpec; + + vec3 light = vec3(0); + + // Punctual lights +#define LIGHT_LOOP(i) light += calcPointLightOrSpotLight( reflect0, c_diff, srgb_to_linear(light_diffuse[i].rgb), albedo.rgb, pos.xyz, n, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w ); + + LIGHT_LOOP(1) + LIGHT_LOOP(2) + LIGHT_LOOP(3) + LIGHT_LOOP(4) + LIGHT_LOOP(5) + LIGHT_LOOP(6) + LIGHT_LOOP(7) + +#if !defined(LOCAL_LIGHT_KILL) + col += light; +#endif // !defined(LOCAL_LIGHT_KILL) + +#if DEBUG_PBR_LIGHT_TYPE + col.rgb = vec3(0.75); + emissive = vec3(0); + spec.rgb = vec3(0); +#endif +#if DEBUG_BASIC + col.rgb = vec3( 1, 0, 1 ); +#endif +#if DEBUG_VERTEX + col.rgb = vertex_color.rgb; +#endif +#if DEBUG_NORMAL_MAP + col.rgb = texture2D(bumpMap, vary_texcoord1.xy).rgb; +#endif +#if DEBUG_NORMAL_OUT + col.rgb = vary_normal; +#endif +#if DEBUG_ORM + col.rgb = linear_to_srgb(spec); +#endif +#if DEBUG_POSITION + col.rgb = vary_position.xyz; +#endif + +// col.rgb = linear_to_srgb(col.rgb); +// frag_color = vec4(albedo.rgb,albedo.a); +// frag_color = vec4(base.rgb,albedo.a); +// frag_color = vec4(irradiance,albedo.a); +// frag_color = vec4(colorDiffuse,albedo.a); +// frag_color = vec4(colorEmissive,albedo.a); +// frag_color = vec4(sun_dir,albedo.a); +// frag_color = vec4(sunlit,albedo.a); + col = linear_to_srgb(col.rgb); + frag_color = vec4(col,albedo.a); +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl new file mode 100644 index 0000000000..8cc3c11fa1 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl @@ -0,0 +1,134 @@ +/** + * @file class1\deferred\pbralphaV.glsl + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2022, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#define DIFFUSE_ALPHA_MODE_IGNORE 0 +#define DIFFUSE_ALPHA_MODE_BLEND 1 +#define DIFFUSE_ALPHA_MODE_MASK 2 +#define DIFFUSE_ALPHA_MODE_EMISSIVE 3 + +#ifdef HAS_SKIN +uniform mat4 modelview_matrix; +uniform mat4 projection_matrix; +mat4 getObjectSkinnedTransform(); +#else +uniform mat3 normal_matrix; +uniform mat4 modelview_projection_matrix; +#endif + +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) + #if !defined(HAS_SKIN) + uniform mat4 modelview_matrix; + #endif + VARYING vec3 vary_position; +#endif + +uniform mat4 texture_matrix0; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec4 diffuse_color; +ATTRIBUTE vec3 normal; +ATTRIBUTE vec2 texcoord0; + + +#ifdef HAS_NORMAL_MAP +ATTRIBUTE vec4 tangent; +ATTRIBUTE vec2 texcoord1; + +VARYING vec3 vary_mat0; +VARYING vec3 vary_mat1; +VARYING vec3 vary_mat2; + +VARYING vec2 vary_texcoord1; +#else +VARYING vec3 vary_normal; +#endif + +#ifdef HAS_SPECULAR_MAP +ATTRIBUTE vec2 texcoord2; +VARYING vec2 vary_texcoord2; +#endif + +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +void main() +{ +#ifdef HAS_SKIN + mat4 mat = getObjectSkinnedTransform(); + mat = modelview_matrix * mat; + vec3 pos = (mat*vec4(position.xyz,1.0)).xyz; +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) + vary_position = pos; +#endif + gl_Position = projection_matrix*vec4(pos,1.0); +#else + //transform vertex + gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); +#endif + + vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; + +#ifdef HAS_NORMAL_MAP + vary_texcoord1 = (texture_matrix0 * vec4(texcoord1,0,1)).xy; +#endif + +#ifdef HAS_SPECULAR_MAP + vary_texcoord2 = (texture_matrix0 * vec4(texcoord2,0,1)).xy; +#endif + +#ifdef HAS_SKIN + vec3 n = normalize((mat*vec4(normal.xyz+position.xyz,1.0)).xyz-pos.xyz); + #ifdef HAS_NORMAL_MAP + vec3 t = normalize((mat*vec4(tangent.xyz+position.xyz,1.0)).xyz-pos.xyz); + vec3 b = cross(n, t)*tangent.w; + + vary_mat0 = vec3(t.x, b.x, n.x); + vary_mat1 = vec3(t.y, b.y, n.y); + vary_mat2 = vec3(t.z, b.z, n.z); + #else //HAS_NORMAL_MAP + vary_normal = n; + #endif //HAS_NORMAL_MAP +#else //HAS_SKIN + vec3 n = normalize(normal_matrix * normal); + #ifdef HAS_NORMAL_MAP + vec3 t = normalize(normal_matrix * tangent.xyz); + vec3 b = cross(n,t)*tangent.w; + + vary_mat0 = vec3(t.x, b.x, n.x); + vary_mat1 = vec3(t.y, b.y, n.y); + vary_mat2 = vec3(t.z, b.z, n.z); + #else //HAS_NORMAL_MAP + vary_normal = n; + #endif //HAS_NORMAL_MAP +#endif //HAS_SKIN + + vertex_color = diffuse_color; + +#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) + #if !defined(HAS_SKIN) + vary_position = (modelview_matrix*vec4(position.xyz, 1.0)).xyz; + #endif +#endif +} diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl index b5c38bba04..69019667de 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl @@ -42,6 +42,8 @@ uniform vec3 emissiveColor; #ifdef HAS_NORMAL_MAP uniform sampler2D bumpMap; + VARYING vec3 vary_tangent; + flat in float vary_sign; #endif #ifdef HAS_EMISSIVE_MAP @@ -66,9 +68,6 @@ VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; #ifdef HAS_NORMAL_MAP VARYING vec3 vary_normal; -VARYING vec3 vary_mat0; -VARYING vec3 vary_mat1; -VARYING vec3 vary_mat2; VARYING vec2 vary_texcoord1; #endif @@ -76,34 +75,32 @@ VARYING vec2 vary_texcoord1; VARYING vec2 vary_texcoord2; #endif +uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlphaCutoff() + vec2 encode_normal(vec3 n); vec3 linear_to_srgb(vec3 c); -const float M_PI = 3.141592653589793; - void main() { // IF .mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; // vec3 col = vertex_color.rgb * diffuseLookup(vary_texcoord0.xy).rgb; // else - vec3 col = vertex_color.rgb * texture2D(diffuseMap, vary_texcoord0.xy).rgb; + vec4 albedo = texture2D(diffuseMap, vary_texcoord0.xy).rgba; + if (albedo.a < minimum_alpha) + { + discard; + } -#ifdef HAS_NORMAL_MAP - vec4 norm = texture2D(bumpMap, vary_texcoord1.xy); - norm.xyz = norm.xyz * 2 - 1; + vec3 col = vertex_color.rgb * albedo.rgb; - vec3 tnorm = vec3(dot(norm.xyz,vary_mat0), - dot(norm.xyz,vary_mat1), - dot(norm.xyz,vary_mat2)); -#else - vec4 norm = vec4(0,0,0,1.0); -// vec3 tnorm = vary_normal; - vec3 tnorm = vec3(0,0,1); -#endif - - tnorm = normalize(tnorm.xyz); + // from mikktspace.com + vec4 vNt = texture2D(bumpMap, vary_texcoord1.xy)*2.0-1.0; + float sign = vary_sign; + vec3 vN = vary_normal; + vec3 vT = vary_tangent.xyz; - norm.xyz = normalize(tnorm.xyz); + vec3 vB = sign * cross(vN, vT); + vec3 tnorm = normalize( vNt.x * vT + vNt.y * vB + vNt.z * vN ); // RGB = Occlusion, Roughness, Metal // default values, see LLViewerTexture::sDefaultPBRORMImagep @@ -148,6 +145,11 @@ void main() col.rgb = vary_position.xyz; #endif + tnorm *= gl_FrontFacing ? 1.0 : -1.0; + + //col = vec3(0,0,0); + //emissive = vary_tangent.xyz*0.5+0.5; + //emissive = vec3(vary_sign*0.5+0.5); // See: C++: addDeferredAttachments(), GLSL: softenLightF frag_data[0] = vec4(col, 0.0); // Diffuse frag_data[1] = vec4(emissive, vertex_color.a); // PBR sRGB Emissive diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl index a2606ed771..e17d91af38 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl @@ -59,13 +59,7 @@ ATTRIBUTE vec2 texcoord0; ATTRIBUTE vec4 tangent; ATTRIBUTE vec2 texcoord1; -VARYING vec3 vary_mat0; -VARYING vec3 vary_mat1; -VARYING vec3 vary_mat2; - VARYING vec2 vary_texcoord1; -#else -VARYING vec3 vary_normal; #endif #ifdef HAS_SPECULAR_MAP @@ -75,6 +69,10 @@ VARYING vec2 vary_texcoord2; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; +VARYING vec3 vary_tangent; +flat out float vary_sign; + +VARYING vec3 vary_normal; void main() { @@ -113,9 +111,9 @@ void main() vec3 t = normalize((mat*vec4(tangent.xyz+position.xyz,1.0)).xyz-pos.xyz); vec3 b = cross(n, t)*tangent.w; - vary_mat0 = vec3(t.x, b.x, n.x); - vary_mat1 = vec3(t.y, b.y, n.y); - vary_mat2 = vec3(t.z, b.z, n.z); + //vary_mat0 = vec3(t.x, b.x, n.x); + //vary_mat1 = vec3(t.y, b.y, n.y); + //vary_mat2 = vec3(t.z, b.z, n.z); #else //HAS_NORMAL_MAP vary_normal = n; #endif //HAS_NORMAL_MAP @@ -123,12 +121,16 @@ vary_normal = n; vec3 n = normalize(normal_matrix * normal); #ifdef HAS_NORMAL_MAP vec3 t = normalize(normal_matrix * tangent.xyz); - vec3 b = cross(n,t)*tangent.w; + vary_tangent = t; + vary_sign = tangent.w; + vary_normal = n; + + //vec3 b = cross(n,t)*tangent.w; //vec3 t = cross(b,n) * binormal.w; - vary_mat0 = vec3(t.x, b.x, n.x); - vary_mat1 = vec3(t.y, b.y, n.y); - vary_mat2 = vec3(t.z, b.z, n.z); + //vary_mat0 = vec3(t.x, b.x, n.x); + //vary_mat1 = vec3(t.y, b.y, n.y); + //vary_mat2 = vec3(t.z, b.z, n.z); #else //HAS_NORMAL_MAP vary_normal = n; #endif //HAS_NORMAL_MAP diff --git a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl index 4d91395a1b..4681fa1abd 100644 --- a/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/irradianceGenF.glsl @@ -79,7 +79,7 @@ void main() vec3 N = normalize(vary_dir); vec3 up = vec3(0.0, 1.0, 0.0); vec3 right = normalize(cross(up, N)); - up = cross(N, right); + up = normalize(cross(N, right)); const float TWO_PI = PI * 2.0; const float HALF_PI = PI * 0.5; diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl index 3efc9c1689..bc4b4eb7e1 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl @@ -125,6 +125,8 @@ vec4 texture2DLodSpecular(vec2 tc, float lod); vec4 getPosition(vec2 pos_screen); +const float M_PI = 3.14159265; + void main() { #if defined(LOCAL_LIGHT_KILL) @@ -201,8 +203,13 @@ void main() dlit = getProjectedLightDiffuseColor( l_dist, proj_tc.xy ); slit = getProjectedLightSpecularColor( pos, n ); - colorDiffuse = shadow * lit * (dlit*0.5 + BRDFLambertian ( reflect0, reflect90, c_diff , specWeight, vh )); - colorSpec = shadow * lit * (slit + BRDFSpecularGGX( reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh )); + float exposure = M_PI; + dlit *= exposure; + slit *= exposure; + + colorDiffuse = shadow * lit * dlit * BRDFLambertian ( reflect0, reflect90, c_diff , specWeight, vh ); + colorSpec = shadow * lit * slit * BRDFSpecularGGX( reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh ); + colorSpec += shadow * lit * BRDFSpecularGGX( reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh ); #if DEBUG_PBR_SPOT_DIFFUSE colorDiffuse = dlit.rgb; colorSpec = vec3(0); diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index e96b39a149..d78c47a36a 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -337,7 +337,6 @@ void main() #if PBR_USE_IRRADIANCE_HACK irradiance = max(amblit,irradiance) * ambocc; #endif - specLight = srgb_to_linear(specLight); #if DEBUG_PBR_SPECLIGHT051 specLight = vec3(0,0.5,1.0); irradiance = specLight; @@ -669,6 +668,9 @@ else diffuse.rgb = linear_to_srgb(diffuse.rgb); // SL-14035 sampleReflectionProbes(ambenv, glossenv, legacyenv, pos.xyz, norm.xyz, spec.a, envIntensity); + ambenv.rgb = linear_to_srgb(ambenv.rgb); + glossenv.rgb = linear_to_srgb(glossenv.rgb); + legacyenv.rgb = linear_to_srgb(legacyenv.rgb); amblit = max(ambenv, amblit); color.rgb = amblit*ambocc; diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl index 8cdf9e49b4..f23e9db040 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl @@ -99,6 +99,8 @@ vec4 texture2DLodSpecular(vec2 tc, float lod); vec4 getPosition(vec2 pos_screen); +const float M_PI = 3.14159265; + void main() { #if defined(LOCAL_LIGHT_KILL) @@ -173,8 +175,13 @@ void main() dlit = getProjectedLightDiffuseColor( l_dist, proj_tc.xy ); slit = getProjectedLightSpecularColor( pos, n ); - colorDiffuse = shadow * dist_atten * nl * (dlit*0.5 + BRDFLambertian ( reflect0, reflect90, c_diff , specWeight, vh )); - colorSpec = shadow * dist_atten * nl * (slit + BRDFSpecularGGX( reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh )); + float exposure = M_PI; + dlit *= exposure; + slit *= exposure; + + colorDiffuse = shadow * lit * dlit * BRDFLambertian ( reflect0, reflect90, c_diff , specWeight, vh ); + colorSpec = shadow * lit * slit * BRDFSpecularGGX( reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh ); + colorSpec += shadow * lit * BRDFSpecularGGX( reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh ); #if DEBUG_PBR_SPOT_DIFFUSE colorDiffuse = dlit.rgb; colorSpec = vec3(0); diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index a2329d46b7..d5aa980d7e 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2071,6 +2071,7 @@ bool LLAppViewer::cleanup() if (sTextureFetch) { sTextureFetch->shutdown(); + sTextureFetch->waitOnPending(); delete sTextureFetch; sTextureFetch = NULL; } diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 89b8ec1ba2..3d456d069f 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -50,6 +50,8 @@ #include "llglcommonfunc.h" #include "llvoavatar.h" +#include "llenvironment.h" + BOOL LLDrawPoolAlpha::sShowDebugAlpha = FALSE; #define current_shader (LLGLSLShader::sCurBoundShaderPtr) @@ -602,65 +604,118 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) } } - LLRenderPass::applyModelMatrix(params); + LLRenderPass::applyModelMatrix(params); - LLMaterial* mat = NULL; + LLMaterial* mat = NULL; + LLGLTFMaterial *gltf_mat = params.mGLTFMaterial; // Also see: LLPipeline::getPoolTypeFromTE() + bool is_pbr = LLPipeline::sRenderPBR && gltf_mat; - if (deferred_render) - { - mat = params.mMaterial; - } - - if (params.mFullbright) - { - // Turn off lighting if it hasn't already been so. - if (light_enabled || !initialized_lighting) - { - initialized_lighting = TRUE; - target_shader = fullbright_shader; + if (is_pbr && gltf_mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_BLEND) + { + target_shader = &gDeferredPBRAlphaProgram[rigged]; + if (current_shader != target_shader) + { + gPipeline.bindDeferredShader(*target_shader); + } - light_enabled = FALSE; - } - } - // Turn on lighting if it isn't already. - else if (!light_enabled || !initialized_lighting) - { - initialized_lighting = TRUE; - target_shader = simple_shader; - light_enabled = TRUE; - } + if (params.mTexture.notNull()) + { + gGL.getTexUnit(0)->bindFast(params.mTexture); // diffuse + } + else + { + gGL.getTexUnit(0)->bindFast(LLViewerFetchedTexture::sWhiteImagep); + } - if (deferred_render && mat) - { - U32 mask = params.mShaderMask; + if (params.mNormalMap) + { + target_shader->bindTexture(LLShaderMgr::BUMP_MAP, params.mNormalMap); + } + else + { + target_shader->bindTexture(LLShaderMgr::BUMP_MAP, LLViewerFetchedTexture::sFlatNormalImagep); + } - llassert(mask < LLMaterial::SHADER_COUNT); - target_shader = &(gDeferredMaterialProgram[mask]); + if (params.mSpecularMap) + { + target_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, params.mSpecularMap); // PBR linear packed Occlusion, Roughness, Metal. + } + else + { + target_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep); + } - if (LLPipeline::sUnderWaterRender) - { - target_shader = &(gDeferredMaterialWaterProgram[mask]); - } + if (params.mEmissiveMap) + { + target_shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, params.mEmissiveMap); // PBR sRGB Emissive + } + else + { + target_shader->bindTexture(LLShaderMgr::EMISSIVE_MAP, LLViewerFetchedTexture::sWhiteImagep); + } - if (params.mAvatar != nullptr) + target_shader->uniform1f(LLShaderMgr::ROUGHNESS_FACTOR, params.mGLTFMaterial->mRoughnessFactor); + target_shader->uniform1f(LLShaderMgr::METALLIC_FACTOR, params.mGLTFMaterial->mMetallicFactor); + target_shader->uniform3fv(LLShaderMgr::EMISSIVE_COLOR, 1, params.mGLTFMaterial->mEmissiveColor.mV); + } + else + { + if (deferred_render) { - llassert(target_shader->mRiggedVariant != nullptr); - target_shader = target_shader->mRiggedVariant; + mat = params.mMaterial; } - if (current_shader != target_shader) - { - gPipeline.bindDeferredShader(*target_shader); - } - } - else if (!params.mFullbright) - { - target_shader = simple_shader; - } - else - { - target_shader = fullbright_shader; - } + if (params.mFullbright) + { + // Turn off lighting if it hasn't already been so. + if (light_enabled || !initialized_lighting) + { + initialized_lighting = TRUE; + target_shader = fullbright_shader; + + light_enabled = FALSE; + } + } + // Turn on lighting if it isn't already. + else if (!light_enabled || !initialized_lighting) + { + initialized_lighting = TRUE; + target_shader = simple_shader; + light_enabled = TRUE; + } + + if (deferred_render && mat) + { + U32 mask = params.mShaderMask; + + llassert(mask < LLMaterial::SHADER_COUNT); + target_shader = &(gDeferredMaterialProgram[mask]); + + if (LLPipeline::sUnderWaterRender) + { + target_shader = &(gDeferredMaterialWaterProgram[mask]); + } + + if (params.mAvatar != nullptr) + { + llassert(target_shader->mRiggedVariant != nullptr); + target_shader = target_shader->mRiggedVariant; + } + + if (current_shader != target_shader) + { + gPipeline.bindDeferredShader(*target_shader); + } + } + else if (!params.mFullbright) + { + target_shader = simple_shader; + } + else + { + target_shader = fullbright_shader; + } + } if (params.mAvatar != nullptr) { diff --git a/indra/newview/lldrawpoolpbropaque.cpp b/indra/newview/lldrawpoolpbropaque.cpp index 3930e11cf3..e1614904b4 100644 --- a/indra/newview/lldrawpoolpbropaque.cpp +++ b/indra/newview/lldrawpoolpbropaque.cpp @@ -95,6 +95,16 @@ void LLDrawPoolPBROpaque::renderDeferred(S32 pass) for (LLCullResult::drawinfo_iterator i = begin; i != end; ++i) { LLDrawInfo* pparams = *i; + LLGLTFMaterial *mat = pparams->mGLTFMaterial; + + // glTF 2.0 Specification 3.9.4. Alpha Coverage + // mAlphaCutoff is only valid for LLGLTFMaterial::ALPHA_MODE_MASK + F32 min_alpha = -1.0; + if (mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_MASK) + { + min_alpha = mat->mAlphaCutoff; + } + shader->uniform1f(LLShaderMgr::MINIMUM_ALPHA, min_alpha); if (pparams->mTexture.notNull()) { @@ -136,6 +146,8 @@ void LLDrawPoolPBROpaque::renderDeferred(S32 pass) shader->uniform1f(LLShaderMgr::METALLIC_FACTOR, pparams->mGLTFMaterial->mMetallicFactor); shader->uniform3fv(LLShaderMgr::EMISSIVE_COLOR, 1, pparams->mGLTFMaterial->mEmissiveColor.mV); + LLGLDisable cull_face(mat->mDoubleSided ? GL_CULL_FACE : 0); + if (rigged) { if (pparams->mAvatar.notNull() && (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash)) diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 534736e0a4..33d6a205e7 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -2166,14 +2166,19 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, mVertexBuffer->getTangentStrider(tangent, mGeomIndex, mGeomCount, map_range); F32* tangents = (F32*) tangent.get(); - mVObjp->getVolume()->genTangents(f); + LLGLTFMaterial* gltf_mat = tep->getGLTFMaterial(); + static LLCachedControl<bool> use_mikktspace(gSavedSettings, "RenderUseMikktSpace"); + bool mikktspace = use_mikktspace && gltf_mat != nullptr; + + mVObjp->getVolume()->genTangents(f, mikktspace); LLVector4Logical mask; mask.clear(); mask.setElement<3>(); - LLVector4a* src = vf.mTangents; - LLVector4a* end = vf.mTangents+num_vertices; + LLVector4a* tbuff = mikktspace ? vf.mMikktSpaceTangents : vf.mTangents; + LLVector4a* src = tbuff; + LLVector4a* end = tbuff+num_vertices; while (src < end) { diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index f05f0344bd..6461aa71a6 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -1059,24 +1059,39 @@ static void pack_textures( LLPointer<LLImageJ2C>& mr_j2c, LLPointer<LLImageJ2C>& emissive_j2c) { + // NOTE : remove log spam and lossless vs lossy comparisons when the logs are no longer useful + if (albedo_img) { albedo_j2c = LLViewerTextureList::convertToUploadFile(albedo_img); + LL_INFOS() << "Albedo: " << albedo_j2c->getDataSize() << LL_ENDL; } if (normal_img) { normal_j2c = LLViewerTextureList::convertToUploadFile(normal_img); + + LLPointer<LLImageJ2C> test; + test = LLViewerTextureList::convertToUploadFile(normal_img, 1024, true); + + S32 lossy_bytes = normal_j2c->getDataSize(); + S32 lossless_bytes = test->getDataSize(); + + LL_INFOS() << llformat("Lossless vs Lossy: (%d/%d) = %.2f", lossless_bytes, lossy_bytes, (F32)lossless_bytes / lossy_bytes) << LL_ENDL; + + normal_j2c = test; } if (mr_img) { mr_j2c = LLViewerTextureList::convertToUploadFile(mr_img); + LL_INFOS() << "Metallic/Roughness: " << mr_j2c->getDataSize() << LL_ENDL; } if (emissive_img) { emissive_j2c = LLViewerTextureList::convertToUploadFile(emissive_img); + LL_INFOS() << "Emissive: " << emissive_j2c->getDataSize() << LL_ENDL; } } @@ -1559,6 +1574,7 @@ void LLMaterialEditor::getGLTFMaterial(LLGLTFMaterial* mat) mat->mDoubleSided = getDoubleSided(); mat->setAlphaMode(getAlphaMode()); + mat->mAlphaCutoff = getAlphaCutoff(); } void LLMaterialEditor::setFromGLTFMaterial(LLGLTFMaterial* mat) @@ -1576,6 +1592,7 @@ void LLMaterialEditor::setFromGLTFMaterial(LLGLTFMaterial* mat) setDoubleSided(mat->mDoubleSided); setAlphaMode(mat->getAlphaMode()); + setAlphaCutoff(mat->mAlphaCutoff); } void LLMaterialEditor::loadAsset() diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 9300b161f4..ac4c76351d 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -101,7 +101,9 @@ const S32 MATTYPE_SPECULAR = 2; // Specular map const S32 ALPHAMODE_MASK = 2; // Alpha masking mode const S32 BUMPY_TEXTURE = 18; // use supplied normal map const S32 SHINY_TEXTURE = 4; // use supplied specular map -const S32 PBRTYPE_ALBEDO = 0; // PBR ALBEDO +const S32 PBRTYPE_ALBEDO = 0; // PBR Albedo +const S32 PBRTYPE_NORMAL = 1; // PBR Normal +const S32 PBRTYPE_METALLIC = 2; // PBR Metallic BOOST_STATIC_ASSERT(MATTYPE_DIFFUSE == LLRender::DIFFUSE_MAP && MATTYPE_NORMAL == LLRender::NORMAL_MAP && MATTYPE_SPECULAR == LLRender::SPECULAR_MAP); @@ -186,7 +188,6 @@ BOOL LLPanelFace::postBuild() LLColorSwatchCtrl* mShinyColorSwatch; LLComboBox* mComboTexGen; - LLComboBox* mComboMatMedia; LLCheckBoxCtrl *mCheckFullbright; @@ -197,10 +198,11 @@ BOOL LLPanelFace::postBuild() setMouseOpaque(FALSE); - LLTextureCtrl* pbr_ctrl = getChild<LLTextureCtrl>("pbr_control"); + LLTextureCtrl* pbr_ctrl = findChild<LLTextureCtrl>("pbr_control"); if (pbr_ctrl) { - pbr_ctrl->setDefaultImageAssetID(LLUUID(gSavedSettings.getString("DefaultObjectTexture"))); + pbr_ctrl->setDefaultImageAssetID(LLUUID::null); + pbr_ctrl->setBlankImageAssetID(LLUUID::null); // should there be some empty default material? pbr_ctrl->setCommitCallback(boost::bind(&LLPanelFace::onCommitPbr, this, _2)); pbr_ctrl->setOnCancelCallback(boost::bind(&LLPanelFace::onCancelPbr, this, _2)); pbr_ctrl->setOnSelectCallback(boost::bind(&LLPanelFace::onSelectPbr, this, _2)); @@ -319,22 +321,22 @@ BOOL LLPanelFace::postBuild() mComboTexGen->setFollows(FOLLOWS_LEFT | FOLLOWS_TOP); } - mComboMatMedia = getChild<LLComboBox>("combobox matmedia"); - if(mComboMatMedia) + LLComboBox* combo_mat_media = findChild<LLComboBox>("combobox matmedia"); + if(combo_mat_media) { - mComboMatMedia->setCommitCallback(LLPanelFace::onCommitMaterialsMedia,this); - mComboMatMedia->selectNthItem(MATMEDIA_MATERIAL); + combo_mat_media->setCommitCallback(LLPanelFace::onCommitMaterialsMedia,this); + combo_mat_media->selectNthItem(MATMEDIA_MATERIAL); } - LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type"); + LLRadioGroup* radio_mat_type = findChild<LLRadioGroup>("radio_material_type"); if(radio_mat_type) { radio_mat_type->setCommitCallback(LLPanelFace::onCommitMaterialType, this); radio_mat_type->selectNthItem(MATTYPE_DIFFUSE); } - LLRadioGroup* radio_pbr_type = getChild<LLRadioGroup>("radio_pbr_type"); - if (radio_mat_type) + LLRadioGroup* radio_pbr_type = findChild<LLRadioGroup>("radio_pbr_type"); + if (radio_pbr_type) { radio_pbr_type->setCommitCallback(LLPanelFace::onCommitPbrType, this); radio_pbr_type->selectNthItem(PBRTYPE_ALBEDO); @@ -867,35 +869,26 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) getChildView("button align")->setEnabled(editable); LLComboBox* combobox_matmedia = getChild<LLComboBox>("combobox matmedia"); - if (combobox_matmedia) - { - if (combobox_matmedia->getCurrentIndex() < MATMEDIA_MATERIAL) - { - combobox_matmedia->selectNthItem(MATMEDIA_MATERIAL); - } - } - else - { - LL_WARNS() << "failed getChild for 'combobox matmedia'" << LL_ENDL; - } + if (combobox_matmedia->getCurrentIndex() < MATMEDIA_MATERIAL) + { + combobox_matmedia->selectNthItem(MATMEDIA_MATERIAL); + } combobox_matmedia->setEnabled(editable); LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type"); - if(radio_mat_type) - { - if (radio_mat_type->getSelectedIndex() < MATTYPE_DIFFUSE) - { - radio_mat_type->selectNthItem(MATTYPE_DIFFUSE); - } + if (radio_mat_type->getSelectedIndex() < MATTYPE_DIFFUSE) + { + radio_mat_type->selectNthItem(MATTYPE_DIFFUSE); + } + radio_mat_type->setEnabled(editable); - } - else - { - LL_WARNS("Materials") << "failed getChild for 'radio_material_type'" << LL_ENDL; - } + LLRadioGroup* radio_pbr_type = getChild<LLRadioGroup>("radio_pbr_type"); + if (radio_pbr_type->getSelectedIndex() < PBRTYPE_ALBEDO) + { + radio_pbr_type->selectNthItem(PBRTYPE_ALBEDO); + } + radio_pbr_type->setEnabled(editable); - getChildView("radio_material_type")->setEnabled(editable); - getChildView("radio_pbr_type")->setEnabled(editable); getChildView("checkbox_sync_settings")->setEnabled(editable); childSetValue("checkbox_sync_settings", gSavedSettings.getBOOL("SyncMaterialSettings")); updateVisibility(); @@ -906,8 +899,8 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) bool identical_spec = false; // pbr material - bool is_pbr_material = false; - LLTextureCtrl* pbr_ctrl = getChild<LLTextureCtrl>("pbr_control"); + bool has_pbr_material = false; + LLTextureCtrl* pbr_ctrl = findChild<LLTextureCtrl>("pbr_control"); if (pbr_ctrl) { LLUUID pbr_id; @@ -918,7 +911,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) pbr_ctrl->setTentative(identical_pbr ? FALSE : TRUE); pbr_ctrl->setEnabled(editable); pbr_ctrl->setImageAssetID(pbr_id); - is_pbr_material = pbr_id.notNull(); + has_pbr_material = pbr_id.notNull(); } LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("texture control"); @@ -931,9 +924,9 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) // Color swatch { - getChildView("color label")->setEnabled(editable && !is_pbr_material); + getChildView("color label")->setEnabled(editable && !has_pbr_material); } - LLColorSwatchCtrl* mColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch"); + LLColorSwatchCtrl* mColorSwatch = findChild<LLColorSwatchCtrl>("colorswatch"); LLColor4 color = LLColor4::white; bool identical_color = false; @@ -946,17 +939,17 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) mColorSwatch->setOriginal(color); mColorSwatch->set(color, force_set_values || (prev_color != color) || !editable); - mColorSwatch->setValid(editable && !is_pbr_material); - mColorSwatch->setEnabled(editable && !is_pbr_material); + mColorSwatch->setValid(editable && !has_pbr_material); + mColorSwatch->setEnabled(editable && !has_pbr_material); mColorSwatch->setCanApplyImmediately( editable ); } // Color transparency - getChildView("color trans")->setEnabled(editable && !is_pbr_material); + getChildView("color trans")->setEnabled(editable && !has_pbr_material); F32 transparency = (1.f - color.mV[VALPHA]) * 100.f; getChild<LLUICtrl>("ColorTrans")->setValue(editable ? transparency : 0); - getChildView("ColorTrans")->setEnabled(editable && !is_pbr_material); + getChildView("ColorTrans")->setEnabled(editable && !has_pbr_material); // Specular map LLSelectedTEMaterial::getSpecularID(specmap_id, identical_spec); @@ -1215,9 +1208,18 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) getChild<LLUICtrl>("shinyScaleU")->setValue(spec_scale_s); getChild<LLUICtrl>("bumpyScaleU")->setValue(norm_scale_s); - getChildView("TexScaleU")->setEnabled(editable); - getChildView("shinyScaleU")->setEnabled(editable && specmap_id.notNull()); - getChildView("bumpyScaleU")->setEnabled(editable && normmap_id.notNull()); + if (combobox_matmedia->getCurrentIndex() == MATMEDIA_PBR) + { + getChildView("TexScaleU")->setEnabled(editable && has_pbr_material); + getChildView("shinyScaleU")->setEnabled(editable && has_pbr_material); + getChildView("bumpyScaleU")->setEnabled(editable && has_pbr_material); + } + else + { + getChildView("TexScaleU")->setEnabled(editable); + getChildView("shinyScaleU")->setEnabled(editable && specmap_id.notNull()); + getChildView("bumpyScaleU")->setEnabled(editable && normmap_id.notNull()); + } BOOL diff_scale_tentative = !(identical && identical_diff_scale_s); BOOL norm_scale_tentative = !(identical && identical_norm_scale_s); @@ -1254,9 +1256,18 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) BOOL norm_scale_tentative = !identical_norm_scale_t; BOOL spec_scale_tentative = !identical_spec_scale_t; - getChildView("TexScaleV")->setEnabled(editable); - getChildView("shinyScaleV")->setEnabled(editable && specmap_id.notNull()); - getChildView("bumpyScaleV")->setEnabled(editable && normmap_id.notNull()); + if (combobox_matmedia->getCurrentIndex() == MATMEDIA_PBR) + { + getChildView("TexScaleV")->setEnabled(editable && has_pbr_material); + getChildView("shinyScaleV")->setEnabled(editable && has_pbr_material); + getChildView("bumpyScaleV")->setEnabled(editable && has_pbr_material); + } + else + { + getChildView("TexScaleV")->setEnabled(editable); + getChildView("shinyScaleV")->setEnabled(editable && specmap_id.notNull()); + getChildView("bumpyScaleV")->setEnabled(editable && normmap_id.notNull()); + } if (force_set_values) { @@ -1300,9 +1311,18 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) getChild<LLUICtrl>("shinyOffsetU")->setTentative(LLSD(norm_offset_u_tentative)); getChild<LLUICtrl>("bumpyOffsetU")->setTentative(LLSD(spec_offset_u_tentative)); - getChildView("TexOffsetU")->setEnabled(editable); - getChildView("shinyOffsetU")->setEnabled(editable && specmap_id.notNull()); - getChildView("bumpyOffsetU")->setEnabled(editable && normmap_id.notNull()); + if (combobox_matmedia->getCurrentIndex() == MATMEDIA_PBR) + { + getChildView("TexOffsetU")->setEnabled(editable && has_pbr_material); + getChildView("shinyOffsetU")->setEnabled(editable && has_pbr_material); + getChildView("bumpyOffsetU")->setEnabled(editable && has_pbr_material); + } + else + { + getChildView("TexOffsetU")->setEnabled(editable); + getChildView("shinyOffsetU")->setEnabled(editable && specmap_id.notNull()); + getChildView("bumpyOffsetU")->setEnabled(editable && normmap_id.notNull()); + } } { @@ -1330,9 +1350,18 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) getChild<LLUICtrl>("shinyOffsetV")->setTentative(LLSD(norm_offset_v_tentative)); getChild<LLUICtrl>("bumpyOffsetV")->setTentative(LLSD(spec_offset_v_tentative)); - getChildView("TexOffsetV")->setEnabled(editable); - getChildView("shinyOffsetV")->setEnabled(editable && specmap_id.notNull()); - getChildView("bumpyOffsetV")->setEnabled(editable && normmap_id.notNull()); + if (combobox_matmedia->getCurrentIndex() == MATMEDIA_PBR) + { + getChildView("TexOffsetV")->setEnabled(editable && has_pbr_material); + getChildView("shinyOffsetV")->setEnabled(editable && has_pbr_material); + getChildView("bumpyOffsetV")->setEnabled(editable && has_pbr_material); + } + else + { + getChildView("TexOffsetV")->setEnabled(editable); + getChildView("shinyOffsetV")->setEnabled(editable && specmap_id.notNull()); + getChildView("bumpyOffsetV")->setEnabled(editable && normmap_id.notNull()); + } } // Texture rotation @@ -1356,10 +1385,19 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) F32 diff_rot_deg = diff_rotation * RAD_TO_DEG; F32 norm_rot_deg = norm_rotation * RAD_TO_DEG; F32 spec_rot_deg = spec_rotation * RAD_TO_DEG; - - getChildView("TexRot")->setEnabled(editable); - getChildView("shinyRot")->setEnabled(editable && specmap_id.notNull()); - getChildView("bumpyRot")->setEnabled(editable && normmap_id.notNull()); + + if (combobox_matmedia->getCurrentIndex() == MATMEDIA_PBR) + { + getChildView("TexRot")->setEnabled(editable && has_pbr_material); + getChildView("shinyRot")->setEnabled(editable && has_pbr_material); + getChildView("bumpyRot")->setEnabled(editable && has_pbr_material); + } + else + { + getChildView("TexRot")->setEnabled(editable); + getChildView("shinyRot")->setEnabled(editable && specmap_id.notNull()); + getChildView("bumpyRot")->setEnabled(editable && normmap_id.notNull()); + } getChild<LLUICtrl>("TexRot")->setTentative(diff_rot_tentative); getChild<LLUICtrl>("shinyRot")->setTentative(LLSD(norm_rot_tentative)); @@ -1376,8 +1414,8 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) LLSelectedTE::getGlow(glow,identical_glow); getChild<LLUICtrl>("glow")->setValue(glow); getChild<LLUICtrl>("glow")->setTentative(!identical_glow); - getChildView("glow")->setEnabled(editable && !is_pbr_material); - getChildView("glow label")->setEnabled(editable && !is_pbr_material); + getChildView("glow")->setEnabled(editable && !has_pbr_material); + getChildView("glow label")->setEnabled(editable && !has_pbr_material); } { @@ -1425,42 +1463,61 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) LLComboBox* mComboTexGen = getChild<LLComboBox>("combobox texgen"); if (mComboTexGen) - { + { S32 index = mComboTexGen ? mComboTexGen->getCurrentIndex() : 0; - BOOL enabled = editable && (index != 1); - BOOL identical_repeats = true; + bool enabled = editable && (index != 1); + bool identical_repeats = true; + S32 material_selection = combobox_matmedia->getCurrentIndex(); F32 repeats = 1.0f; - U32 material_type = (combobox_matmedia->getCurrentIndex() == MATMEDIA_MATERIAL) ? radio_mat_type->getSelectedIndex() : MATTYPE_DIFFUSE; + U32 material_type = MATTYPE_DIFFUSE; + if (material_selection == MATMEDIA_MATERIAL) + { + material_type = radio_mat_type->getSelectedIndex(); + } + else if (material_selection == MATMEDIA_PBR) + { + enabled = editable && has_pbr_material; + material_type = radio_pbr_type->getSelectedIndex(); + } LLSelectMgr::getInstance()->setTextureChannel(LLRender::eTexIndex(material_type)); - switch (material_type) - { - default: - case MATTYPE_DIFFUSE: - { - enabled = editable && !id.isNull(); - identical_repeats = identical_diff_repeats; - repeats = repeats_diff; - } - break; + switch (material_type) + { + default: + case MATTYPE_DIFFUSE: + { + if (material_selection != MATMEDIA_PBR) + { + enabled = editable && !id.isNull(); + } + identical_repeats = identical_diff_repeats; + repeats = repeats_diff; + } + break; - case MATTYPE_SPECULAR: - { - enabled = (editable && ((shiny == SHINY_TEXTURE) && !specmap_id.isNull())); - identical_repeats = identical_spec_repeats; - repeats = repeats_spec; - } - break; + case MATTYPE_SPECULAR: + { + if (material_selection != MATMEDIA_PBR) + { + enabled = (editable && ((shiny == SHINY_TEXTURE) && !specmap_id.isNull())); + } + identical_repeats = identical_spec_repeats; + repeats = repeats_spec; + } + break; - case MATTYPE_NORMAL: - { - enabled = (editable && ((bumpy == BUMPY_TEXTURE) && !normmap_id.isNull())); - identical_repeats = identical_norm_repeats; - repeats = repeats_norm; - } - break; - } + case MATTYPE_NORMAL: + { + if (material_selection != MATMEDIA_PBR) + { + enabled = (editable && ((bumpy == BUMPY_TEXTURE) && !normmap_id.isNull())); + } + identical_repeats = identical_norm_repeats; + repeats = repeats_norm; + } + break; + } BOOL repeats_tentative = !identical_repeats; @@ -1603,7 +1660,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) clearCtrls(); // Disable non-UICtrls - LLTextureCtrl* pbr_ctrl = getChild<LLTextureCtrl>("pbr_control"); + LLTextureCtrl* pbr_ctrl = findChild<LLTextureCtrl>("pbr_control"); if (pbr_ctrl) { pbr_ctrl->setImageAssetID(LLUUID::null); @@ -1731,25 +1788,32 @@ void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) // static void LLPanelFace::updateVisibility() -{ - LLComboBox* combo_matmedia = getChild<LLComboBox>("combobox matmedia"); - LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type"); - LLComboBox* combo_shininess = getChild<LLComboBox>("combobox shininess"); - LLComboBox* combo_bumpiness = getChild<LLComboBox>("combobox bumpiness"); - if (!radio_mat_type || !combo_matmedia || !combo_shininess || !combo_bumpiness) +{ + LLComboBox* combo_matmedia = findChild<LLComboBox>("combobox matmedia"); + LLRadioGroup* radio_mat_type = findChild<LLRadioGroup>("radio_material_type"); + LLRadioGroup* radio_pbr_type = findChild<LLRadioGroup>("radio_pbr_type"); + LLComboBox* combo_shininess = findChild<LLComboBox>("combobox shininess"); + LLComboBox* combo_bumpiness = findChild<LLComboBox>("combobox bumpiness"); + if (!radio_mat_type || !radio_pbr_type || !combo_matmedia || !combo_shininess || !combo_bumpiness) { LL_WARNS("Materials") << "Combo box not found...exiting." << LL_ENDL; return; } U32 materials_media = combo_matmedia->getCurrentIndex(); U32 material_type = radio_mat_type->getSelectedIndex(); + U32 pbr_type = radio_pbr_type->getSelectedIndex(); bool show_media = (materials_media == MATMEDIA_MEDIA) && combo_matmedia->getEnabled(); bool show_material = materials_media == MATMEDIA_MATERIAL; bool show_pbr = materials_media == MATMEDIA_PBR; bool show_texture = (show_media || (show_material && (material_type == MATTYPE_DIFFUSE) && combo_matmedia->getEnabled())); bool show_bumpiness = show_material && (material_type == MATTYPE_NORMAL) && combo_matmedia->getEnabled(); bool show_shininess = show_material && (material_type == MATTYPE_SPECULAR) && combo_matmedia->getEnabled(); - getChildView("radio_material_type")->setVisible(show_texture); + bool show_pbr_albedo = show_pbr && (pbr_type == PBRTYPE_ALBEDO) && combo_matmedia->getEnabled(); + bool show_pbr_normal = show_pbr && (pbr_type == PBRTYPE_NORMAL) && combo_matmedia->getEnabled(); + bool show_pbr_metallic = show_pbr && (pbr_type == PBRTYPE_METALLIC) && combo_matmedia->getEnabled(); + + radio_mat_type->setVisible(show_material); + radio_pbr_type->setVisible(show_pbr); // Media controls getChildView("media_info")->setVisible(show_media); @@ -1759,19 +1823,20 @@ void LLPanelFace::updateVisibility() // Diffuse texture controls getChildView("texture control")->setVisible(show_texture && show_material); - getChildView("label alphamode")->setVisible(show_texture && (show_material || show_pbr)); - getChildView("combobox alphamode")->setVisible(show_texture && (show_material || show_pbr)); + getChildView("label alphamode")->setVisible((show_texture && show_material) || show_pbr); + getChildView("combobox alphamode")->setVisible((show_texture && show_material) || show_pbr); getChildView("label maskcutoff")->setVisible(false); getChildView("maskcutoff")->setVisible(false); - if (show_texture && show_material) + if ((show_texture && show_material) || show_pbr) { updateAlphaControls(); } - getChildView("TexScaleU")->setVisible(show_texture || show_pbr); - getChildView("TexScaleV")->setVisible(show_texture || show_pbr); - getChildView("TexRot")->setVisible(show_texture || show_pbr); - getChildView("TexOffsetU")->setVisible(show_texture || show_pbr); - getChildView("TexOffsetV")->setVisible(show_texture || show_pbr); + // texture scale and position controls are shared between bpr and non-pbr textures + getChildView("TexScaleU")->setVisible(show_texture || show_pbr_albedo); + getChildView("TexScaleV")->setVisible(show_texture || show_pbr_albedo); + getChildView("TexRot")->setVisible(show_texture || show_pbr_albedo); + getChildView("TexOffsetU")->setVisible(show_texture || show_pbr_albedo); + getChildView("TexOffsetV")->setVisible(show_texture || show_pbr_albedo); // Specular map controls getChildView("shinytexture control")->setVisible(show_shininess); @@ -1787,11 +1852,11 @@ void LLPanelFace::updateVisibility() { updateShinyControls(); } - getChildView("shinyScaleU")->setVisible(show_shininess); - getChildView("shinyScaleV")->setVisible(show_shininess); - getChildView("shinyRot")->setVisible(show_shininess); - getChildView("shinyOffsetU")->setVisible(show_shininess); - getChildView("shinyOffsetV")->setVisible(show_shininess); + getChildView("shinyScaleU")->setVisible(show_shininess || show_pbr_normal); + getChildView("shinyScaleV")->setVisible(show_shininess || show_pbr_normal); + getChildView("shinyRot")->setVisible(show_shininess || show_pbr_normal); + getChildView("shinyOffsetU")->setVisible(show_shininess || show_pbr_normal); + getChildView("shinyOffsetV")->setVisible(show_shininess || show_pbr_normal); // Normal map controls if (show_bumpiness) @@ -1801,15 +1866,14 @@ void LLPanelFace::updateVisibility() getChildView("bumpytexture control")->setVisible(show_bumpiness); getChildView("combobox bumpiness")->setVisible(show_bumpiness); getChildView("label bumpiness")->setVisible(show_bumpiness); - getChildView("bumpyScaleU")->setVisible(show_bumpiness); - getChildView("bumpyScaleV")->setVisible(show_bumpiness); - getChildView("bumpyRot")->setVisible(show_bumpiness); - getChildView("bumpyOffsetU")->setVisible(show_bumpiness); - getChildView("bumpyOffsetV")->setVisible(show_bumpiness); + getChildView("bumpyScaleU")->setVisible(show_bumpiness || show_pbr_metallic); + getChildView("bumpyScaleV")->setVisible(show_bumpiness || show_pbr_metallic); + getChildView("bumpyRot")->setVisible(show_bumpiness || show_pbr_metallic); + getChildView("bumpyOffsetU")->setVisible(show_bumpiness || show_pbr_metallic); + getChildView("bumpyOffsetV")->setVisible(show_bumpiness || show_pbr_metallic); // PBR controls getChildView("pbr_control")->setVisible(show_pbr); - getChildView("radio_pbr_type")->setVisible(show_pbr); } // static @@ -2062,7 +2126,7 @@ void LLPanelFace::onSelectPbr(const LLSD& data) { LLSelectMgr::getInstance()->saveSelectedObjectTextures(); - LLTextureCtrl* pbr_ctrl = getChild<LLTextureCtrl>("pbr_control"); + LLTextureCtrl* pbr_ctrl = findChild<LLTextureCtrl>("pbr_control"); if (!pbr_ctrl) return; if (!pbr_ctrl->getTentative()) { @@ -3582,7 +3646,7 @@ void LLPanelFace::onTextureSelectionChanged(LLInventoryItem* itemp) void LLPanelFace::onPbrSelectionChanged(LLInventoryItem* itemp) { - LLTextureCtrl* pbr_ctrl = getChild<LLTextureCtrl>("pbr_control"); + LLTextureCtrl* pbr_ctrl = findChild<LLTextureCtrl>("pbr_control"); if (pbr_ctrl) { LLUUID obj_owner_id; diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index 29c9329a26..09e568e9ac 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -887,8 +887,6 @@ BOOL LLPanelProfileSecondLife::postBuild() mDiscardDescriptionChanges->setCommitCallback([this](LLUICtrl*, void*) { onDiscardDescriptionChanges(); }, nullptr); mDescriptionEdit->setKeystrokeCallback([this](LLTextEditor* caller) { onSetDescriptionDirty(); }); - getChild<LLButton>("open_notes")->setCommitCallback([this](LLUICtrl*, void*) { onOpenNotes(); }, nullptr); - mCanSeeOnlineIcon->setMouseUpCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask) { onShowAgentPermissionsDialog(); }); mCantSeeOnlineIcon->setMouseUpCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask) { onShowAgentPermissionsDialog(); }); mCanSeeOnMapIcon->setMouseUpCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask) { onShowAgentPermissionsDialog(); }); diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index dc1fff9a8f..97277ee798 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -80,7 +80,7 @@ void LLReflectionMapManager::update() if (!mRenderTarget.isComplete()) { - U32 color_fmt = GL_RGBA; + U32 color_fmt = GL_SRGB8_ALPHA8; const bool use_depth_buffer = true; const bool use_stencil_buffer = true; U32 targetRes = LL_REFLECTION_PROBE_RESOLUTION * 2; // super sample diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index c730b6f970..142d929188 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -265,6 +265,7 @@ LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT*2]; LLGLSLShader gDeferredMaterialWaterProgram[LLMaterial::SHADER_COUNT*2]; LLGLSLShader gDeferredPBROpaqueProgram; LLGLSLShader gDeferredSkinnedPBROpaqueProgram; +LLGLSLShader gDeferredPBRAlphaProgram[2]; // not skinned, skinned //helper for making a rigged variant of a given shader bool make_rigged_variant(LLGLSLShader& shader, LLGLSLShader& riggedShader) @@ -1283,6 +1284,8 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredPBROpaqueProgram.unload(); gDeferredSkinnedPBROpaqueProgram.unload(); + gDeferredPBRAlphaProgram[0].unload(); + gDeferredPBRAlphaProgram[1].unload(); return TRUE; } @@ -1616,6 +1619,80 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() } llassert(success); } + + if (success) + { + for (int rigged = 0; rigged < 2 && success; ++rigged) + { + LLGLSLShader* shader = &gDeferredPBRAlphaProgram[rigged]; + shader->mName = rigged + ? "Skinned Deferred PBR Alpha Shader" + : "Deferred PBR Alpha Shader"; + shader->mRiggedVariant = rigged + ? &gDeferredPBRAlphaProgram[1] + : nullptr; + shader->mFeatures.hasObjectSkinning = (bool)rigged; + shader->mFeatures.calculatesLighting = false; + shader->mFeatures.hasLighting = false; + shader->mFeatures.isAlphaLighting = true; + shader->mFeatures.hasSrgb = true; + shader->mFeatures.encodesNormal = true; + shader->mFeatures.calculatesAtmospherics = true; + shader->mFeatures.hasAtmospherics = true; + shader->mFeatures.hasGamma = true; + shader->mFeatures.hasTransport = true; + shader->mFeatures.hasShadows = use_sun_shadow; + shader->mFeatures.isDeferred = true; // include deferredUtils + shader->mFeatures.hasReflectionProbes = mShaderLevel[SHADER_DEFERRED]; + + shader->mShaderFiles.clear(); + shader->mShaderFiles.push_back(make_pair("deferred/pbralphaV.glsl", GL_VERTEX_SHADER_ARB)); + shader->mShaderFiles.push_back(make_pair("deferred/pbralphaF.glsl", GL_FRAGMENT_SHADER_ARB)); + + shader->clearPermutations(); + + U32 alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_BLEND; + shader->addPermutation("DIFFUSE_ALPHA_MODE", llformat("%d", alpha_mode)); + shader->addPermutation("HAS_NORMAL_MAP", "1"); + shader->addPermutation("HAS_SPECULAR_MAP", "1"); // PBR: Packed: Occlusion, Metal, Roughness + shader->addPermutation("HAS_EMISSIVE_MAP", "1"); + shader->addPermutation("USE_VERTEX_COLOR", "1"); + if (use_sun_shadow) + { + shader->addPermutation("HAS_SHADOW", "1"); + } + + if (ambient_kill) + { + shader->addPermutation("AMBIENT_KILL", "1"); + } + + if (sunlight_kill) + { + shader->addPermutation("SUNLIGHT_KILL", "1"); + } + + if (local_light_kill) + { + shader->addPermutation("LOCAL_LIGHT_KILL", "1"); + } + + if (rigged) + { + shader->addPermutation("HAS_SKIN", "1"); + } + + shader->mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + + success = shader->createShader(NULL, NULL); + llassert(success); + + // Alpha Shader Hack + shader->mFeatures.calculatesLighting = true; + shader->mFeatures.hasLighting = true; + } + } + if (success) { diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index ef49074959..38f67cd23c 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -321,5 +321,6 @@ extern LLGLSLShader gNormalMapGenProgram; extern LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT*2]; extern LLGLSLShader gDeferredMaterialWaterProgram[LLMaterial::SHADER_COUNT*2]; -extern LLGLSLShader gDeferredPBROpaqueProgram; +extern LLGLSLShader gDeferredPBROpaqueProgram; +extern LLGLSLShader gDeferredPBRAlphaProgram[2]; // not skinned, skinned #endif diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 9cbbf1c276..511df4bd79 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -1224,15 +1224,18 @@ BOOL LLViewerTextureList::createUploadFile(const std::string& filename, } // note: modifies the argument raw_image!!!! -LLPointer<LLImageJ2C> LLViewerTextureList::convertToUploadFile(LLPointer<LLImageRaw> raw_image, const S32 max_image_dimentions) +LLPointer<LLImageJ2C> LLViewerTextureList::convertToUploadFile(LLPointer<LLImageRaw> raw_image, const S32 max_image_dimentions, bool force_lossless) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; raw_image->biasedScaleToPowerOfTwo(max_image_dimentions); LLPointer<LLImageJ2C> compressedImage = new LLImageJ2C(); - if (gSavedSettings.getBOOL("LosslessJ2CUpload") && - (raw_image->getWidth() * raw_image->getHeight() <= LL_IMAGE_REZ_LOSSLESS_CUTOFF * LL_IMAGE_REZ_LOSSLESS_CUTOFF)) - compressedImage->setReversible(TRUE); + if (force_lossless || + (gSavedSettings.getBOOL("LosslessJ2CUpload") && + (raw_image->getWidth() * raw_image->getHeight() <= LL_IMAGE_REZ_LOSSLESS_CUTOFF * LL_IMAGE_REZ_LOSSLESS_CUTOFF))) + { + compressedImage->setReversible(TRUE); + } if (gSavedSettings.getBOOL("Jpeg2000AdvancedCompression")) diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index 7de3d68e42..4116be6528 100644 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -96,7 +96,7 @@ public: const std::string& out_filename, const U8 codec, const S32 max_image_dimentions = LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT); - static LLPointer<LLImageJ2C> convertToUploadFile(LLPointer<LLImageRaw> raw_image, const S32 max_image_dimentions = LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT); + static LLPointer<LLImageJ2C> convertToUploadFile(LLPointer<LLImageRaw> raw_image, const S32 max_image_dimentions = LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT, bool force_lossless = false); static void processImageNotInDatabase( LLMessageSystem *msg, void **user_data ); static void receiveImageHeader(LLMessageSystem *msg, void **user_data); static void receiveImagePacket(LLMessageSystem *msg, void **user_data); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index ad99ce1509..9d8cc17a7f 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5892,7 +5892,8 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) bool is_pbr = false; #endif #else - bool is_pbr = facep->getTextureEntry()->getGLTFMaterial() != nullptr; + LLGLTFMaterial *gltf_mat = facep->getTextureEntry()->getGLTFMaterial(); + bool is_pbr = gltf_mat != nullptr; #endif //ALWAYS null out vertex buffer on rebuild -- if the face lands in a render @@ -5960,8 +5961,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) BOOL force_simple = (facep->getPixelArea() < FORCE_SIMPLE_RENDER_AREA); U32 type = gPipeline.getPoolTypeFromTE(te, tex); - - if (is_pbr) + if (is_pbr && gltf_mat && gltf_mat->mAlphaMode != LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) { type = LLDrawPool::POOL_PBR_OPAQUE; } @@ -6781,7 +6781,10 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace if (gltf_mat) { // all other parameters ignored if gltf material is present - registerFace(group, facep, LLRenderPass::PASS_PBR_OPAQUE); + if (gltf_mat->mAlphaMode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) + registerFace(group, facep, LLRenderPass::PASS_ALPHA); + else + registerFace(group, facep, LLRenderPass::PASS_PBR_OPAQUE); } else // do NOT use 'fullbright' for this logic or you risk sending diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 9ad760d024..3538f7e911 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1684,7 +1684,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima } } - if (alpha) + if (alpha || (gltf_mat && gltf_mat->mAlphaMode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND)) { return LLDrawPool::POOL_ALPHA; } @@ -1692,7 +1692,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima { return LLDrawPool::POOL_BUMP; } - else if (gltf_mat && !alpha) + else if (gltf_mat) { return LLDrawPool::POOL_PBR_OPAQUE; } diff --git a/indra/newview/skins/default/xui/en/floater_material_editor.xml b/indra/newview/skins/default/xui/en/floater_material_editor.xml index 0a05a4f868..eda28c5a4b 100644 --- a/indra/newview/skins/default/xui/en/floater_material_editor.xml +++ b/indra/newview/skins/default/xui/en/floater_material_editor.xml @@ -1,355 +1,378 @@ <?xml version="1.0" encoding="utf-8" standalone="yes" ?> <floater legacy_header_height="18" - can_resize="false" + can_resize="true" default_tab_group="1" height="887" + width="256" + min_height="500" + min_width="256" layout="topleft" name="material editor" help_topic="material_editor" - title="[MATERIAL_NAME]" - width="256"> + title="[MATERIAL_NAME]"> <string name="no_upload_fee_string">no upload fee</string> <string name="upload_fee_string">L$[FEE] upload fee</string> - <check_box - follows="left|top" - label="Double Sided" - left="14" - top="14" - name="double sided" - height="25" - width="120" /> - <panel - border="true" - follows="left|top" - width="246" - height="196" - layout="topleft" - left="5" - mouse_opaque="false" - name="albedo_texture_pnl" - top_pad="5" - > - <text - type="string" - font.style="BOLD" - length="1" - follows="left|top" - height="10" - layout="topleft" - left="10" - top="5" - width="64"> - Albedo: - </text> - <texture_picker - can_apply_immediately="true" - default_image_name="Default" - fallback_image="materials_ui_x_24.png" - allow_no_texture="true" + + <scroll_container + name="materials_scroll" + top="14" + left="4" + height="768" + width="247" + follows="all" + layout="topleft" + color="DkGray2" + opaque="true" + reserve_scroll_corner="false" + > + <panel + border="false" + name="scroll_panel" + top="0" + left="0" + height="768" + width="247" + > + <check_box + follows="left|top" + label="Double Sided" + left="10" + top="0" + name="double sided" + height="25" + width="120" /> + <panel + border="true" follows="left|top" - top_pad="8" - height="151" + width="246" + height="196" layout="topleft" - left="10" - name="albedo_texture" - tool_tip="Albedo map. Alpha channel is optional and used for transparency." - width="128" /> - <text - type="string" - font.style="BOLD" - length="1" - follows="left|top" - height="10" - width="128" - layout="topleft" - left="10" - top_pad="-17" - name="albedo_upload_fee" + left="1" + mouse_opaque="false" + name="albedo_texture_pnl" + top_pad="5" + > + <text + type="string" + font.style="BOLD" + length="1" + follows="left|top" + height="10" + layout="topleft" + left="10" + top="5" + width="64"> + Albedo: + </text> + <texture_picker + can_apply_immediately="true" + default_image_name="Default" + fallback_image="materials_ui_x_24.png" + allow_no_texture="true" + follows="left|top" + top_pad="8" + height="151" + layout="topleft" + left="10" + name="albedo_texture" + tool_tip="Albedo map. Alpha channel is optional and used for transparency." + width="128" /> + <text + type="string" + font.style="BOLD" + length="1" + follows="left|top" + height="10" + width="128" + layout="topleft" + left="10" + top_pad="-17" + name="albedo_upload_fee" > - No upload fee - </text> - <text - type="string" - length="1" - follows="left|top" - height="10" - layout="topleft" - left_pad="5" - top="8" + No upload fee + </text> + <text + type="string" + length="1" + follows="left|top" + height="10" + layout="topleft" + left_pad="5" + top="8" > - Tint - </text> - <color_swatch - can_apply_immediately="true" - follows="left|top" - height="40" - label_height="0" - layout="topleft" - left_delta="0" - top_pad="5" - name="albedo color" - width="40" /> - <text - type="string" - length="1" - follows="left|top" - height="10" - layout="topleft" - left_delta="0" - top_pad="5" - width="96" + Tint + </text> + <color_swatch + can_apply_immediately="true" + follows="left|top" + height="40" + label_height="0" + layout="topleft" + left_delta="0" + top_pad="5" + name="albedo color" + width="40" /> + <text + type="string" + length="1" + follows="left|top" + height="10" + layout="topleft" + left_delta="0" + top_pad="5" + width="96" > - Transparency - </text> - <spinner - decimal_digits="3" - follows="left|top" - height="19" - increment="0.01" - initial_value="1" - layout="topleft" - left_delta="0" - top_pad="5" - min_val="0" - max_val="1" - name="transparency" - width="64" + Transparency + </text> + <spinner + decimal_digits="3" + follows="left|top" + height="19" + increment="0.01" + initial_value="1" + layout="topleft" + left_delta="0" + top_pad="5" + min_val="0" + max_val="1" + name="transparency" + width="64" /> - <text - type="string" - length="1" - follows="left|top" - height="10" - layout="topleft" - left_delta="0" - name="label alphamode" - text_readonly_color="LabelDisabledColor" - top_pad="5" - width="90"> - Alpha mode - </text> - <combo_box - height="23" - layout="topleft" - left_delta="0" - name="alpha mode" - top_pad="4" - width="96"> - <combo_box.item - label="None" - name="None" - value="OPAQUE" /> - <combo_box.item - label="Alpha blending" - name="Alpha blending" - value="BLEND" /> - <combo_box.item - label="Alpha masking" - name="Alpha masking" - value="MASK" /> - </combo_box> - <text - type="string" - length="1" - follows="left|top" - height="10" - layout="topleft" - left_delta="0" - top_pad="5" - width="96" + <text + type="string" + length="1" + follows="left|top" + height="10" + layout="topleft" + left_delta="0" + name="label alphamode" + text_readonly_color="LabelDisabledColor" + top_pad="5" + width="90"> + Alpha mode + </text> + <combo_box + height="23" + layout="topleft" + left_delta="0" + name="alpha mode" + top_pad="4" + width="96"> + <combo_box.item + label="None" + name="None" + value="OPAQUE" /> + <combo_box.item + label="Alpha blending" + name="Alpha blending" + value="BLEND" /> + <combo_box.item + label="Alpha masking" + name="Alpha masking" + value="MASK" /> + </combo_box> + <text + type="string" + length="1" + follows="left|top" + height="10" + layout="topleft" + left_delta="0" + top_pad="5" + width="96" > - Alpha Cutoff - </text> - <spinner - decimal_digits="3" - follows="left|top" - height="19" - increment="0.01" - initial_value="1" - layout="topleft" - left_delta="0" - top_pad="5" - min_val="0" - max_val="1" - name="alpha cutoff" - width="64" + Alpha Cutoff + </text> + <spinner + decimal_digits="3" + follows="left|top" + height="19" + increment="0.01" + initial_value="1" + layout="topleft" + left_delta="0" + top_pad="5" + min_val="0" + max_val="1" + name="alpha cutoff" + width="64" /> - </panel> - <panel - border="true" - follows="left|top" - width="246" - height="175" - layout="topleft" - left="5" - mouse_opaque="false" - name="metallic_texture_pnl" - top_pad="5" - > - <text - type="string" - font.style="BOLD" - length="1" + </panel> + <panel + border="true" follows="left|top" - height="10" + width="246" + height="175" layout="topleft" - left="10" - top="5" + left="1" + mouse_opaque="false" + name="metallic_texture_pnl" + top_pad="5" + > + <text + type="string" + font.style="BOLD" + length="1" + follows="left|top" + height="10" + layout="topleft" + left="10" + top="5" > - Metallic-Roughness: - </text> - <texture_picker - can_apply_immediately="true" - default_image_name="Default" - fallback_image="materials_ui_x_24.png" - allow_no_texture="true" - follows="left|top" - width="128" - height="151" - layout="topleft" - left="10" - name="metallic_roughness_texture" - tool_tip="GLTF metallic-roughness map with optional occlusion. Red channel is occlusion, green channel is roughness, blue channel is metalness." - top_pad="8" + Metallic-Roughness: + </text> + <texture_picker + can_apply_immediately="true" + default_image_name="Default" + fallback_image="materials_ui_x_24.png" + allow_no_texture="true" + follows="left|top" + width="128" + height="151" + layout="topleft" + left="10" + name="metallic_roughness_texture" + tool_tip="GLTF metallic-roughness map with optional occlusion. Red channel is occlusion, green channel is roughness, blue channel is metalness." + top_pad="8" /> - <text - type="string" - font.style="BOLD" - length="1" - follows="left|top" - height="10" - width="128" - layout="topleft" - left="10" - top_pad="-17" - name="metallic_upload_fee" + <text + type="string" + font.style="BOLD" + length="1" + follows="left|top" + height="10" + width="128" + layout="topleft" + left="10" + top_pad="-17" + name="metallic_upload_fee" > - No upload fee - </text> - <text - type="string" - length="1" - follows="left|top" - height="10" - layout="topleft" - left_pad="5" - top="8" + No upload fee + </text> + <text + type="string" + length="1" + follows="left|top" + height="10" + layout="topleft" + left_pad="5" + top="8" > - Metallic Factor - </text> - <spinner - decimal_digits="3" - follows="left|top" - height="19" - increment="0.01" - initial_value="0" - layout="topleft" - left_delta="0" - top_pad="5" - min_val="0" - max_val="1" - name="metalness factor" - width="64" + Metallic Factor + </text> + <spinner + decimal_digits="3" + follows="left|top" + height="19" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="0" + top_pad="5" + min_val="0" + max_val="1" + name="metalness factor" + width="64" /> - <text - type="string" - length="1" + <text + type="string" + length="1" + follows="left|top" + height="10" + layout="topleft" + left_delta="0" + top_pad="5" + width="96" + > + Roughness Factor + </text> + <spinner + decimal_digits="3" + follows="left|top" + height="19" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="0" + top_pad="5" + min_val="0" + max_val="1" + name="roughness factor" + width="64" + /> + </panel> + <panel + border="true" follows="left|top" - height="10" + width="246" + height="175" layout="topleft" - left_delta="0" + left="1" + mouse_opaque="false" + name="emissive_texture_pnl" top_pad="5" - width="96" - > - Roughness Factor - </text> - <spinner - decimal_digits="3" - follows="left|top" - height="19" - increment="0.01" - initial_value="0" - layout="topleft" - left_delta="0" - top_pad="5" - min_val="0" - max_val="1" - name="roughness factor" - width="64" - /> - </panel> - <panel - border="true" - follows="left|top" - width="246" - height="175" - layout="topleft" - left="5" - mouse_opaque="false" - name="emissive_texture_pnl" - top_pad="5" > - <text - type="string" - font.style="BOLD" - length="1" - follows="left|top" - height="10" - layout="topleft" - left="10" - top="5" - width="64"> - Emissive: - </text> - <texture_picker - can_apply_immediately="true" - default_image_name="Default" - fallback_image="materials_ui_x_24.png" - allow_no_texture="true" - follows="left|top" - top_pad="8" - height="151" - layout="topleft" - left="10" - name="emissive_texture" - width="128" /> - <text - type="string" - font.style="BOLD" - length="1" - follows="left|top" - height="10" - width="128" - layout="topleft" - left="10" - top_pad="-17" - name="emissive_upload_fee" + <text + type="string" + font.style="BOLD" + length="1" + follows="left|top" + height="10" + layout="topleft" + left="10" + top="5" + width="64"> + Emissive: + </text> + <texture_picker + can_apply_immediately="true" + default_image_name="Default" + fallback_image="materials_ui_x_24.png" + allow_no_texture="true" + follows="left|top" + top_pad="8" + height="151" + layout="topleft" + left="10" + name="emissive_texture" + width="128" /> + <text + type="string" + font.style="BOLD" + length="1" + follows="left|top" + height="10" + width="128" + layout="topleft" + left="10" + top_pad="-17" + name="emissive_upload_fee" > - No upload fee - </text> - <text - type="string" - length="1" - follows="left|top" - height="10" - layout="topleft" - left_pad="5" - top="8" + No upload fee + </text> + <text + type="string" + length="1" + follows="left|top" + height="10" + layout="topleft" + left_pad="5" + top="8" > - Tint - </text> - <color_swatch - can_apply_immediately="true" - follows="left|top" - height="40" - label_height="0" - layout="topleft" - left_delta="0" - top_pad="5" - name="emissive color" - width="40" /> - <!--<text + Tint + </text> + <color_swatch + can_apply_immediately="true" + follows="left|top" + height="40" + label_height="0" + layout="topleft" + left_delta="0" + top_pad="5" + name="emissive color" + width="40" /> + <!--<text type="string" length="1" follows="left|top" @@ -373,64 +396,66 @@ max_val="100" width="64" />--> - </panel> - <panel - border="true" - follows="left|top" - width="246" - height="175" - layout="topleft" - left="5" - mouse_opaque="false" - top_pad="5" - name="normal_texture_pnl" + </panel> + <panel + border="true" + follows="left|top" + width="246" + height="175" + layout="topleft" + left="1" + mouse_opaque="false" + top_pad="5" + name="normal_texture_pnl" > - <text - type="string" - font.style="BOLD" - length="1" - follows="left|top" - height="10" - layout="topleft" - left="10" - top="5" - width="64"> - Normal: - </text> - <texture_picker - can_apply_immediately="true" - default_image_name="Default" - fallback_image="materials_ui_x_24.png" - allow_no_texture="true" - follows="left|top" - top_pad="8" - height="151" - layout="topleft" - left="10" - name="normal_texture" - width="128" /> - <text - type="string" - font.style="BOLD" - length="1" - follows="left|top" - height="10" - width="128" - layout="topleft" - left="10" - top_pad="-17" - name="normal_upload_fee" + <text + type="string" + font.style="BOLD" + length="1" + follows="left|top" + height="10" + layout="topleft" + left="10" + top="5" + width="64"> + Normal: + </text> + <texture_picker + can_apply_immediately="true" + default_image_name="Default" + fallback_image="materials_ui_x_24.png" + allow_no_texture="true" + follows="left|top" + top_pad="8" + height="151" + layout="topleft" + left="10" + name="normal_texture" + width="128" /> + <text + type="string" + font.style="BOLD" + length="1" + follows="left|top" + height="10" + width="128" + layout="topleft" + left="10" + top_pad="-17" + name="normal_upload_fee" > - No upload fee - </text> - </panel> + No upload fee + </text> + </panel> + </panel> + </scroll_container> <panel follows="right|bottom" width="246" height="97" layout="bottomright" - top_delta="-2" + top_pad="0" left="5" name="button_panel" > 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 922c58fa94..9bdfff41d8 100644 --- a/indra/newview/skins/default/xui/en/panel_tools_texture.xml +++ b/indra/newview/skins/default/xui/en/panel_tools_texture.xml @@ -153,7 +153,6 @@ value="Media" /> </combo_box> <radio_group - control_name="ComboMaterialType" height="50" layout="topleft" left_pad="5" @@ -184,7 +183,6 @@ value="2"/> </radio_group> <radio_group - control_name="ComboMaterialType" height="50" layout="topleft" left_delta="0" @@ -254,8 +252,6 @@ width="64" /> <texture_picker can_apply_immediately="true" - default_image_name="Default" - fallback_image="materials_ui_x_24.png" follows="left|top" height="80" label="PBR " |