diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp index beddb11fda..9206550bba 100644 --- a/indra/llcommon/llqueuedthread.cpp +++ b/indra/llcommon/llqueuedthread.cpp @@ -146,7 +146,7 @@ S32 LLQueuedThread::updateQueue(F32 max_time_ms) // schedule a call to threadedUpdate for every call to updateQueue if (!isQuitting()) { - mRequestQueue.post([=]() + mRequestQueue.postIfOpen([=]() { LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("qt - update"); mIdleThread = false; diff --git a/indra/llcommon/llrefcount.cpp b/indra/llcommon/llrefcount.cpp index 5cbd346411..6852b5536a 100644 --- a/indra/llcommon/llrefcount.cpp +++ b/indra/llcommon/llrefcount.cpp @@ -30,7 +30,7 @@ #include "llerror.h" // maximum reference count before sounding memory leak alarm -const S32 gMaxRefCount = 65536; +const S32 gMaxRefCount = S32_MAX; LLRefCount::LLRefCount(const LLRefCount& other) : mRef(0) diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl index b5c38bba04..7a13abc7e8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl @@ -76,25 +76,31 @@ 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; + } + + vec3 col = vertex_color.rgb * albedo.rgb; #ifdef HAS_NORMAL_MAP vec4 norm = texture2D(bumpMap, vary_texcoord1.xy); - norm.xyz = norm.xyz * 2 - 1; + 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)); + 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; @@ -102,8 +108,7 @@ void main() #endif tnorm = normalize(tnorm.xyz); - - norm.xyz = normalize(tnorm.xyz); + norm.xyz = tnorm.xyz; // RGB = Occlusion, Roughness, Metal // default values, see LLViewerTexture::sDefaultPBRORMImagep 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/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl index 71135786c3..c7c241b76e 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl @@ -30,7 +30,7 @@ #define DEBUG_ANY_LIGHT_TYPE 0 // Output red light cone #define DEBUG_PBR_LIGHT_TYPE 0 // Output PBR objects in red #define DEBUG_LEG_LIGHT_TYPE 0 // Show Legacy objects in red -#define DEBUG_POINT_ZERO 0 // Output zero for spotlight +#define DEBUG_POINT_ZERO 0 // Output zero for point lights #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; @@ -113,11 +113,10 @@ void main() vec3 lv =(light [ light_idx ].xyz - pos); calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist); - if (nl > 0.0) + float dist = lightDist / lightSize; + if (dist <= 1.0 && nl > 0.0) { - float dist = lightDist / lightSize; float dist_atten = calcLegacyDistanceAttenuation(dist, falloff); - vec3 intensity = dist_atten * nl * lightColor; colorDiffuse += intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh); colorSpec += intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh); @@ -148,7 +147,7 @@ void main() float lightDist; calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist); - float fa = light_col[i].a + 1.0; + float fa = light_col[i].a; float dist_atten = calcLegacyDistanceAttenuation(dist, fa); dist_atten *= noise; diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl index a9a2b8dcb4..bc4b4eb7e1 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl @@ -110,6 +110,7 @@ uniform mat4 inv_proj; 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 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); vec3 colorized_dot(float x); bool clipProjectedLightVars(vec3 center, vec3 pos, out float dist, out float l_dist, out vec3 lv, out vec4 proj_tc ); vec3 getLightIntensitySpot(vec3 lightColor, float lightRange, float lightDistance, vec3 v); @@ -124,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) @@ -155,9 +158,7 @@ void main() vec3 n; vec4 norm = getNormalEnvIntensityFlags(tc, n, envIntensity); - float dist_atten = 1.0 - (dist + falloff)/(1.0 + falloff); - dist_atten *= dist_atten; - dist_atten *= 2.0; + float dist_atten = calcLegacyDistanceAttenuation(dist, falloff); if (dist_atten <= 0.0) { discard; @@ -202,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 34ebb67c3c..e6017534ca 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -27,6 +27,10 @@ #define PBR_USE_IBL 1 #define PBR_USE_SUN 1 +#define PBR_USE_LINEAR_ALBEDO 1 +#define PBR_USE_DEFAULT_IRRADIANCE 0 // PBR: irradiance, skins/default/textures/default_irradiance.png +#define PBR_USE_IRRADIANCE_HACK 1 + #define DEBUG_PBR_LIGHT_TYPE 0 // Output no global light to make it easier to see pointLight and spotLight #define DEBUG_PBR_PACKORM0 0 // Rough=0, Metal=0 #define DEBUG_PBR_PACKORM1 0 // Rough=1, Metal=1 @@ -135,6 +139,9 @@ uniform sampler2DRect diffuseRect; uniform sampler2DRect specularRect; uniform sampler2DRect normalMap; uniform sampler2DRect emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl +uniform sampler2D altDiffuseMap; // PBR: irradiance, skins/default/textures/default_irradiance.png + +const float M_PI = 3.14159265; #if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO) uniform sampler2DRect lightMap; @@ -207,12 +214,7 @@ void main() norm.xyz = getNorm(tc); vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; - float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0); -#if DEBUG_PBR_DA_RAW - float debug_da = da; -#endif float light_gamma = 1.0 / 1.3; - da = pow(da, light_gamma); vec4 diffuse = texture2DRect(diffuseRect, tc); vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); // NOTE: PBR sRGB Emissive @@ -295,7 +297,11 @@ void main() float bv = clamp(dot(b,v),0,1); // Reference: getMetallicRoughnessInfo +#if PBR_USE_LINEAR_ALBEDO + vec3 base = diffuse.rgb; +#else vec3 base = linear_to_srgb(diffuse.rgb); +#endif float perceptualRough = packedORM.g; // NOTE: do NOT clamp here to be consistent with Blender, Blender is wrong and Substance is right vec3 c_diff, reflect0, reflect90; float alphaRough, specWeight; @@ -321,8 +327,14 @@ void main() #if DEBUG_PBR_IRRADIANCE_RAW vec3 debug_irradiance = irradiance; #endif + +#if PBR_USE_DEFAULT_IRRADIANCE + vec2 iruv = vec2(0.5f + 0.5f * atan(reflectVN.z, reflectVN.x) / M_PI, 1.f - acos(reflectVN.y) / M_PI); + irradiance = texture2D(altDiffuseMap, iruv).rgb * ambocc; +#endif +#if PBR_USE_IRRADIANCE_HACK irradiance = max(amblit,irradiance) * ambocc; - specLight = srgb_to_linear(specLight); +#endif #if DEBUG_PBR_SPECLIGHT051 specLight = vec3(0,0.5,1.0); irradiance = specLight; @@ -365,9 +377,17 @@ void main() #endif // scol = sun shadow vec3 intensity = ambocc * sunColor * nl * scol; +#if PBR_USE_LINEAR_ALBEDO + vec3 sunDiffuse = intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh); + vec3 sunSpec = intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh); +#else vec3 sunDiffuse = base * intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh); vec3 sunSpec = intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh); - bloom = dot(sunSpec, sunSpec) / (scale * scale * scale); +#endif + // Disabling PBR bloom due to two reasons: + // 1. The glTF 2.0 Specification does not specify bloom, + // 2. As the camera moves there are lots of bloom shimmering. + //bloom = dot(sunSpec, sunSpec) / (scale * scale * scale); #if DEBUG_PBR_SUN_SPEC_FRESNEL colorDiffuse = vec3(0); @@ -577,9 +597,11 @@ void main() #endif #if DEBUG_PBR_IRRADIANCE_RAW color.rgb = debug_irradiance; + bloom = 0; #endif #if DEBUG_PBR_IRRADIANCE color.rgb = irradiance; + bloom = 0; #endif #if DEBUG_PBR_KSPEC color.rgb = kSpec; @@ -633,13 +655,23 @@ void main() #if DEBUG_PBR_LIGHT_TYPE color.rgb = vec3(0); #endif + frag_color.rgb = color.rgb; // PBR is done in linear } else { + float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0); +#if DEBUG_PBR_DA_RAW + float debug_da = da; +#endif + da = pow(da, light_gamma); + 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 41e40a07e7..9153fe031e 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl @@ -85,6 +85,7 @@ uniform mat4 inv_proj; 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 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); bool clipProjectedLightVars(vec3 center, vec3 pos, out float dist, out float l_dist, out vec3 lv, out vec4 proj_tc ); vec3 getLightIntensitySpot(vec3 lightColor, float lightRange, float lightDistance, vec3 v); vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensity); @@ -98,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) @@ -129,9 +132,7 @@ void main() vec3 n; vec4 norm = getNormalEnvIntensityFlags(tc, n, envIntensity); // need `norm.w` for GET_GBUFFER_FLAG() - float dist_atten = 1.0 - (dist + falloff)/(1.0 + falloff); - dist_atten *= dist_atten; - dist_atten *= 2.0; + float dist_atten = calcLegacyDistanceAttenuation(dist, falloff); if (dist_atten <= 0.0) { discard; @@ -174,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 7d16c16b42..fbfee3039a 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2457,8 +2457,13 @@ bool LLAppViewer::cleanup() //MUST happen AFTER SUBSYSTEM_CLEANUP(LLCurl) delete sTextureCache; sTextureCache = NULL; - delete sTextureFetch; - sTextureFetch = NULL; + if (sTextureFetch) + { + sTextureFetch->shutdown(); + sTextureFetch->waitOnPending(); + delete sTextureFetch; + sTextureFetch = NULL; + } delete sImageDecodeThread; sImageDecodeThread = NULL; delete mFastTimerLogThread; diff --git a/indra/newview/lldrawpoolpbropaque.cpp b/indra/newview/lldrawpoolpbropaque.cpp index 3930e11cf3..9fc3d51cad 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()) { diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index 3a1efec91b..55ebf03adc 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -51,7 +51,10 @@ LLDrawPoolSky::LLDrawPoolSky() void LLDrawPoolSky::prerender() { mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT); - gSky.mVOSkyp->updateGeometry(gSky.mVOSkyp->mDrawable); + if (gSky.mVOSkyp->mDrawable) + { + gSky.mVOSkyp->updateGeometry(gSky.mVOSkyp->mDrawable); + } } void LLDrawPoolSky::render(S32 pass) 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& mr_j2c, LLPointer& 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 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 f4682ae6ad..29d0cecc6c 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -93,13 +93,17 @@ // Must match the commbobox definitions in panel_tools_texture.xml // const S32 MATMEDIA_MATERIAL = 0; // Material -const S32 MATMEDIA_MEDIA = 1; // Media +const S32 MATMEDIA_PBR = 1; // PBR +const S32 MATMEDIA_MEDIA = 2; // Media const S32 MATTYPE_DIFFUSE = 0; // Diffuse material texture const S32 MATTYPE_NORMAL = 1; // Normal map 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_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); @@ -142,7 +146,6 @@ F32 LLPanelFace::getCurrentShinyScaleU() { return mCtrlShinyScaleU->getValue() F32 LLPanelFace::getCurrentShinyScaleV() { return mCtrlShinyScaleV->getValue().asReal(); } F32 LLPanelFace::getCurrentShinyOffsetU() { return mCtrlShinyOffsetU->getValue().asReal(); } F32 LLPanelFace::getCurrentShinyOffsetV() { return mCtrlShinyOffsetV->getValue().asReal(); } -LLUUID LLPanelFace::getCurrentMaterialID() { return getChild("materialID")->getValue().asUUID(); } // UI provided diffuse parameters F32 LLPanelFace::getCurrentTextureRot() { return mCtrlTexRot->getValue().asReal(); } @@ -182,7 +185,6 @@ BOOL LLPanelFace::postBuild() childSetCommitCallback("glossiness",&LLPanelFace::onCommitMaterialGloss, this); childSetCommitCallback("environment",&LLPanelFace::onCommitMaterialEnv, this); childSetCommitCallback("maskcutoff",&LLPanelFace::onCommitMaterialMaskCutoff, this); - childSetCommitCallback("materialID", &LLPanelFace::onCommitMaterialID, this); // childSetCommitCallback("checkbox_sync_settings", &LLPanelFace::onClickMapsSync, this); @@ -293,6 +295,25 @@ BOOL LLPanelFace::postBuild() setMouseOpaque(FALSE); + LLTextureCtrl* pbr_ctrl = getChild("pbr_control"); + if (pbr_ctrl) + { + pbr_ctrl->setDefaultImageAssetID(LLUUID(gSavedSettings.getString("DefaultObjectTexture"))); + 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)); + pbr_ctrl->setDragCallback(boost::bind(&LLPanelFace::onDragPbr, this, _2)); + pbr_ctrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onPbrSelectionChanged, this, _1)); + pbr_ctrl->setOnCloseCallback(boost::bind(&LLPanelFace::onCloseTexturePicker, this, _2)); + + pbr_ctrl->setFollowsTop(); + pbr_ctrl->setFollowsLeft(); + pbr_ctrl->setImmediateFilterPermMask(PERM_NONE); + pbr_ctrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); + pbr_ctrl->setBakeTextureEnabled(false); + pbr_ctrl->setInventoryPickType(LLTextureCtrl::PICK_MATERIAL); + } + mTextureCtrl = getChild("texture control"); if(mTextureCtrl) { @@ -410,6 +431,13 @@ BOOL LLPanelFace::postBuild() mRadioMatType->selectNthItem(MATTYPE_DIFFUSE); } + mRadioPbrType = getChild("radio_pbr_type"); + if (mRadioPbrType) + { + mRadioPbrType->setCommitCallback(LLPanelFace::onCommitPbrType, this); + mRadioPbrType->selectNthItem(PBRTYPE_ALBEDO); + } + mCtrlGlow = getChild("glow"); if(mCtrlGlow) { @@ -952,42 +980,50 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) BOOL enable_material_controls = (!gSavedSettings.getBOOL("SyncMaterialSettings")); //LLComboBox* combobox_matmedia = getChild("combobox matmedia"); - if (mComboMatMedia) - { - if (mComboMatMedia->getCurrentIndex() < MATMEDIA_MATERIAL) - { - mComboMatMedia->selectNthItem(MATMEDIA_MATERIAL); - } - } - else - { - LL_WARNS() << "failed getChild for 'combobox matmedia'" << LL_ENDL; - } - mComboMatMedia->setEnabled(editable); + if (mComboMatMedia->getCurrentIndex() < MATMEDIA_MATERIAL) + { + mComboMatMedia->selectNthItem(MATMEDIA_MATERIAL); + } + mComboMatMedia->setEnabled(editable); //LLRadioGroup* radio_mat_type = getChild("radio_material_type"); - if(mRadioMatType) - { - if (mRadioMatType->getSelectedIndex() < MATTYPE_DIFFUSE) - { - mRadioMatType->selectNthItem(MATTYPE_DIFFUSE); - } + if (mRadioMatType->getSelectedIndex() < MATTYPE_DIFFUSE) + { + mRadioMatType->selectNthItem(MATTYPE_DIFFUSE); + } + mRadioMatType->setEnabled(editable); - } - else - { - LL_WARNS("Materials") << "failed getChild for 'radio_material_type'" << LL_ENDL; - } + //LLRadioGroup* radio_pbr_type = getChild("radio_pbr_type"); + if (mRadioPbrType->getSelectedIndex() < PBRTYPE_ALBEDO) + { + mRadioPbrType->selectNthItem(PBRTYPE_ALBEDO); + } + mRadioPbrType->setEnabled(editable); - mRadioMatType->setEnabled(editable); getChildView("checkbox_sync_settings")->setEnabled(editable); childSetValue("checkbox_sync_settings", gSavedSettings.getBOOL("SyncMaterialSettings")); updateVisibility(); - bool identical = true; // true because it is anded below - bool identical_diffuse = false; - bool identical_norm = false; - bool identical_spec = false; + bool identical = true; // true because it is anded below + bool identical_diffuse = false; + bool identical_norm = false; + bool identical_spec = false; + + // pbr material + bool has_pbr_material = false; + LLTextureCtrl* pbr_ctrl = findChild("pbr_control"); + if (pbr_ctrl) + { + LLUUID pbr_id; + bool identical_pbr; + LLSelectedTE::getPbrMaterialId(pbr_id, identical_pbr); + identical &= identical_pbr; + + pbr_ctrl->setTentative(identical_pbr ? FALSE : TRUE); + pbr_ctrl->setEnabled(editable); + pbr_ctrl->setImageAssetID(pbr_id); + has_pbr_material = pbr_id.notNull(); + } //LLTextureCtrl* texture_ctrl = getChild("texture control"); //LLTextureCtrl* shinytexture_ctrl = getChild("shinytexture control"); @@ -999,9 +1035,9 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) // Color swatch { - getChildView("color label")->setEnabled(editable); + getChildView("color label")->setEnabled(editable && !has_pbr_material); } - //LLColorSwatchCtrl* mColorSwatch = getChild("colorswatch"); + //LLColorSwatchCtrl* mColorSwatch = findChild("colorswatch"); LLColor4 color = LLColor4::white; bool identical_color = false; @@ -1014,17 +1050,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); - mColorSwatch->setEnabled( editable ); + mColorSwatch->setValid(editable && !has_pbr_material); + mColorSwatch->setEnabled(editable && !has_pbr_material); mColorSwatch->setCanApplyImmediately( editable ); } // Color transparency - getChildView("color trans")->setEnabled(editable); + getChildView("color trans")->setEnabled(editable && !has_pbr_material); F32 transparency = (1.f - color.mV[VALPHA]) * 100.f; getChild("ColorTrans")->setValue(editable ? transparency : 0); - getChildView("ColorTrans")->setEnabled(editable); + getChildView("ColorTrans")->setEnabled(editable && !has_pbr_material); // Specular map LLSelectedTEMaterial::getSpecularID(specmap_id, identical_spec); @@ -1069,7 +1105,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) U8 bumpy = 0; // Bumpy - { + { bool identical_bumpy = false; LLSelectedTE::getBumpmap(bumpy,identical_bumpy); @@ -1090,7 +1126,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) getChildView("combobox bumpiness")->setEnabled(editable); getChild("combobox bumpiness")->setTentative(!identical_bumpy); getChildView("label bumpiness")->setEnabled(editable); - } + } // Texture { @@ -1283,11 +1319,20 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) mCtrlShinyScaleU->setValue(spec_scale_s); mCtrlBumpyScaleU->setValue(norm_scale_s); - mCtrlTexScaleU->setEnabled(editable); - mCtrlShinyScaleU->setEnabled(editable && specmap_id.notNull() - && enable_material_controls); // Materials alignment - mCtrlBumpyScaleU->setEnabled(editable && normmap_id.notNull() - && enable_material_controls); // Materials alignment + if (mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR) + { + mCtrlTexScaleU->setEnabled(editable && has_pbr_material); + mCtrlShinyScaleU->setEnabled(editable && has_pbr_material); + mCtrlBumpyScaleU->setEnabled(editable && has_pbr_material); + } + else + { + mCtrlTexScaleU->setEnabled(editable); + mCtrlShinyScaleU->setEnabled(editable && specmap_id.notNull() + && enable_material_controls); // Materials alignment + mCtrlBumpyScaleU->setEnabled(editable && normmap_id.notNull() + && enable_material_controls); // Materials alignment + } BOOL diff_scale_tentative = !(identical && identical_diff_scale_s); BOOL norm_scale_tentative = !(identical && identical_norm_scale_s); @@ -1327,11 +1372,20 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) BOOL norm_scale_tentative = !identical_norm_scale_t; BOOL spec_scale_tentative = !identical_spec_scale_t; - mCtrlTexScaleV->setEnabled(editable); - mCtrlShinyScaleV->setEnabled(editable && specmap_id.notNull() - && enable_material_controls); // Materials alignment - mCtrlBumpyScaleV->setEnabled(editable && normmap_id.notNull() - && enable_material_controls); // Materials alignment + if (mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR) + { + mCtrlTexScaleV->setEnabled(editable && has_pbr_material); + mCtrlShinyScaleV->setEnabled(editable && has_pbr_material); + mCtrlBumpyScaleV->setEnabled(editable && has_pbr_material); + } + else + { + mCtrlTexScaleV->setEnabled(editable); + mCtrlShinyScaleV->setEnabled(editable && specmap_id.notNull() + && enable_material_controls); // Materials alignment + mCtrlBumpyScaleV->setEnabled(editable && normmap_id.notNull() + && enable_material_controls); // Materials alignment + } if (force_set_values) { @@ -1375,11 +1429,20 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) mCtrlBumpyOffsetU->setTentative(LLSD(norm_offset_u_tentative)); mCtrlShinyOffsetU->setTentative(LLSD(spec_offset_u_tentative)); - mCtrlTexOffsetU->setEnabled(editable); - mCtrlShinyOffsetU->setEnabled(editable && specmap_id.notNull() - && enable_material_controls); // Materials alignment - mCtrlBumpyOffsetU->setEnabled(editable && normmap_id.notNull() - && enable_material_controls); // Materials alignment + if (mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR) + { + mCtrlTexOffsetU->setEnabled(editable && has_pbr_material); + mCtrlShinyOffsetU->setEnabled(editable && has_pbr_material); + mCtrlBumpyOffsetU->setEnabled(editable && has_pbr_material); + } + else + { + mCtrlTexOffsetU->setEnabled(editable); + mCtrlShinyOffsetU->setEnabled(editable && specmap_id.notNull() + && enable_material_controls); // Materials alignment + mCtrlBumpyOffsetU->setEnabled(editable && normmap_id.notNull() + && enable_material_controls); // Materials alignment + } } { @@ -1407,11 +1470,20 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) mCtrlBumpyOffsetV->setTentative(LLSD(norm_offset_v_tentative)); mCtrlShinyOffsetV->setTentative(LLSD(spec_offset_v_tentative)); - mCtrlTexOffsetV->setEnabled(editable); - mCtrlShinyOffsetV->setEnabled(editable && specmap_id.notNull() - && enable_material_controls); // Materials alignment - mCtrlBumpyOffsetV->setEnabled(editable && normmap_id.notNull() - && enable_material_controls); // Materials alignment + if (mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR) + { + mCtrlTexOffsetV->setEnabled(editable && has_pbr_material); + mCtrlShinyOffsetV->setEnabled(editable && has_pbr_material); + mCtrlBumpyOffsetV->setEnabled(editable && has_pbr_material); + } + else + { + mCtrlTexOffsetV->setEnabled(editable); + mCtrlShinyOffsetV->setEnabled(editable && specmap_id.notNull() + && enable_material_controls); // Materials alignment + mCtrlBumpyOffsetV->setEnabled(editable && normmap_id.notNull() + && enable_material_controls); // Materials alignment + } } // Texture rotation @@ -1435,12 +1507,21 @@ 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; - - mCtrlTexRot->setEnabled(editable); - mCtrlShinyRot->setEnabled(editable && specmap_id.notNull() - && enable_material_controls); // Materials alignment - mCtrlBumpyRot->setEnabled(editable && normmap_id.notNull() - && enable_material_controls); // Materials alignment + + if (mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR) + { + mCtrlTexRot->setEnabled(editable && has_pbr_material); + mCtrlShinyRot->setEnabled(editable && has_pbr_material); + mCtrlBumpyRot->setEnabled(editable && has_pbr_material); + } + else + { + mCtrlTexRot->setEnabled(editable); + mCtrlShinyRot->setEnabled(editable && specmap_id.notNull() + && enable_material_controls); // Materials alignment + mCtrlBumpyRot->setEnabled(editable && normmap_id.notNull() + && enable_material_controls); // Materials alignment + } mCtrlTexRot->setTentative(diff_rot_tentative); mCtrlBumpyRot->setTentative(LLSD(norm_rot_tentative)); @@ -1458,8 +1539,8 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) LLUICtrl* glow_ctrl = getChild("glow"); glow_ctrl->setValue(glow); glow_ctrl->setTentative(!identical_glow); - glow_ctrl->setEnabled(editable); - getChildView("glow label")->setEnabled(editable); + glow_ctrl->setEnabled(editable && !has_pbr_material); + getChildView("glow label")->setEnabled(editable && !has_pbr_material); } { @@ -1508,44 +1589,63 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) LLComboBox* mComboTexGen = getChild("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 = mComboMatMedia->getCurrentIndex(); F32 repeats = 1.0f; - U32 material_type = (mComboMatMedia->getCurrentIndex() == MATMEDIA_MATERIAL) ? mRadioMatType->getSelectedIndex() : MATTYPE_DIFFUSE; + U32 material_type = MATTYPE_DIFFUSE; + if (material_selection == MATMEDIA_MATERIAL) + { + material_type = mRadioMatType->getSelectedIndex(); + } + else if (material_selection == MATMEDIA_PBR) + { + enabled = editable && has_pbr_material; + material_type = mRadioPbrType->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()) - && enable_material_controls); // Materials Alignment - 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()) + && enable_material_controls); // Materials Alignment + } + identical_repeats = identical_spec_repeats; + repeats = repeats_spec; + } + break; - case MATTYPE_NORMAL: - { - enabled = (editable && ((bumpy == BUMPY_TEXTURE) && !normmap_id.isNull()) - && enable_material_controls); // Materials Alignment - 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()) + && enable_material_controls); // Materials Alignment + } + identical_repeats = identical_norm_repeats; + repeats = repeats_norm; + } + break; + } BOOL repeats_tentative = !identical_repeats; @@ -1574,10 +1674,6 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) LLMaterialPtr material; LLSelectedTEMaterial::getCurrent(material, identical); - // enable this UI box if a single face is selected. - BOOL is_single_face = !LLSelectMgr::getInstance()->getSelection()->isMultipleTESelected(); - childSetEnabled("materialID", static_cast(is_single_face)); // doesn't work - why? - if (material && editable) { LL_DEBUGS("Materials") << material->asLLSD() << LL_ENDL; @@ -1695,8 +1791,6 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) calcp->setVar(LLCalc::TEX_ROTATION, getCurrentTextureRot()); calcp->setVar(LLCalc::TEX_TRANSPARENCY, childGetValue("ColorTrans").asReal()); calcp->setVar(LLCalc::TEX_GLOW, childGetValue("glow").asReal()); - - getChildView("materialID")->setEnabled(editable); } else { @@ -1704,8 +1798,14 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) clearCtrls(); // Disable non-UICtrls - //LLTextureCtrl* texture_ctrl = getChild("texture control"); - if(mTextureCtrl) + LLTextureCtrl* pbr_ctrl = getChild("pbr_control"); + if (pbr_ctrl) + { + pbr_ctrl->setImageAssetID(LLUUID::null); + pbr_ctrl->setEnabled(FALSE); + } + LLTextureCtrl* texture_ctrl = getChild("texture control"); + if(texture_ctrl) { mTextureCtrl->setImageAssetID( LLUUID::null ); mTextureCtrl->setEnabled( FALSE ); // this is a LLUICtrl, but we don't want it to have keyboard focus so we add it as a child, not a ctrl. @@ -1718,10 +1818,10 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) mColorSwatch->setFallbackImage(LLUI::getUIImage("locked_image.j2c") ); mColorSwatch->setValid(FALSE); } - LLRadioGroup* radio_mat_type = getChild("radio_material_type"); - if (radio_mat_type) + //LLRadioGroup* radio_mat_type = getChild("radio_material_type"); + if (mRadioMatType) { - radio_mat_type->setSelectedIndex(0); + mRadioMatType->setSelectedIndex(0); } getChildView("color trans")->setEnabled(FALSE); mCtrlRpt->setEnabled(FALSE); @@ -1837,23 +1937,29 @@ void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) // static void LLPanelFace::updateVisibility() -{ - LLComboBox* combo_matmedia = getChild("combobox matmedia"); - LLRadioGroup* radio_mat_type = getChild("radio_material_type"); - LLComboBox* combo_shininess = getChild("combobox shininess"); - LLComboBox* combo_bumpiness = getChild("combobox bumpiness"); - if (!radio_mat_type || !combo_matmedia || !combo_shininess || !combo_bumpiness) +{ + LLComboBox* combo_matmedia = findChild("combobox matmedia"); + LLRadioGroup* radio_mat_type = findChild("radio_material_type"); + LLRadioGroup* radio_pbr_type = findChild("radio_pbr_type"); + LLComboBox* combo_shininess = findChild("combobox shininess"); + LLComboBox* combo_bumpiness = findChild("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_texture = (show_media || ((material_type == MATTYPE_DIFFUSE) && combo_matmedia->getEnabled())); - bool show_bumpiness = (!show_media) && (material_type == MATTYPE_NORMAL) && combo_matmedia->getEnabled(); - bool show_shininess = (!show_media) && (material_type == MATTYPE_SPECULAR) && combo_matmedia->getEnabled(); - getChildView("radio_material_type")->setVisible(!show_media); + 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(); + 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(); // FIRE-11407 - Be consistant and hide this with the other controls getChildView("rptctrl")->setVisible(combo_matmedia->getEnabled()); getChildView("tex gen")->setVisible(combo_matmedia->getEnabled()); @@ -1866,6 +1972,9 @@ void LLPanelFace::updateVisibility() getChildView("flipTextureScaleV")->setVisible(combo_matmedia->getEnabled()); // + radio_mat_type->setVisible(show_material); + radio_pbr_type->setVisible(show_pbr); + // Media controls getChildView("media_info")->setVisible(show_media); getChildView("add_media")->setVisible(show_media); @@ -1873,20 +1982,21 @@ void LLPanelFace::updateVisibility() getChildView("button align")->setVisible(show_media); // Diffuse texture controls - getChildView("texture control")->setVisible(show_texture && !show_media); - getChildView("label alphamode")->setVisible(show_texture && !show_media); - getChildView("combobox alphamode")->setVisible(show_texture && !show_media); + 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 maskcutoff")->setVisible(false); getChildView("maskcutoff")->setVisible(false); - if (show_texture && !show_media) + if ((show_texture && show_material) || show_pbr) { updateAlphaControls(); } - getChildView("TexScaleU")->setVisible(show_texture); - getChildView("TexScaleV")->setVisible(show_texture); - getChildView("TexRot")->setVisible(show_texture); - getChildView("TexOffsetU")->setVisible(show_texture); - getChildView("TexOffsetV")->setVisible(show_texture); + // 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); @@ -1902,11 +2012,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) @@ -1916,13 +2026,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); } // static @@ -1937,6 +2048,16 @@ void LLPanelFace::onCommitMaterialType(LLUICtrl* ctrl, void* userdata) self->updateUI(); } +// static +void LLPanelFace::onCommitPbrType(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self = (LLPanelFace*)userdata; + // Force to default states to side-step problems with menu contents + // and generally reflecting old state when switching tabs or objects + // + self->updateUI(); +} + // static void LLPanelFace::onCommitBump(LLUICtrl* ctrl, void* userdata) { @@ -2003,8 +2124,8 @@ void LLPanelFace::updateShinyControls(bool is_setting_texture, bool mess_with_sh LLRadioGroup* radio_mat_type = getChild("radio_material_type"); U32 materials_media = combo_matmedia->getCurrentIndex(); U32 material_type = radio_mat_type->getSelectedIndex(); - bool show_media = (materials_media == MATMEDIA_MEDIA) && combo_matmedia->getEnabled(); - bool show_shininess = (!show_media) && (material_type == MATTYPE_SPECULAR) && combo_matmedia->getEnabled(); + bool show_material = (materials_media == MATMEDIA_MATERIAL); + bool show_shininess = show_material && (material_type == MATTYPE_SPECULAR) && combo_matmedia->getEnabled(); U32 shiny_value = comboShiny->getCurrentIndex(); bool show_shinyctrls = (shiny_value == SHINY_TEXTURE) && show_shininess; // Use texture getChildView("label glossiness")->setVisible(show_shinyctrls); @@ -2121,22 +2242,82 @@ void LLPanelFace::onCommitGlow(LLUICtrl* ctrl, void* userdata) self->sendGlow(); } +// static +BOOL LLPanelFace::onDragPbr(LLUICtrl*, LLInventoryItem* item) +{ + BOOL accept = TRUE; + for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin(); + iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++) + { + LLSelectNode* node = *iter; + LLViewerObject* obj = node->getObject(); + if (!LLToolDragAndDrop::isInventoryDropAcceptable(obj, item)) + { + accept = FALSE; + break; + } + } + return accept; +} + +void LLPanelFace::onCommitPbr(const LLSD& data) +{ + LLTextureCtrl* pbr_ctrl = findChild("pbr_control"); + if (!pbr_ctrl) return; + if (!pbr_ctrl->getTentative()) + { + // we grab the item id first, because we want to do a + // permissions check in the selection manager. ARGH! + LLUUID id = pbr_ctrl->getImageItemID(); + if (id.isNull()) + { + id = pbr_ctrl->getImageAssetID(); + } + LLSelectMgr::getInstance()->selectionSetGLTFMaterial(id); + } +} + +void LLPanelFace::onCancelPbr(const LLSD& data) +{ + LLSelectMgr::getInstance()->selectionRevertGLTFMaterials(); +} + +void LLPanelFace::onSelectPbr(const LLSD& data) +{ + LLSelectMgr::getInstance()->saveSelectedObjectTextures(); + + LLTextureCtrl* pbr_ctrl = getChild("pbr_control"); + if (!pbr_ctrl) return; + if (!pbr_ctrl->getTentative()) + { + // we grab the item id first, because we want to do a + // permissions check in the selection manager. ARGH! + LLUUID id = pbr_ctrl->getImageItemID(); + if (id.isNull()) + { + id = pbr_ctrl->getImageAssetID(); + } + LLSelectMgr::getInstance()->selectionSetGLTFMaterial(id); + LLSelectedTEMaterial::setMaterialID(this, id); + } +} + // static BOOL LLPanelFace::onDragTexture(LLUICtrl*, LLInventoryItem* item) { - BOOL accept = TRUE; - for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin(); - iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++) - { - LLSelectNode* node = *iter; - LLViewerObject* obj = node->getObject(); - if(!LLToolDragAndDrop::isInventoryDropAcceptable(obj, item)) - { - accept = FALSE; - break; - } - } - return accept; + BOOL accept = TRUE; + for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin(); + iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++) + { + LLSelectNode* node = *iter; + LLViewerObject* obj = node->getObject(); + if (!LLToolDragAndDrop::isInventoryDropAcceptable(obj, item)) + { + accept = FALSE; + break; + } + } + return accept; } void LLPanelFace::onCommitTexture( const LLSD& data ) @@ -2514,17 +2695,6 @@ void LLPanelFace::onCommitMaterialMaskCutoff(LLUICtrl* ctrl, void* userdata) LLSelectedTEMaterial::setAlphaMaskCutoff(self,self->getCurrentAlphaMaskCutoff()); } -//static -void LLPanelFace::onCommitMaterialID(LLUICtrl* ctrl, void* userdata) -{ - LLPanelFace* self = static_cast(userdata); - LLUUID matID = self->getCurrentMaterialID(); - LLSelectedTEMaterial::setMaterialID(self, matID); - - // Temporary demo hack - replace the TE entries with those from the Material's LLSD - applyMaterialUUID(matID, userdata); -} - // static void LLPanelFace::onCommitTextureInfo( LLUICtrl* ctrl, void* userdata ) { @@ -3659,6 +3829,39 @@ void LLPanelFace::onTextureSelectionChanged(LLInventoryItem* itemp) } } +void LLPanelFace::onPbrSelectionChanged(LLInventoryItem* itemp) +{ + LLTextureCtrl* pbr_ctrl = getChild("pbr_control"); + if (pbr_ctrl) + { + LLUUID obj_owner_id; + std::string obj_owner_name; + LLSelectMgr::instance().selectGetOwner(obj_owner_id, obj_owner_name); + + LLSaleInfo sale_info; + LLSelectMgr::instance().selectGetSaleInfo(sale_info); + + bool can_copy = itemp->getPermissions().allowCopyBy(gAgentID); // do we have perm to copy this texture? + bool can_transfer = itemp->getPermissions().allowOperationBy(PERM_TRANSFER, gAgentID); // do we have perm to transfer this texture? + bool is_object_owner = gAgentID == obj_owner_id; // does object for which we are going to apply texture belong to the agent? + bool not_for_sale = !sale_info.isForSale(); // is object for which we are going to apply texture not for sale? + + if (can_copy && can_transfer) + { + pbr_ctrl->setCanApply(true, true); + return; + } + + // if texture has (no-transfer) attribute it can be applied only for object which we own and is not for sale + pbr_ctrl->setCanApply(false, can_transfer ? true : is_object_owner && not_for_sale); + + if (gSavedSettings.getBOOL("TextureLivePreview")) + { + LLNotificationsUtil::add("LivePreviewUnavailable"); + } + } +} + bool LLPanelFace::isIdenticalPlanarTexgen() { LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; @@ -3738,6 +3941,18 @@ void LLPanelFace::LLSelectedTE::getTexId(LLUUID& id, bool& identical) identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &func, id ); } +void LLPanelFace::LLSelectedTE::getPbrMaterialId(LLUUID& id, bool& identical) +{ + struct LLSelectedTEGetmatId : public LLSelectedTEGetFunctor + { + LLUUID get(LLViewerObject* object, S32 te_index) + { + return object->getRenderMaterialID(te_index); + } + } func; + identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue(&func, id); +} + void LLPanelFace::LLSelectedTEMaterial::getCurrent(LLMaterialPtr& material_ptr, bool& identical_material) { struct MaterialFunctor : public LLSelectedTEGetFunctor @@ -4032,196 +4247,3 @@ void LLPanelFace::changePrecision(S32 decimal_precision) } // - -void LLPanelFace::onSaveMaterial(void* userdata) -{ - // DRTVWR-559, Q&D material picker - save to inventory goes here - LL_DEBUGS("Material") << "saving render material to inventory" << LL_ENDL; - - std::string name = "New Material"; - - LLSD material_data = llsd::map( - "version", "1", - "material", LLSD::emptyMap() - ); - - // gen a new uuid for this asset - LLTransactionID tid; - tid.generate(); // timestamp-based randomization + uniquification - LLAssetID new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); - - material_data["material"] = renderMaterialToLLSD(new_asset_id, userdata); - std::stringstream output; - LLSDSerialize::toNotation(material_data, output); - - //S32 expected_upload_cost = 0;// LLAgentBenefitsMgr::current().getTextureUploadCost(); - - std::string res_name = name; - std::string res_desc = "Saved Material"; - //LLFolderType::EType folder_type = LLFolderType::FT_MATERIAL; - //LLInventoryType::EType inv_type = LLInventoryType::IT_MATERIAL; - U32 next_owner_perm = LLPermissions::DEFAULT.getMaskNextOwner(); - - LLUUID parent = gInventory.findCategoryUUIDForType(LLFolderType::FT_MATERIAL); - const U8 subtype = NO_INV_SUBTYPE; // TODO maybe use AT_SETTINGS and LLSettingsType::ST_MATERIAL ? - - create_inventory_item(gAgent.getID(), gAgent.getSessionID(), parent, tid, res_name, res_desc, - LLAssetType::AT_MATERIAL, LLInventoryType::IT_MATERIAL, subtype, next_owner_perm, - new LLBoostFuncInventoryCallback([output=output.str()](LLUUID const & inv_item_id){ - // from reference in LLSettingsVOBase::createInventoryItem()/updateInventoryItem() - LLResourceUploadInfo::ptr_t uploadInfo = - std::make_shared( - inv_item_id, - LLAssetType::AT_SETTINGS, // TODO switch to AT_MATERIAL - output, - [](LLUUID item_id, LLUUID new_asset_id, LLUUID new_item_id, LLSD response) { - LL_INFOS("Material") << "inventory item uploaded. item: " << item_id << " asset: " << new_asset_id << " new_item_id: " << new_item_id << " response: " << response << LL_ENDL; - LLSD params = llsd::map("ASSET_ID", new_asset_id); - LLNotificationsUtil::add("MaterialCreated", params); - }); - - const LLViewerRegion* region = gAgent.getRegion(); - if (region) - { - std::string agent_url(region->getCapability("UpdateSettingsAgentInventory")); - if (agent_url.empty()) - { - LL_ERRS() << "missing required agent inventory cap url" << LL_ENDL; - } - LLViewerAssetUpload::EnqueueInventoryUpload(agent_url, uploadInfo); - } - }) - ); - -} - -// Fill an LLSD with data describing the current face's texture settings -// TODO 2022-05 FUBAR there are both colliding and different data in LLPanelFace vs the TE. Also, neither one has the diffuse tex settings. -// -LLSD LLPanelFace::renderMaterialToLLSD(LLUUID uuid, void* userdata) -{ - llassert(userdata != nullptr); - - LLSD sd; - - sd.insert("RenderMaterialUUID", LLSD(uuid)); - - // now pull same data from the selected TE (same but different. W T F?) - LLMaterialPtr mat = nullptr; - bool ident; // ? - LLSelectedTEMaterial::getCurrent(mat, ident); - - if (mat) - { - sd.insert("teMaterialID", LLSD(mat->getMaterialID())); - - sd.insert("teNormalMap", LLSD(mat->getNormalID())); - sd.insert("teNormalOffsetX", LLSD(mat->getNormalOffsetX())); - sd.insert("teNormalOffsetY", LLSD(mat->getNormalOffsetY())); - sd.insert("teNormalRepeatX", LLSD(mat->getNormalRepeatX())); - sd.insert("teNormalRepeatY", LLSD(mat->getNormalRepeatY())); - sd.insert("teNormalRotation", LLSD(mat->getNormalRotation())); - - sd.insert("teSpecularMap", LLSD(mat->getSpecularID())); - LLColor4U color = mat->getSpecularLightColor(); - - sd.insert("teSpecularColorR", LLSD(static_cast(color.mV[0]))); - sd.insert("teSpecularColorG", LLSD(static_cast(color.mV[1]))); - sd.insert("teSpecularColorB", LLSD(static_cast(color.mV[2]))); - sd.insert("teSpecularColorA", LLSD(static_cast(color.mV[3]))); - sd.insert("teSpecularExponent", LLSD(static_cast(mat->getSpecularLightExponent()))); - sd.insert("teSpecularOffsetX", LLSD(mat->getSpecularOffsetX())); - sd.insert("teSpecularOffsetY", LLSD(mat->getSpecularOffsetY())); - sd.insert("teSpecularRepeatX", LLSD(mat->getSpecularRepeatX())); - sd.insert("teSpecularRepeatY", LLSD(mat->getSpecularRepeatY())); - sd.insert("teSpecularRotation", LLSD(mat->getSpecularRotation())); - - sd.insert("teAlphaMode", LLSD(static_cast(mat->getDiffuseAlphaMode()))); - sd.insert("teAlphaCutoff", LLSD(static_cast(mat->getAlphaMaskCutoff()))); - sd.insert("teEnvIntensity", LLSD(static_cast(mat->getEnvironmentIntensity()))); - sd.insert("teShaderMask", LLSD(static_cast(mat->getShaderMask()))); - } - else - { - // pull data from the LLPanelFace - LLPanelFace* instance = static_cast(userdata); - sd.insert("pfNormalMap", LLSD(instance->getCurrentNormalMap())); - sd.insert("pfSpecularMap", LLSD(instance->getCurrentSpecularMap())); - sd.insert("pfShininess", LLSD(static_cast(instance->getCurrentShininess()))); - sd.insert("pfBumpiness", LLSD(static_cast(instance->getCurrentBumpiness()))); - sd.insert("pfAlphaMode", LLSD(static_cast(instance->getCurrentDiffuseAlphaMode()))); - sd.insert("pfAlphaCutoff", LLSD(static_cast(instance->getCurrentAlphaMaskCutoff()))); - sd.insert("pfEnvIntensity", LLSD(static_cast(instance->getCurrentEnvIntensity()))); - sd.insert("pfGlossiness", LLSD(static_cast(instance->getCurrentGlossiness()))); - sd.insert("pfNormalRotation", LLSD(instance->getCurrentBumpyRot())); - sd.insert("pfNormalScaleU", LLSD(instance->getCurrentBumpyScaleU())); - sd.insert("pfNormalScaleV", LLSD(instance->getCurrentBumpyScaleV())); - sd.insert("pfNormalOffsetU", LLSD(instance->getCurrentBumpyOffsetU())); - sd.insert("pfNormalOffsetV", LLSD(instance->getCurrentBumpyOffsetV())); - sd.insert("pfSpecularRotation", LLSD(instance->getCurrentShinyRot())); - sd.insert("pfSpecularScaleU", LLSD(instance->getCurrentShinyScaleU())); - sd.insert("pfSpecularScaleV", LLSD(instance->getCurrentShinyScaleV())); - sd.insert("pfSpecularOffsetU", LLSD(instance->getCurrentShinyOffsetU())); - sd.insert("pfSpecularOffsetV", LLSD(instance->getCurrentShinyOffsetV())); - sd.insert("pfMaterialID", LLSD(instance->getCurrentMaterialID())); - } - - return sd; -} - -// Take the individual texture settings from the material and apply to current face & TE -void LLPanelFace::applyMaterialUUID(LLUUID uuid, void* userdata) -{ - llassert(userdata != nullptr); - //LLPanelFace* instance = static_cast(userdata); - - LLFileSystem material_file(uuid, LLAssetType::AT_MATERIAL, LLFileSystem::READ); - S32 bufsize = material_file.getSize(); - llassert(bufsize > 0); - std::vector buffer(bufsize); - material_file.read(&buffer[0], bufsize); - std::istringstream input(std::string(buffer.begin(), buffer.end())); // TODO - extend LLFileSystem to expose iostream interface - LLSD matSD; - - LLSDSerialize::fromNotation(matSD, input, bufsize); - - LL_INFOS() << "dump matSD: " << matSD << LL_ENDL; - - // strip off the versioning wrapper for now - matSD = matSD["material"]; - - // wrong, oops. llassert(uuid == matSD.get("RenderMaterialUUID").asUUID()); // if not, whoo boy - - LLMaterialPtr mat = nullptr; - bool ident; // ? - LLSelectedTEMaterial::getCurrent(mat, ident); - - mat->setMaterialID(matSD.get("teMaterialID").asUUID()); - - mat->setNormalID(matSD.get("teNormalMap").asUUID()); - mat->setNormalOffsetX(matSD.get("teNormalOffsetX").asReal()); - mat->setNormalOffsetY(matSD.get("teNormalOffsetY").asReal()); - mat->setNormalRepeatX(matSD.get("teNormalRepeatX").asReal()); - mat->setNormalRepeatY(matSD.get("teNormalRepeatY").asReal()); - mat->setNormalRotation(matSD.get("teNormalRotation").asReal()); - - mat->setSpecularID(matSD.get("teSpecularMap").asUUID()); - LLColor4U color; - color.mV[0] = static_cast(matSD.get("teSecularColorR").asInteger()); - color.mV[1] = static_cast(matSD.get("teSecularColorG").asInteger()); - color.mV[2] = static_cast(matSD.get("teSecularColorB").asInteger()); - color.mV[3] = static_cast(matSD.get("teSecularColorA").asInteger()); - mat->setSpecularLightColor(color); - mat->setSpecularLightExponent(static_cast(matSD.get("teSpecularExponent").asInteger())); - mat->setSpecularOffsetX(matSD.get("teSpecularOffsetX").asReal()); - mat->setSpecularOffsetY(matSD.get("teSpecularOffsetY").asReal()); - mat->setSpecularRepeatX(matSD.get("teSpecularRepeatX").asReal()); - mat->setSpecularRepeatY(matSD.get("teSpecularRepeatY").asReal()); - mat->setSpecularRotation(matSD.get("teSpecularRotation").asReal()); - - mat->setDiffuseAlphaMode(static_cast(matSD.get("teAlphaMode").asInteger())); - mat->setAlphaMaskCutoff(static_cast(matSD.get("teAlphaCutoff").asInteger())); - mat->setEnvironmentIntensity(static_cast(matSD.get("teEnvIntensity").asInteger())); - //mat->setShaderMask(static_cast(matSD.get(teShaderMask").asInteger()); -} - diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index ada3826d93..e14b1886f8 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -130,11 +130,15 @@ protected: void sendShiny(U32 shininess); // applies and sends shininess void sendFullbright(); // applies and sends full bright void sendGlow(); - void sendMedia(); void alignTestureLayer(); void updateCopyTexButton(); + void onCommitPbr(const LLSD& data); + void onCancelPbr(const LLSD& data); + void onSelectPbr(const LLSD& data); + static BOOL onDragPbr(LLUICtrl* ctrl, LLInventoryItem* item); + // this function is to return TRUE if the drag should succeed. static BOOL onDragTexture(LLUICtrl* ctrl, LLInventoryItem* item); @@ -202,6 +206,7 @@ protected: static void onCommitMaterialsMedia( LLUICtrl* ctrl, void* userdata); static void onCommitMaterialType( LLUICtrl* ctrl, void* userdata); + static void onCommitPbrType(LLUICtrl* ctrl, void* userdata); static void onCommitBump( LLUICtrl* ctrl, void* userdata); static void onCommitTexGen( LLUICtrl* ctrl, void* userdata); static void onCommitShiny( LLUICtrl* ctrl, void* userdata); @@ -213,10 +218,6 @@ protected: static void onClickAutoFix(void*); static void onAlignTexture(void*); - static void onSaveMaterial(void*); - static LLSD renderMaterialToLLSD(LLUUID uuid, void* userdata); - static void applyMaterialUUID(LLUUID uuid, void*); - // Extended copy & paste buttons void onCopyFaces(); void onPasteFaces(); @@ -287,7 +288,6 @@ private: F32 getCurrentShinyScaleV(); F32 getCurrentShinyOffsetU(); F32 getCurrentShinyOffsetV(); - LLUUID getCurrentMaterialID(); // Convenience funcs for diffuse maps F32 getCurrentTextureRot(); @@ -306,7 +306,8 @@ private: LLComboBox* mComboTexGen; LLComboBox* mComboMatMedia; LLRadioGroup* mRadioMatType; - + LLRadioGroup* mRadioPbrType; + LLCheckBoxCtrl *mCheckFullbright; LLTextBox* mLabelColorTransp; @@ -483,6 +484,7 @@ private: * all controls of the floater texture picker which allow to apply the texture will be disabled. */ void onTextureSelectionChanged(LLInventoryItem* itemp); + void onPbrSelectionChanged(LLInventoryItem* itemp); // Extended copy & paste buttons //LLMenuButton* mMenuClipboardColor; @@ -598,6 +600,7 @@ public: static void getFace(class LLFace*& face_to_return, bool& identical_face); static void getImageFormat(LLGLenum& image_format_to_return, bool& identical_face); static void getTexId(LLUUID& id, bool& identical); + static void getPbrMaterialId(LLUUID& id, bool& identical); static void getObjectScaleS(F32& scale_s, bool& identical); static void getObjectScaleT(F32& scale_t, bool& identical); static void getMaxDiffuseRepeats(F32& repeats, bool& identical); diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 7f72212b9a..7598001aec 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 @@ -166,7 +166,7 @@ void LLReflectionMapManager::update() if (realtime && closestDynamic == nullptr && - probe->mCubeArray.notNull() && + probe->mCubeIndex != -1 && probe->getIsDynamic()) { closestDynamic = probe; @@ -324,6 +324,7 @@ S32 LLReflectionMapManager::allocateCubeIndex() { S32 ret = mProbes[i]->mCubeIndex; mProbes[i]->mCubeIndex = -1; + mProbes[i]->mCubeArray = nullptr; return ret; } } diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 10b95eba6b..35cda062c6 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -1845,6 +1845,89 @@ void LLSelectMgr::selectionSetImage(const LLUUID& imageid) getSelection()->applyToObjects(&sendfunc); } +//----------------------------------------------------------------------------- +// selectionSetGLTFMaterial() +//----------------------------------------------------------------------------- +void LLSelectMgr::selectionSetGLTFMaterial(const LLUUID& mat_id) +{ + // First for (no copy) textures and multiple object selection + LLViewerInventoryItem* item = gInventory.getItem(mat_id); + if (item + && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID()) + && (mSelectedObjects->getNumNodes() > 1)) + { + LL_WARNS() << "Attempted to apply no-copy material to multiple objects" + << LL_ENDL; + return; + } + + struct f : public LLSelectedTEFunctor + { + LLViewerInventoryItem* mItem; + LLUUID mMatId; + f(LLViewerInventoryItem* item, const LLUUID& id) : mItem(item), mMatId(id) {} + bool apply(LLViewerObject* objectp, S32 te) + { + if (objectp && !objectp->permModify()) + { + return false; + } + LLUUID asset_id = mMatId; + if (mItem) + { + asset_id = mItem->getAssetUUID(); + } + + if (te != -1) + { + objectp->setRenderMaterialID(te, asset_id); + } + else + { + S32 num_faces = objectp->getNumTEs(); + for (S32 face = 0; face < num_faces; face++) + { + objectp->setRenderMaterialID(face, asset_id); + } + } + + return true; + } + }; + + if (item && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID())) + { + getSelection()->applyNoCopyTextureToTEs(item); + } + else + { + f setfunc(item, mat_id); + getSelection()->applyToTEs(&setfunc); + } + + + struct g : public LLSelectedObjectFunctor + { + LLViewerInventoryItem* mItem; + g(LLViewerInventoryItem* item) : mItem(item) {} + virtual bool apply(LLViewerObject* object) + { + if (!mItem) + { + object->sendTEUpdate(); + // 1 particle effect per object + LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE); + effectp->setSourceObject(gAgentAvatarp); + effectp->setTargetObject(object); + effectp->setDuration(LL_HUD_DUR_SHORT); + effectp->setColor(LLColor4U(gAgent.getEffectColor())); + } + return true; + } + } sendfunc(item); + getSelection()->applyToObjects(&sendfunc); +} + //----------------------------------------------------------------------------- // selectionSetColor() //----------------------------------------------------------------------------- diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index 84872f7186..96a1ccab97 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -678,6 +678,7 @@ public: void selectionSetRestitution(F32 restitution); void selectionSetMaterial(U8 material); void selectionSetImage(const LLUUID& imageid); // could be item or asset id + void selectionSetGLTFMaterial(const LLUUID& mat_id); // could be item or asset id void selectionSetColor(const LLColor4 &color); void selectionSetColorOnly(const LLColor4 &color); // Set only the RGB channels void selectionSetAlphaOnly(const F32 alpha); // Set only the alpha channel diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index c3bec10156..7869413253 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -179,7 +179,8 @@ LLFloaterTexturePicker::LLFloaterTexturePicker( mOnFloaterCloseCallback(NULL), mSetImageAssetIDCallback(NULL), mOnUpdateImageStatsCallback(NULL), - mBakeTextureEnabled(FALSE) + mBakeTextureEnabled(FALSE), + mInventoryPickType(LLTextureCtrl::PICK_TEXTURE) { mCanApplyImmediately = can_apply_immediately; buildFromFile("floater_texture_ctrl.xml"); @@ -462,15 +463,14 @@ BOOL LLFloaterTexturePicker::postBuild() childSetAction("Blank", LLFloaterTexturePicker::onBtnBlank,this); childSetAction("Transparent", LLFloaterTexturePicker::onBtnTransparent,this); // FIRE-5082: "Transparent" button in Texture Panel - - childSetCommitCallback("show_folders_check", onShowFolders, this); - getChildView("show_folders_check")->setVisible( FALSE); - mFilterEdit = getChild("inventory search editor"); mFilterEdit->setCommitCallback(boost::bind(&LLFloaterTexturePicker::onFilterEdit, this, _2)); mInventoryPanel = getChild("inventory panel"); + // if can select both materials and textures, set textures_material_combo's layout as visible + childSetVisible("combo_layout", mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL); + mTextureMaterialsCombo = getChild("textures_material_combo"); mTextureMaterialsCombo->setCommitCallback(onSelectTextureMaterials, this); @@ -527,8 +527,20 @@ BOOL LLFloaterTexturePicker::postBuild() mLocalScrollCtrl = getChild("l_name_list"); mLocalScrollCtrl->setCommitCallback(onLocalScrollCommit, this); mLocalScrollCtrl->clearRows(); - LLLocalBitmapMgr::getInstance()->feedScrollList(mLocalScrollCtrl); - LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + + if (mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + } + else if (mInventoryPickType == LLTextureCtrl::PICK_TEXTURE) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + } + else if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) + { + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + } mNoCopyTextureSelected = FALSE; @@ -565,7 +577,6 @@ void LLFloaterTexturePicker::draw() updateImageStats(); // if we're inactive, gray out "apply immediate" checkbox - getChildView("show_folders_check")->setEnabled(mActive && mCanApplyImmediately && !mNoCopyTextureSelected); getChildView("Select")->setEnabled(mActive && mCanApply); getChildView("Pipette")->setEnabled(mActive); getChild("Pipette")->setValue(LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance()); @@ -956,9 +967,6 @@ void LLFloaterTexturePicker::onModeSelect(LLUICtrl* ctrl, void *userdata) self->getChild("inventory search editor")->setVisible(index == 0 ? TRUE : FALSE); self->getChild("inventory panel")->setVisible(index == 0 ? TRUE : FALSE); - /*self->getChild("show_folders_check")->setVisible(mode); - no idea under which conditions the above is even shown, needs testing. */ - self->getChild("l_add_btn")->setVisible(index == 1 ? TRUE : FALSE); self->getChild("l_rem_btn")->setVisible(index == 1 ? TRUE : FALSE); self->getChild("l_upl_btn")->setVisible(index == 1 ? TRUE : FALSE); @@ -1029,11 +1037,18 @@ void LLFloaterTexturePicker::onBtnAdd(void* userdata) { LLFloaterTexturePicker* self = (LLFloaterTexturePicker*)userdata; - // todo: there will be changes to texture picker to forbid - // selection of materials in some cases, like landmarks, once - // it gets implemented, update code to select FLOAD_* filter - // based on picker's material/texture mode. - LLFilePickerReplyThread::startPicker(boost::bind(&onPickerCallback, _1, self->getHandle()), LLFilePicker::FFLOAD_MATERIAL_TEXTURE, true); + if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL) + { + LLFilePickerReplyThread::startPicker(boost::bind(&onPickerCallback, _1, self->getHandle()), LLFilePicker::FFLOAD_MATERIAL_TEXTURE, true); + } + else if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE) + { + LLFilePickerReplyThread::startPicker(boost::bind(&onPickerCallback, _1, self->getHandle()), LLFilePicker::FFLOAD_IMAGE, true); + } + else if (self->mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) + { + LLFilePickerReplyThread::startPicker(boost::bind(&onPickerCallback, _1, self->getHandle()), LLFilePicker::FFLOAD_MATERIAL, true); + } } // static @@ -1069,8 +1084,20 @@ void LLFloaterTexturePicker::onBtnRemove(void* userdata) self->getChild("l_rem_btn")->setEnabled(false); self->getChild("l_upl_btn")->setEnabled(false); self->mLocalScrollCtrl->clearRows(); - LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); - LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + + if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + } + else if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + } + else if (self->mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) + { + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + } } } @@ -1159,22 +1186,6 @@ void LLFloaterTexturePicker::onLocalScrollCommit(LLUICtrl* ctrl, void* userdata) } } -// static -void LLFloaterTexturePicker::onShowFolders(LLUICtrl* ctrl, void *user_data) -{ - LLCheckBoxCtrl* check_box = (LLCheckBoxCtrl*)ctrl; - LLFloaterTexturePicker* picker = (LLFloaterTexturePicker*)user_data; - - if (check_box->get()) - { - picker->mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); - } - else - { - picker->mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NO_FOLDERS); - } -} - // static void LLFloaterTexturePicker::onApplyImmediateCheck(LLUICtrl* ctrl, void *user_data) { @@ -1324,26 +1335,26 @@ void LLFloaterTexturePicker::onSelectTextureMaterials(LLUICtrl* ctrl, void *user LLFloaterTexturePicker* self = (LLFloaterTexturePicker*)userdata; int index = self->mTextureMaterialsCombo->getValue().asInteger(); - // IMPORTANT: make sure these match the entries in floater_texture_ctrl.xml - // for the textures_material_combo combo box - const int textures_and_materials = 0; - const int textures_only = 1; - const int materials_only = 2; - U32 filter_types = 0x0; - if (index == textures_and_materials) + if (self->mInventoryPickType != LLTextureCtrl::PICK_TEXTURE_MATERIAL) + { + // mInventoryPickType overrides combo + index = self->mInventoryPickType; + } + + if (index == LLTextureCtrl::PICK_TEXTURE_MATERIAL) { filter_types |= 0x1 << LLInventoryType::IT_TEXTURE; filter_types |= 0x1 << LLInventoryType::IT_SNAPSHOT; filter_types |= 0x1 << LLInventoryType::IT_MATERIAL; } - else if (index == textures_only) + else if (index == LLTextureCtrl::PICK_TEXTURE) { filter_types |= 0x1 << LLInventoryType::IT_TEXTURE; filter_types |= 0x1 << LLInventoryType::IT_SNAPSHOT; } - else if (index == materials_only) + else if (index == LLTextureCtrl::PICK_MATERIAL) { filter_types |= 0x1 << LLInventoryType::IT_MATERIAL; } @@ -1395,6 +1406,32 @@ void LLFloaterTexturePicker::setBakeTextureEnabled(BOOL enabled) onModeSelect(0, this); } +void LLFloaterTexturePicker::setInventoryPickType(LLTextureCtrl::EPickInventoryType type) +{ + mInventoryPickType = type; + + // if can select both materials and textures, set textures_material_combo's layout as visible + childSetVisible("combo_layout", mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL); + + mLocalScrollCtrl->clearRows(); + if (mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + } + else if (mInventoryPickType == LLTextureCtrl::PICK_TEXTURE) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + } + else if (mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) + { + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(mLocalScrollCtrl); + } + + // refresh filters + onSelectTextureMaterials(0, this); +} + void LLFloaterTexturePicker::onPickerCallback(const std::vector& filenames, LLHandle handle) { std::vector::const_iterator iter = filenames.begin(); @@ -1420,8 +1457,20 @@ void LLFloaterTexturePicker::onPickerCallback(const std::vector& fi { LLFloaterTexturePicker* self = (LLFloaterTexturePicker*)handle.get(); self->mLocalScrollCtrl->clearRows(); - LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); - LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + + if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE_MATERIAL) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + } + else if (self->mInventoryPickType == LLTextureCtrl::PICK_TEXTURE) + { + LLLocalBitmapMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + } + else if (self->mInventoryPickType == LLTextureCtrl::PICK_MATERIAL) + { + LLLocalGLTFMaterialMgr::getInstance()->feedScrollList(self->mLocalScrollCtrl); + } } } @@ -1475,6 +1524,8 @@ LLTextureCtrl::LLTextureCtrl(const LLTextureCtrl::Params& p) mValid( TRUE ), mShowLoadingPlaceholder( TRUE ), mOpenTexPreview(!p.enabled), // For texture preview mode + mBakeTextureEnabled(true), + mInventoryPickType(PICK_TEXTURE), mImageAssetID(p.image_id), mDefaultImageAssetID(p.default_image_id), mDefaultImageName(p.default_image_name), @@ -1677,14 +1728,10 @@ void LLTextureCtrl::showPicker(BOOL take_focus) if (texture_floaterp) { texture_floaterp->setOnFloaterCommitCallback(boost::bind(&LLTextureCtrl::onFloaterCommit, this, _1, _2)); - } - if (texture_floaterp) - { texture_floaterp->setSetImageAssetIDCallback(boost::bind(&LLTextureCtrl::setImageAssetID, this, _1)); - } - if (texture_floaterp) - { - texture_floaterp->setBakeTextureEnabled(TRUE); + + texture_floaterp->setBakeTextureEnabled(mBakeTextureEnabled); + texture_floaterp->setInventoryPickType(mInventoryPickType); } LLFloater* root_floater = gFloaterView->getParentFloater(this); @@ -1942,8 +1989,9 @@ void LLTextureCtrl::setImageAssetID( const LLUUID& asset_id ) } } -void LLTextureCtrl::setBakeTextureEnabled(BOOL enabled) +void LLTextureCtrl::setBakeTextureEnabled(bool enabled) { + mBakeTextureEnabled = enabled; LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); if (floaterp) { @@ -1951,6 +1999,16 @@ void LLTextureCtrl::setBakeTextureEnabled(BOOL enabled) } } +void LLTextureCtrl::setInventoryPickType(EPickInventoryType type) +{ + mInventoryPickType = type; + LLFloaterTexturePicker* floaterp = (LLFloaterTexturePicker*)mFloaterHandle.get(); + if (floaterp) + { + floaterp->setInventoryPickType(type); + } +} + BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, diff --git a/indra/newview/lltexturectrl.h b/indra/newview/lltexturectrl.h index 3c8057ef33..c2c9364a97 100644 --- a/indra/newview/lltexturectrl.h +++ b/indra/newview/lltexturectrl.h @@ -79,6 +79,15 @@ public: TEXTURE_CANCEL } ETexturePickOp; + // Should match the entries in floater_texture_ctrl.xml + // for the textures_material_combo combo box + typedef enum e_pick_inventory_type + { + PICK_TEXTURE_MATERIAL = 0, + PICK_TEXTURE = 1, + PICK_MATERIAL = 2, + } EPickInventoryType; + public: struct Params : public LLInitParam::Block { @@ -213,7 +222,11 @@ public: LLViewerFetchedTexture* getTexture() { return mTexturep; } - void setBakeTextureEnabled(BOOL enabled); + void setBakeTextureEnabled(bool enabled); + bool getBakeTextureEnabled() const { return mBakeTextureEnabled; } + + void setInventoryPickType(EPickInventoryType type); + EPickInventoryType getInventoryPickType() { return mInventoryPickType; }; // Mask texture if desired void setIsMasked(BOOL masked) { mIsMasked = masked; } @@ -255,7 +268,8 @@ private: std::string mLoadingPlaceholderString; S32 mLabelWidth; bool mOpenTexPreview; - BOOL mBakeTextureEnabled; + bool mBakeTextureEnabled; + LLTextureCtrl::EPickInventoryType mInventoryPickType; // Mask texture if desired BOOL mIsMasked; @@ -342,9 +356,7 @@ public: static void onBtnBlank(void* userdata); static void onBtnTransparent( void* userdata ); // FIRE-5082: "Transparent" button in Texture Panel static void onBtnNone(void* userdata); - static void onBtnClear(void* userdata); void onSelectionChange(const std::deque &items, BOOL user_action); - static void onShowFolders(LLUICtrl* ctrl, void* userdata); static void onApplyImmediateCheck(LLUICtrl* ctrl, void* userdata); void onTextureSelect(const LLTextureEntry& te); @@ -362,6 +374,8 @@ public: void setLocalTextureEnabled(BOOL enabled); void setBakeTextureEnabled(BOOL enabled); + void setInventoryPickType(LLTextureCtrl::EPickInventoryType type); + static void onPickerCallback(const std::vector& filenames, LLHandle handle); protected: @@ -407,6 +421,7 @@ private: bool mCanApply; bool mCanPreview; bool mPreviewSettingChanged; + LLTextureCtrl::EPickInventoryType mInventoryPickType; texture_selected_callback mTextureSelectedCallback; diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index d0c752d17b..c7774adfc7 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -81,12 +81,13 @@ LLPointer LLViewerFetchedTexture::sWhiteImagep = NULL; LLPointer LLViewerFetchedTexture::sDefaultImagep = NULL; LLPointer LLViewerFetchedTexture::sSmokeImagep = NULL; LLPointer LLViewerFetchedTexture::sFlatNormalImagep = NULL; +LLPointer LLViewerFetchedTexture::sDefaultIrradiancePBRp; // [SL:KB] - Patch: Render-TextureToggle (Catznip-4.0) LLPointer LLViewerFetchedTexture::sDefaultDiffuseImagep = NULL; // [/SL:KB] LLViewerMediaTexture::media_map_t LLViewerMediaTexture::sMediaMap; LLTexturePipelineTester* LLViewerTextureManager::sTesterp = NULL; -F32 LLViewerFetchedTexture::sMaxVirtualSize = F32_MAX/2.f; +F32 LLViewerFetchedTexture::sMaxVirtualSize = 8192.f*8192.f; const std::string sTesterName("TextureTester"); @@ -107,7 +108,6 @@ U32 LLViewerTexture::sMinLargeImageSize = 65536; //256 * 256. U32 LLViewerTexture::sMaxSmallImageSize = MAX_CACHED_RAW_IMAGE_AREA; bool LLViewerTexture::sFreezeImageUpdates = false; F32 LLViewerTexture::sCurrentTime = 0.0f; -F32 LLViewerTexture::sTexelPixelRatio = 1.0f; LLViewerTexture::EDebugTexels LLViewerTexture::sDebugTexelsMode = LLViewerTexture::DEBUG_TEXELS_OFF; @@ -472,6 +472,7 @@ void LLViewerTextureManager::cleanup() LLViewerFetchedTexture::sWhiteImagep = NULL; LLViewerFetchedTexture::sFlatNormalImagep = NULL; + LLViewerFetchedTexture::sDefaultIrradiancePBRp = NULL; LLViewerMediaTexture::cleanUpClass(); } @@ -841,7 +842,7 @@ void LLViewerTexture::addTextureStats(F32 virtual_size, BOOL needs_gltexture) co mNeedsGLTexture = TRUE; } - virtual_size *= sTexelPixelRatio; + virtual_size = llmin(virtual_size, LLViewerFetchedTexture::sMaxVirtualSize); if (virtual_size > mMaxVirtualSize) { diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index 92c289bbfb..40eff73457 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -227,7 +227,6 @@ protected: LL::WorkQueue::weak_t mMainQueue; LL::WorkQueue::weak_t mImageQueue; - static F32 sTexelPixelRatio; public: static const U32 sCurrentFileVersion; static S32 sImageCount; @@ -567,6 +566,7 @@ public: static LLPointer sDefaultImagep; // "Default" texture for error cases, the only case of fetched texture which is generated in local. static LLPointer sSmokeImagep; // Old "Default" translucent texture static LLPointer sFlatNormalImagep; // Flat normal map denoting no bumpiness on a surface + static LLPointer sDefaultIrradiancePBRp; // PBR: irradiance // [SL:KB] - Patch: Render-TextureToggle (Catznip-4.0) static LLPointer sDefaultDiffuseImagep; // [/SL:KB] diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 57625c81a4..9941850563 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -123,7 +123,10 @@ void LLViewerTextureList::doPreloadImages() // Set the default flat normal map LLViewerFetchedTexture::sFlatNormalImagep = LLViewerTextureManager::getFetchedTextureFromFile("flatnormal.tga", FTT_LOCAL_FILE, MIPMAP_NO, LLViewerFetchedTexture::BOOST_BUMP); - + + // PBR: irradiance + LLViewerFetchedTexture::sDefaultIrradiancePBRp = LLViewerTextureManager::getFetchedTextureFromFile("default_irradiance.png", FTT_LOCAL_FILE, MIPMAP_YES, LLViewerFetchedTexture::BOOST_UI); + image_list->initFromFile(); // turn off clamping and bilinear filtering for uv picking images @@ -1233,15 +1236,18 @@ BOOL LLViewerTextureList::createUploadFile(const std::string& filename, } // note: modifies the argument raw_image!!!! -LLPointer LLViewerTextureList::convertToUploadFile(LLPointer raw_image, const S32 max_image_dimentions) +LLPointer LLViewerTextureList::convertToUploadFile(LLPointer raw_image, const S32 max_image_dimentions, bool force_lossless) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; raw_image->biasedScaleToPowerOfTwo(max_image_dimentions); LLPointer 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 340b402db1..e6e663587d 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 convertToUploadFile(LLPointer raw_image, const S32 max_image_dimentions = LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT); + static LLPointer convertToUploadFile(LLPointer 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/pipeline.cpp b/indra/newview/pipeline.cpp index d60c090145..7791665191 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8994,6 +8994,11 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) soften_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); soften_shader.uniform4fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV); + if (!LLPipeline::sUnderWaterRender && LLPipeline::sRenderPBR) + { + soften_shader.bindTexture(LLShaderMgr::ALTERNATE_DIFFUSE_MAP, LLViewerFetchedTexture::sDefaultIrradiancePBRp); // PBR: irradiance + } + if(LLPipeline::sRenderPBR) { LLVector3 cameraAtAxis = LLViewerCamera::getInstance()->getAtAxis(); diff --git a/indra/newview/skins/default/textures/default_irradiance.png b/indra/newview/skins/default/textures/default_irradiance.png new file mode 100644 index 0000000000..899e0ddf2a Binary files /dev/null and b/indra/newview/skins/default/textures/default_irradiance.png differ 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 @@ + title="[MATERIAL_NAME]"> no upload fee L$[FEE] upload fee - - + + + - - Albedo: - - - + Albedo: + + + - No upload fee - - + - Tint - - - + + - Transparency - - + - - Alpha mode - - - - - - - - Alpha Cutoff - - - - + Alpha mode + + - + + + + + - Metallic-Roughness: - - + - + + + Metallic-Roughness: + + + - No upload fee - - + - Metallic Factor - - + - - Roughness Factor - - + - - + - - Emissive: - - - + Emissive: + + + - No upload fee - - + - Tint - - - - - + - - Normal: - - - + Normal: + + + - No upload fee - - + No upload fee + + + + diff --git a/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml b/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml index aaec36d473..9d5ad95682 100644 --- a/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml +++ b/indra/newview/skins/default/xui/en/floater_texture_ctrl.xml @@ -164,59 +164,77 @@ word_wrap="true" visible="false" width="87" /> - - - - - - - - + + + + + + + + + + + + +