summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2022-11-30 13:25:25 -0600
committerDave Parks <davep@lindenlab.com>2022-11-30 13:25:25 -0600
commit0186707937852922521eeced28687231d8407deb (patch)
treed1c45591b0037d7ecb06067a3c953630245712b7 /indra
parent87bb72a47a1fc64b98e498120e332de76e6a9211 (diff)
parent0d58d3ee7a4196f31d45dd5a466a452d887a6968 (diff)
Merge branch 'DRTVWR-559' of github.com:secondlife/viewer into DRTVWR-559
Diffstat (limited to 'indra')
-rw-r--r--indra/llrender/llglslshader.cpp20
-rw-r--r--indra/llrender/llglslshader.h9
-rw-r--r--indra/llrender/llvertexbuffer.cpp62
-rw-r--r--indra/llrender/llvertexbuffer.h1
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl112
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/moonF.glsl8
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/starsF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/waterV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/moonF.glsl51
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/moonV.glsl (renamed from indra/newview/app_settings/shaders/class1/objects/indexedTextureF.glsl)19
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/starsF.glsl (renamed from indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendF.glsl)30
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/starsV.glsl (renamed from indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendV.glsl)38
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/waterV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/windlight/moonF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl6
-rw-r--r--indra/newview/llagentcamera.cpp7
-rw-r--r--indra/newview/llappviewer.cpp2
-rw-r--r--indra/newview/lldrawpoolsky.cpp23
-rw-r--r--indra/newview/lldrawpoolwater.cpp229
-rw-r--r--indra/newview/lldrawpoolwlsky.cpp16
-rw-r--r--indra/newview/llface.cpp28
-rw-r--r--indra/newview/llface.h3
-rw-r--r--indra/newview/llgltfmateriallist.cpp54
-rw-r--r--indra/newview/llgltfmateriallist.h2
-rw-r--r--indra/newview/lllocalgltfmaterials.cpp10
-rw-r--r--indra/newview/lllocalgltfmaterials.h10
-rw-r--r--indra/newview/llmaterialeditor.cpp109
-rw-r--r--indra/newview/llmaterialeditor.h4
-rw-r--r--indra/newview/llpanelface.cpp228
-rw-r--r--indra/newview/llpanelface.h66
-rw-r--r--indra/newview/llviewermenu.cpp2
-rw-r--r--indra/newview/llviewermenu.h1
-rw-r--r--indra/newview/llviewershadermgr.cpp40
-rw-r--r--indra/newview/llviewershadermgr.h2
-rw-r--r--indra/newview/llviewerstats.cpp106
-rw-r--r--indra/newview/llviewertexture.cpp30
-rw-r--r--indra/newview/llviewertexture.h5
-rw-r--r--indra/newview/llvovolume.cpp236
-rw-r--r--indra/newview/llvovolume.h20
40 files changed, 833 insertions, 776 deletions
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index d634945632..e3b29dc812 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -61,6 +61,21 @@ U32 LLGLSLShader::sTotalDrawCalls = 0;
LLGLSLShader gUIProgram;
LLGLSLShader gSolidColorProgram;
+// NOTE: Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync!
+const std::string gShaderConstsKey[ LLGLSLShader::NUM_SHADER_CONSTS ] =
+{
+ "LL_SHADER_CONST_CLOUD_MOON_DEPTH"
+ , "LL_SHADER_CONST_STAR_DEPTH"
+};
+
+// NOTE: Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync!
+const std::string gShaderConstsVal[ LLGLSLShader::NUM_SHADER_CONSTS ] =
+{
+ "0.99998" // SHADER_CONST_CLOUD_MOON_DEPTH // SL-14113
+ , "0.99999" // SHADER_CONST_STAR_DEPTH // SL-14113
+};
+
+
BOOL shouldChange(const LLVector4& v1, const LLVector4& v2)
{
return v1 != v2;
@@ -776,6 +791,11 @@ void LLGLSLShader::addPermutation(std::string name, std::string value)
mDefines[name] = value;
}
+void LLGLSLShader::addConstant( const LLGLSLShader::eShaderConsts shader_const )
+{
+ addPermutation( gShaderConstsKey[ shader_const ], gShaderConstsVal[ shader_const ] );
+}
+
void LLGLSLShader::removePermutation(std::string name)
{
mDefines[name].erase();
diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h
index 67a9fca53a..23db1a8549 100644
--- a/indra/llrender/llglslshader.h
+++ b/indra/llrender/llglslshader.h
@@ -135,6 +135,13 @@ public:
class LLGLSLShader
{
public:
+ // NOTE: Keep gShaderConsts and LLGLSLShader::ShaderConsts_e in sync!
+ enum eShaderConsts
+ {
+ SHADER_CONST_CLOUD_MOON_DEPTH
+ , SHADER_CONST_STAR_DEPTH
+ , NUM_SHADER_CONSTS
+ };
// enum primarily used to control application sky settings uniforms
typedef enum
@@ -224,6 +231,8 @@ public:
void addPermutation(std::string name, std::string value);
void removePermutation(std::string name);
+ void addConstant( const LLGLSLShader::eShaderConsts shader_const );
+
//enable/disable texture channel for specified uniform
//if given texture uniform is active in the shader,
//the corresponding channel will be active upon return
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index fc24c6846d..adb3d99553 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -74,10 +74,12 @@ U32 vbo_block_size(U32 size)
U32 vbo_block_index(U32 size)
{
- return vbo_block_size(size)/LL_VBO_BLOCK_SIZE;
+ U32 blocks = vbo_block_size(size)/LL_VBO_BLOCK_SIZE; // block count reqd
+ llassert(blocks > 0);
+ return blocks - 1; // Adj index, i.e. single-block allocations are at index 0, etc
}
-const U32 LL_VBO_POOL_SEED_COUNT = vbo_block_index(LL_VBO_POOL_MAX_SEED_SIZE);
+const U32 LL_VBO_POOL_SEED_COUNT = vbo_block_index(LL_VBO_POOL_MAX_SEED_SIZE) + 1;
//============================================================================
@@ -120,7 +122,6 @@ bool LLVertexBuffer::sUseStreamDraw = true;
bool LLVertexBuffer::sUseVAO = false;
bool LLVertexBuffer::sPreferStreamDraw = false;
-
U32 LLVBOPool::genBuffer()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX
@@ -151,8 +152,9 @@ void LLVBOPool::deleteBuffer(U32 name)
LLVBOPool::LLVBOPool(U32 vboUsage, U32 vboType)
-: mUsage(vboUsage), mType(vboType)
+: mUsage(vboUsage), mType(vboType), mMissCountDirty(true)
{
+ mFreeList.resize(LL_VBO_POOL_SEED_COUNT);
mMissCount.resize(LL_VBO_POOL_SEED_COUNT);
std::fill(mMissCount.begin(), mMissCount.end(), 0);
}
@@ -181,6 +183,7 @@ U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed)
if (!for_seed && i < LL_VBO_POOL_SEED_COUNT)
{ //record this miss
mMissCount[i]++;
+ mMissCountDirty = true; // signal to ::seedPool()
}
if (mType == GL_ARRAY_BUFFER)
@@ -200,13 +203,13 @@ U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed)
ret = (U8*) ll_aligned_malloc<64>(size);
if (!ret)
{
- LL_ERRS() << "Failed to allocate "<< size << " bytes for LLVBOPool buffer " << name <<"." << LL_NEWLINE
- << "Free list size: " << mFreeList.size() // this happens if we are out of memory so a solution might be to clear some from freelist
+ LL_ERRS()
+ << "Failed to allocate " << size << " bytes for LLVBOPool buffer " << name << "." << LL_NEWLINE
+ << "Free list size: "
+ << mFreeList.size() // this happens if we are out of memory so a solution might be to clear some from freelist
<< " Allocated Bytes: " << LLVertexBuffer::sAllocatedBytes
- << " Allocated Index Bytes: " << LLVertexBuffer::sAllocatedIndexBytes
- << " Pooled Bytes: " << sBytesPooled
- << " Pooled Index Bytes: " << sIndexBytesPooled
- << LL_ENDL;
+ << " Allocated Index Bytes: " << LLVertexBuffer::sAllocatedIndexBytes << " Pooled Bytes: " << sBytesPooled
+ << " Pooled Index Bytes: " << sIndexBytesPooled << LL_ENDL;
}
}
}
@@ -234,6 +237,7 @@ U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed)
sIndexBytesPooled += size;
}
mFreeList[i].push_back(rec);
+ mMissCountDirty = true; // signal to ::seedPool()
}
}
else
@@ -251,6 +255,7 @@ U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed)
}
mFreeList[i].pop_front();
+ mMissCountDirty = true; // signal to ::seedPool()
}
return ret;
@@ -276,31 +281,27 @@ void LLVBOPool::release(U32 name, U8* buffer, U32 size)
void LLVBOPool::seedPool()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_VERTEX
- U32 dummy_name = 0;
-
- if (mFreeList.size() < LL_VBO_POOL_SEED_COUNT)
+ if (mMissCountDirty)
{
- LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("VBOPool Resize");
- mFreeList.resize(LL_VBO_POOL_SEED_COUNT);
- }
+ U32 dummy_name = 0;
+ U32 size = LL_VBO_BLOCK_SIZE;
for (U32 i = 0; i < LL_VBO_POOL_SEED_COUNT; i++)
{
if (mMissCount[i] > mFreeList[i].size())
{
- U32 size = i*LL_VBO_BLOCK_SIZE;
-
S32 count = mMissCount[i] - mFreeList[i].size();
for (U32 j = 0; j < count; ++j)
{
allocate(dummy_name, size, true);
}
}
+ size += LL_VBO_BLOCK_SIZE;
+ }
+ mMissCountDirty = false;
}
}
-
-
void LLVBOPool::cleanup()
{
U32 size = LL_VBO_BLOCK_SIZE;
@@ -478,7 +479,7 @@ void LLVertexBuffer::drawArrays(U32 mode, const std::vector<LLVector3>& pos)
}
gGL.end();
gGL.flush();
-}
+ }
//static
void LLVertexBuffer::drawElements(U32 mode, const LLVector4a* pos, const LLVector2* tc, S32 num_indices, const U16* indicesp)
@@ -514,7 +515,7 @@ void LLVertexBuffer::drawElements(U32 mode, const LLVector4a* pos, const LLVecto
U16 idx = indicesp[i];
gGL.vertex3fv(pos[idx].getF32ptr());
}
- }
+}
gGL.end();
gGL.flush();
}
@@ -709,10 +710,10 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const
#ifndef LL_RELEASE_FOR_DOWNLOAD
llassert(mNumVerts >= 0);
- if (first >= (U32)mNumVerts ||
- first + count > (U32)mNumVerts)
+ if (first >= (U32) mNumVerts ||
+ first + count > (U32) mNumVerts)
{
- LL_ERRS() << "Bad vertex buffer draw range: [" << first << ", " << first + count << "]" << LL_ENDL;
+ LL_ERRS() << "Bad vertex buffer draw range: [" << first << ", " << first+count << "]" << LL_ENDL;
}
if (mGLArray)
@@ -792,6 +793,11 @@ void LLVertexBuffer::cleanupClass()
sStreamVBOPool.cleanup();
sDynamicVBOPool.cleanup();
sDynamicCopyVBOPool.cleanup();
+
+ llassert(0 == LLVBOPool::sBytesPooled);
+ llassert(0 == LLVBOPool::sIndexBytesPooled);
+ llassert(0 == sAllocatedBytes);
+ llassert(0 == sAllocatedIndexBytes);
}
//----------------------------------------------------------------------------
@@ -2381,10 +2387,10 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask)
}
llglassertok();
-}
+ }
void LLVertexBuffer::setupVertexBufferFast(U32 data_mask)
-{
+ {
U8* base = (U8*)mAlignedOffset;
if (data_mask & MAP_NORMAL)
@@ -2472,7 +2478,7 @@ void LLVertexBuffer::setupVertexBufferFast(U32 data_mask)
void* ptr = (void*)(base + mOffsets[TYPE_VERTEX]);
glVertexAttribPointer(loc, 3, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_VERTEX], ptr);
}
-}
+ }
LLVertexBuffer::MappedRegion::MappedRegion(S32 type, S32 index, S32 count)
: mType(type), mIndex(index), mCount(count)
diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h
index e846ab70e2..4d73cf07c0 100644
--- a/indra/llrender/llvertexbuffer.h
+++ b/indra/llrender/llvertexbuffer.h
@@ -88,6 +88,7 @@ public:
typedef std::list<Record> record_list_t;
std::vector<record_list_t> mFreeList;
std::vector<U32> mMissCount;
+ bool mMissCountDirty; // flag any changes to mFreeList or mMissCount
//used to avoid calling glGenBuffers for every VBO creation
static U32 sNamePool[1024];
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl
deleted file mode 100644
index bbdc8fdd1c..0000000000
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- * @file avatarAlphaNoColorV.glsl
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2007, 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$
- */
-
-uniform mat4 projection_matrix;
-
-ATTRIBUTE vec3 position;
-ATTRIBUTE vec3 normal;
-ATTRIBUTE vec2 texcoord0;
-
-mat4 getSkinnedTransform();
-void calcAtmospherics(vec3 inPositionEye);
-
-float calcDirectionalLight(vec3 n, vec3 l);
-
-vec3 atmosAmbient();
-vec3 atmosAffectDirectionalLight(float lightIntensity);
-
-VARYING vec3 vary_position;
-VARYING vec3 vary_ambient;
-VARYING vec3 vary_directional;
-VARYING vec3 vary_fragcoord;
-VARYING vec3 vary_pointlight_col;
-VARYING vec2 vary_texcoord0;
-VARYING vec3 vary_norm;
-
-
-uniform float near_clip;
-
-uniform vec4 color;
-
-uniform vec4 light_position[8];
-uniform vec3 light_direction[8];
-uniform vec3 light_attenuation[8];
-uniform vec3 light_diffuse[8];
-
-float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight);
-
-void main()
-{
- vary_texcoord0 = texcoord0;
-
- vec4 pos;
- vec3 norm;
-
- mat4 trans = getSkinnedTransform();
- vec4 pos_in = vec4(position.xyz, 1.0);
- pos.x = dot(trans[0], pos_in);
- pos.y = dot(trans[1], pos_in);
- pos.z = dot(trans[2], pos_in);
- pos.w = 1.0;
-
- norm.x = dot(trans[0].xyz, normal);
- norm.y = dot(trans[1].xyz, normal);
- norm.z = dot(trans[2].xyz, normal);
- norm = normalize(norm);
- vary_norm = norm;
-
- vec4 frag_pos = projection_matrix * pos;
- gl_Position = frag_pos;
-
- vary_position = pos.xyz;
-
- calcAtmospherics(pos.xyz);
-
- vec4 col = vec4(0.0, 0.0, 0.0, 1.0);
-
- // Collect normal lights
- col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z);
- col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z);
- col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z);
- col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z);
- col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z);
- col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z);
-
- vary_pointlight_col = col.rgb*color.rgb;
-
- col.rgb = vec3(0,0,0);
-
- // Add windlight lights
- col.rgb = atmosAmbient();
-
- vary_ambient = col.rgb*color.rgb;
- vary_directional = color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), 0.0));
-
- col.rgb = col.rgb * color.rgb;
-
- vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip);
-}
-
-
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl
index 788ce4a47b..b45dfcd550 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl
@@ -126,6 +126,6 @@ void main()
frag_data[1] = vec4(0.0,0.0,0.0,0.0);
frag_data[2] = vec4(0,0,0,GBUFFER_FLAG_SKIP_ATMOS);
- gl_FragDepth = 0.99995f;
+ gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; // SL-14113 Stars and Clouds need same depth
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl
index b4044353b4..7032c45603 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl
@@ -54,6 +54,12 @@ void main()
fade = clamp( moon_dir.z*moon_dir.z*4.0, 0.0, 1.0 );
vec4 c = texture2D(diffuseMap, vary_texcoord0.xy);
+
+ // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible
+ // Moon texture has transparent pixels <0x55,0x55,0x55,0x00>
+ if (c.a <= 2./255.) // 0.00784
+ discard;
+
// c.rgb = srgb_to_linear(c.rgb);
c.rgb *= moonlight_color.rgb;
c.rgb *= moon_brightness;
@@ -67,6 +73,6 @@ void main()
frag_data[1] = vec4(0.0);
frag_data[2] = vec4(0.0, 0.0, 0.0, GBUFFER_FLAG_HAS_ATMOS);
- gl_FragDepth = 0.999985f;
+ gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; // SL-14113
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
index ef9cee3fa0..6376527273 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
@@ -46,8 +46,13 @@ float twinkle(){
return abs(d);
}
+// See:
+// ALM off: class1/environment/starsF.glsl
+// ALM on : class1/deferred/starsF.glsl
void main()
{
+ // camera above water: class1\deferred\starsF.glsl
+ // camera below water: class1\environment\starsF.glsl
vec4 col_a = texture2D(diffuseMap, vary_texcoord0.xy);
vec4 col_b = texture2D(diffuseMap, vary_texcoord0.xy);
vec4 col = mix(col_b, col_a, blend_factor);
@@ -62,6 +67,6 @@ void main()
frag_data[1] = vec4(0.0f);
frag_data[2] = vec4(0.0, 1.0, 0.0, GBUFFER_FLAG_SKIP_ATMOS);
- gl_FragDepth = 0.99995f;
+ gl_FragDepth = LL_SHADER_CONST_STAR_DEPTH; // SL-14113 Moon Haze -- Stars need to depth test behind the moon
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl
index 8863869e44..38276859a0 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl
@@ -70,7 +70,7 @@ void main()
d *= d;
oPosition = vec4(position, 1.0);
- oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d);
+// oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d); // SL-11589 remove "U" shaped horizon
vary_position = modelview_matrix * oPosition;
oPosition = modelViewProj * oPosition;
diff --git a/indra/newview/app_settings/shaders/class1/environment/moonF.glsl b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl
new file mode 100644
index 0000000000..a220971f06
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl
@@ -0,0 +1,51 @@
+/**
+ * @file class1/environment/moonF.glsl
+ *
+ * $LicenseInfo:firstyear=2021&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2021, 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$
+ */
+
+#ifdef DEFINE_GL_FRAGCOLOR
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor
+#endif
+
+uniform sampler2D tex0;
+
+VARYING vec2 vary_texcoord0;
+
+// See:
+// AS off: class1/environment/moonF.glsl
+// ALM off: class1/windlight/moonF.glsl
+// ALM on : class1/deferred/moonF.glsl
+void main()
+{
+ vec4 color = texture2D(tex0, vary_texcoord0.xy);
+
+ // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible
+ // Moon texture has transparent pixels <0x55,0x55,0x55,0x00>
+ if (color.a <= 2./255.) // 0.00784
+ discard;
+
+ frag_color = color;
+ gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; // SL-14113 Moon is infront of stars
+}
diff --git a/indra/newview/app_settings/shaders/class1/objects/indexedTextureF.glsl b/indra/newview/app_settings/shaders/class1/environment/moonV.glsl
index 254c1d4fc2..c00f202c23 100644
--- a/indra/newview/app_settings/shaders/class1/objects/indexedTextureF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/moonV.glsl
@@ -1,9 +1,9 @@
/**
- * @file fullbrightF.glsl
+ * @file class1\environment\moonV.glsl
*
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * $LicenseInfo:firstyear=2021&license=viewerlgpl$
* Second Life Viewer Source Code
- * Copyright (C) 2007, Linden Research, Inc.
+ * Copyright (C) 2021, 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
@@ -22,12 +22,17 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
-
-
+uniform mat4 modelview_projection_matrix;
-void main()
+ATTRIBUTE vec3 position;
+ATTRIBUTE vec2 texcoord0;
+
+VARYING vec2 vary_texcoord0;
+
+void main()
{
- fullbright_lighting();
+ gl_Position = modelview_projection_matrix * vec4(position, 1);
+ vary_texcoord0 = texcoord0;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendF.glsl b/indra/newview/app_settings/shaders/class1/environment/starsF.glsl
index 44f2a73e1f..e1a9cc6387 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/starsF.glsl
@@ -1,9 +1,9 @@
/**
- * @file shadowAlphaMaskF.glsl
+ * @file class1/environment/starsF.glsl
*
- * $LicenseInfo:firstyear=2011&license=viewerlgpl$
+ * $LicenseInfo:firstyear=2021&license=viewerlgpl$
* Second Life Viewer Source Code
- * Copyright (C) 2011, Linden Research, Inc.
+ * Copyright (C) 2021, 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
@@ -23,8 +23,6 @@
* $/LicenseInfo$
*/
-/*[EXTRA_CODE_HERE]*/
-
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
@@ -33,23 +31,21 @@ out vec4 frag_color;
uniform sampler2D diffuseMap;
-#if !defined(DEPTH_CLAMP)
-VARYING float pos_zd2;
-#endif
-
-VARYING float pos_w;
+uniform float custom_alpha;
-VARYING float target_pos_x;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
+// See:
+// ALM off: class1/environment/starsF.glsl
+// ALM on : class1/deferred/starsF.glsl
void main()
{
- float alpha = diffuseLookup(vary_texcoord0.xy).a * vertex_color.a;
+ vec4 color = texture2D(diffuseMap, vary_texcoord0.xy);
+ color.rgb = pow(color.rgb, vec3(0.45));
+ color.rgb *= vertex_color.rgb;
+ color.a *= max(custom_alpha, vertex_color.a);
- frag_color = vec4(alpha, alpha, alpha, 1);
-
-#if !defined(DEPTH_CLAMP)
- gl_FragDepth = max(pos_zd2/pos_w+0.5, 0.0);
-#endif
+ frag_color = color;
+ gl_FragDepth = LL_SHADER_CONST_STAR_DEPTH; // SL-14113 Moon Haze -- Stars need to depth test behind the moon
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendV.glsl b/indra/newview/app_settings/shaders/class1/environment/starsV.glsl
index f45c343066..6fcfec6b6a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaBlendV.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/starsV.glsl
@@ -1,9 +1,9 @@
/**
- * @file shadowAlphaMaskV.glsl
+ * @file class1/environment/starsV.glsl
*
- * $LicenseInfo:firstyear=2011&license=viewerlgpl$
+ * $LicenseInfo:firstyear=2021&license=viewerlgpl$
* Second Life Viewer Source Code
- * Copyright (C) 2011, Linden Research, Inc.
+ * Copyright (C) 2021, 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
@@ -23,45 +23,19 @@
* $/LicenseInfo$
*/
-uniform mat4 texture_matrix0;
uniform mat4 modelview_projection_matrix;
-uniform float shadow_target_width;
ATTRIBUTE vec3 position;
ATTRIBUTE vec4 diffuse_color;
ATTRIBUTE vec2 texcoord0;
-#if !defined(DEPTH_CLAMP)
-VARYING float pos_zd2;
-#endif
-
-VARYING float pos_w;
-
-VARYING float target_pos_x;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
-void passTextureIndex();
-
void main()
{
- //transform vertex
- vec4 pre_pos = vec4(position.xyz, 1.0);
- vec4 pos = modelview_projection_matrix * pre_pos;
- target_pos_x = 0.5 * (shadow_target_width - 1.0) * pos.x;
-
- pos_w = pos.w;
-
-#if !defined(DEPTH_CLAMP)
- pos_zd2 = pos.z * 0.5;
-
- gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w);
-#else
- gl_Position = pos;
-#endif
-
- passTextureIndex();
-
- vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
+ gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+ vary_texcoord0 = texcoord0;
vertex_color = diffuse_color;
}
+
diff --git a/indra/newview/app_settings/shaders/class1/environment/waterV.glsl b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl
index a0a0e7dfca..ac400aa2a6 100644
--- a/indra/newview/app_settings/shaders/class1/environment/waterV.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl
@@ -80,7 +80,7 @@ void main()
d *= d;
oPosition = vec4(position, 1.0);
- oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d);
+// oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d); // SL-11589 remove "U" shaped horizon
oPosition = modelViewProj * oPosition;
diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl
index f03003f5e1..c4ab0c95dc 100644
--- a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl
+++ b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl
@@ -51,6 +51,12 @@ void main()
fade = clamp( moon_dir.z*moon_dir.z*4.0, 0.0, 1.0 );
vec4 c = texture2D(diffuseMap, vary_texcoord0.xy);
+
+ // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible
+ // Moon texture has transparent pixels <0x55,0x55,0x55,0x00>
+ if (c.a <= 2./255.) // 0.00784
+ discard;
+
// c.rgb = pow(c.rgb, vec3(0.7f)); // can't use "srgb_to_linear(color.rgb)" as that is a deferred only function
c.rgb *= moonlight_color.rgb;
c.rgb *= moon_brightness;
@@ -61,5 +67,6 @@ void main()
c.rgb = scaleSoftClip(c.rgb);
frag_color = vec4(c.rgb, c.a);
+ gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; // SL-14113
}
diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl
index 9c5a4903d0..6f4bdbde28 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl
@@ -127,5 +127,11 @@ void main()
/// Gamma correct for WL (soft clip effect).
frag_color = vec4(color.rgb, alpha1);
+
+ // SL-14113 Moon Haze -- When the camera is underwater fix clouds clipping into moon
+ // camera above water: class1\deferred\cloudsF.glsl
+ // camera below water: class2\windlight\coudsV.glsl
+ // See: starsV.glsl, cloudsV.glsl, moonF.glsl
+ gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH;
}
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 57a59d81c4..5de52c1daf 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -2043,6 +2043,13 @@ LLVector3d LLAgentCamera::getFocusOffsetInitial()
F32 LLAgentCamera::getCameraMaxZoomDistance()
{
+ // SL-14706 / SL-14885 TPV have relaxed camera constraints allowing you to mousewheeel zoom WAY out.
+ static LLCachedControl<bool> s_disable_camera_constraints(gSavedSettings, "DisableCameraConstraints", false);
+ if (s_disable_camera_constraints)
+ {
+ return (F32)INT_MAX;
+ }
+
// Ignore "DisableCameraConstraints", we don't want to be out of draw range when we focus onto objects or avatars
return llmin(MAX_CAMERA_DISTANCE_FROM_OBJECT,
mDrawDistance - 1, // convenience, don't hit draw limit when focusing on something
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index dcc12a865b..cd8f9d2065 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -572,7 +572,7 @@ static void settings_modify()
LLPipeline::sRenderDeferred = TRUE; // FALSE is deprecated -- LLPipeline::sRenderBump&& gSavedSettings.getBOOL("RenderDeferred");
LLRenderTarget::sUseFBO = LLPipeline::sRenderDeferred;
LLVOSurfacePatch::sLODFactor = gSavedSettings.getF32("RenderTerrainLODFactor");
- LLVOSurfacePatch::sLODFactor *= LLVOSurfacePatch::sLODFactor; // square lod factor to get exponential range of [1,4]
+ LLVOSurfacePatch::sLODFactor *= LLVOSurfacePatch::sLODFactor; //square lod factor to get exponential range of [1,4]
gDebugGL = gDebugGLSession || gDebugSession;
gDebugPipeline = gSavedSettings.getBOOL("RenderDebugPipeline");
}
diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp
index 55ebf03adc..a7b5ec5fc8 100644
--- a/indra/newview/lldrawpoolsky.cpp
+++ b/indra/newview/lldrawpoolsky.cpp
@@ -51,7 +51,7 @@ LLDrawPoolSky::LLDrawPoolSky()
void LLDrawPoolSky::prerender()
{
mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT);
- if (gSky.mVOSkyp->mDrawable)
+ if (gSky.mVOSkyp && gSky.mVOSkyp->mDrawable)
{
gSky.mVOSkyp->updateGeometry(gSky.mVOSkyp->mDrawable);
}
@@ -112,20 +112,39 @@ void LLDrawPoolSky::renderSkyFace(U8 index)
return;
}
- if (index < 6) // sky tex...interp
+ if (index < LLVOSky::FACE_SUN) // sky tex...interp
{
llassert(mSkyTex);
mSkyTex[index].bindTexture(true); // bind the current tex
face->renderIndexed();
}
+ else // Moon
+ if (index == LLVOSky::FACE_MOON)
+ {
+ LLGLSPipelineDepthTestSkyBox gls_skybox(true, true); // SL-14113 Write depth for moon so stars can test if behind it
+
+ LLGLEnable blend(GL_BLEND);
+
+ // if (LLGLSLShader::sNoFixedFunction) // TODO: Necessary? is this always true? We already bailed on gPipeline.canUseWindLightShaders ... above
+ LLViewerTexture* tex = face->getTexture(LLRender::DIFFUSE_MAP);
+ if (tex)
+ {
+ gMoonProgram.bind(); // SL-14113 was gOneTextureNoColorProgram
+ gGL.getTexUnit(0)->bind(tex, true);
+ face->renderIndexed();
+ }
+ }
else // heavenly body faces, no interp...
{
+ LLGLSPipelineDepthTestSkyBox gls_skybox(true, false); // reset to previous
+
LLGLEnable blend(GL_BLEND);
LLViewerTexture* tex = face->getTexture(LLRender::DIFFUSE_MAP);
if (tex)
{
+ gOneTextureNoColorProgram.bind();
gGL.getTexUnit(0)->bind(tex, true);
face->renderIndexed();
}
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index 3f39716449..21b2e56c7c 100644
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -357,7 +357,7 @@ void LLDrawPoolWater::renderOpaqueLegacyWater()
{
#if 0
LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL;
- LLVOSky *voskyp = gSky.mVOSkyp;
+ LLVOSky *voskyp = gSky.mVOSkyp;
if (voskyp == NULL)
{
@@ -365,16 +365,16 @@ void LLDrawPoolWater::renderOpaqueLegacyWater()
}
LLGLSLShader* shader = NULL;
- if (LLPipeline::sUnderWaterRender)
- {
- shader = &gObjectSimpleNonIndexedTexGenWaterProgram;
- }
- else
- {
- shader = &gObjectSimpleNonIndexedTexGenProgram;
- }
+ if (LLPipeline::sUnderWaterRender)
+ {
+ shader = &gObjectSimpleNonIndexedTexGenWaterProgram;
+ }
+ else
+ {
+ shader = &gObjectSimpleNonIndexedTexGenProgram;
+ }
- shader->bind();
+ shader->bind();
stop_glerror();
@@ -508,9 +508,9 @@ void LLDrawPoolWater::renderWater()
LLColor3 light_diffuse(0, 0, 0);
F32 light_exp = 0.0f;
- LLEnvironment & environment = LLEnvironment::instance();
- LLSettingsWater::ptr_t pwater = environment.getCurrentWater();
- LLSettingsSky::ptr_t psky = environment.getCurrentSky();
+ LLEnvironment& environment = LLEnvironment::instance();
+ LLSettingsWater::ptr_t pwater = environment.getCurrentWater();
+ LLSettingsSky::ptr_t psky = environment.getCurrentSky();
LLVector3 light_dir = environment.getLightDirection();
bool sun_up = environment.getIsSunUp();
bool moon_up = environment.getIsMoonUp();
@@ -535,15 +535,15 @@ void LLDrawPoolWater::renderWater()
F32 ground_proj_sq = light_dir.mV[0] * light_dir.mV[0] + light_dir.mV[1] * light_dir.mV[1];
light_exp = llmax(32.f, 256.f * powf(ground_proj_sq, 16.0f));
if (0.f < light_diffuse.normalize()) // Normalizing a color? Puzzling...
- {
+ {
light_diffuse *= (1.5f + (6.f * ground_proj_sq));
}
// set up normal maps filtering
for (auto norm_map : mWaterNormp)
- {
+ {
if (norm_map) norm_map->setFilteringOption(has_normal_mips ? LLTexUnit::TFO_ANISOTROPIC : LLTexUnit::TFO_POINT);
- }
+ }
LLColor4 specular(sun_up ? psky->getSunlightColor() : psky->getMoonlightColor());
F32 phase_time = (F32) LLFrameTimer::getElapsedSeconds() * 0.5f;
@@ -570,51 +570,51 @@ void LLDrawPoolWater::renderWater()
}
gPipeline.bindDeferredShader(*shader);
-
+
// bind textures for water rendering
- S32 reftex = shader->enableTexture(LLShaderMgr::WATER_REFTEX);
- if (reftex > -1)
- {
- gGL.getTexUnit(reftex)->activate();
- gGL.getTexUnit(reftex)->bind(&gPipeline.mWaterRef);
- gGL.getTexUnit(0)->activate();
- }
+ S32 reftex = shader->enableTexture(LLShaderMgr::WATER_REFTEX);
+ if (reftex > -1)
+ {
+ gGL.getTexUnit(reftex)->activate();
+ gGL.getTexUnit(reftex)->bind(&gPipeline.mWaterRef);
+ gGL.getTexUnit(0)->activate();
+ }
- // bind normal map
- S32 bumpTex = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP);
- S32 bumpTex2 = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP2);
+ //bind normal map
+ S32 bumpTex = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP);
+ S32 bumpTex2 = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP2);
- LLViewerTexture *tex_a = mWaterNormp[0];
- LLViewerTexture *tex_b = mWaterNormp[1];
+ LLViewerTexture* tex_a = mWaterNormp[0];
+ LLViewerTexture* tex_b = mWaterNormp[1];
F32 blend_factor = pwater->getBlendFactor();
+
+ gGL.getTexUnit(bumpTex)->unbind(LLTexUnit::TT_TEXTURE);
+ gGL.getTexUnit(bumpTex2)->unbind(LLTexUnit::TT_TEXTURE);
- gGL.getTexUnit(bumpTex)->unbind(LLTexUnit::TT_TEXTURE);
- gGL.getTexUnit(bumpTex2)->unbind(LLTexUnit::TT_TEXTURE);
-
- if (tex_a && (!tex_b || (tex_a == tex_b)))
- {
- gGL.getTexUnit(bumpTex)->bind(tex_a);
- blend_factor = 0; // only one tex provided, no blending
- }
- else if (tex_b && !tex_a)
- {
- gGL.getTexUnit(bumpTex)->bind(tex_b);
- blend_factor = 0; // only one tex provided, no blending
- }
- else if (tex_b != tex_a)
- {
- gGL.getTexUnit(bumpTex)->bind(tex_a);
- gGL.getTexUnit(bumpTex2)->bind(tex_b);
- }
-
- // bind reflection texture from RenderTarget
- S32 screentex = shader->enableTexture(LLShaderMgr::WATER_SCREENTEX);
+ if (tex_a && (!tex_b || (tex_a == tex_b)))
+ {
+ gGL.getTexUnit(bumpTex)->bind(tex_a);
+ blend_factor = 0; // only one tex provided, no blending
+ }
+ else if (tex_b && !tex_a)
+ {
+ gGL.getTexUnit(bumpTex)->bind(tex_b);
+ blend_factor = 0; // only one tex provided, no blending
+ }
+ else if (tex_b != tex_a)
+ {
+ gGL.getTexUnit(bumpTex)->bind(tex_a);
+ gGL.getTexUnit(bumpTex2)->bind(tex_b);
+ }
+
+ // bind reflection texture from RenderTarget
+ S32 screentex = shader->enableTexture(LLShaderMgr::WATER_SCREENTEX);
S32 screenDepth = shader->enableTexture(LLShaderMgr::WATER_SCREENDEPTH);
F32 screenRes[] = {1.f / gGLViewport[2], 1.f / gGLViewport[3]};
-
- S32 diffTex = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP);
+
+ S32 diffTex = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP);
// set uniforms for shader
if (deferred_render)
@@ -626,26 +626,26 @@ void LLDrawPoolWater::renderWater()
}
}
- shader->uniform2fv(LLShaderMgr::DEFERRED_SCREEN_RES, 1, screenRes);
- shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor);
+ shader->uniform2fv(LLShaderMgr::DEFERRED_SCREEN_RES, 1, screenRes);
+ shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor);
- F32 fog_density = pwater->getModifiedWaterFogDensity(underwater);
-
- if (screentex > -1)
- {
- shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, fog_density);
- gGL.getTexUnit(screentex)->bind(&gPipeline.mWaterDis);
- }
+ F32 fog_density = pwater->getModifiedWaterFogDensity(underwater);
+ if (screentex > -1)
+ {
+ shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, fog_density);
+ gGL.getTexUnit(screentex)->bind(&gPipeline.mWaterDis);
+ }
+
if (screenDepth > -1)
{
gGL.getTexUnit(screenDepth)->bind(&gPipeline.mWaterDis, true);
}
- if (mShaderLevel == 1)
- {
- fog_color.mV[VW] = log(fog_density) / log(2);
- }
+ if (mShaderLevel == 1)
+ {
+ fog_color.mV[VW] = log(fog_density) / log(2);
+ }
F32 water_height = environment.getWaterHeight();
F32 camera_height = LLViewerCamera::getInstance()->getOrigin().mV[2];
@@ -654,45 +654,48 @@ void LLDrawPoolWater::renderWater()
shader->uniform3fv(LLShaderMgr::WATER_EYEVEC, 1, LLViewerCamera::getInstance()->getOrigin().mV);
shader->uniform4fv(LLShaderMgr::SPECULAR_COLOR, 1, specular.mV);
- shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, fog_color.mV);
+ shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, fog_color.mV);
shader->uniform3fv(LLShaderMgr::WATER_FOGCOLOR_LINEAR, 1, fog_color_linear.mV);
- shader->uniform3fv(LLShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV);
- shader->uniform1f(LLShaderMgr::WATER_SPECULAR_EXP, light_exp);
+ shader->uniform3fv(LLShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV);
+ shader->uniform1f(LLShaderMgr::WATER_SPECULAR_EXP, light_exp);
- shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR1, 1, pwater->getWave1Dir().mV);
- shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR2, 1, pwater->getWave2Dir().mV);
+ shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR1, 1, pwater->getWave1Dir().mV);
+ shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR2, 1, pwater->getWave2Dir().mV);
- shader->uniform3fv(LLShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV);
+ shader->uniform3fv(LLShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV);
- shader->uniform3fv(LLShaderMgr::WATER_NORM_SCALE, 1, pwater->getNormalScale().mV);
- shader->uniform1f(LLShaderMgr::WATER_FRESNEL_SCALE, pwater->getFresnelScale());
- shader->uniform1f(LLShaderMgr::WATER_FRESNEL_OFFSET, pwater->getFresnelOffset());
- shader->uniform1f(LLShaderMgr::WATER_BLUR_MULTIPLIER, pwater->getBlurMultiplier());
+ shader->uniform3fv(LLShaderMgr::WATER_NORM_SCALE, 1, pwater->getNormalScale().mV);
+ shader->uniform1f(LLShaderMgr::WATER_FRESNEL_SCALE, pwater->getFresnelScale());
+ shader->uniform1f(LLShaderMgr::WATER_FRESNEL_OFFSET, pwater->getFresnelOffset());
+ shader->uniform1f(LLShaderMgr::WATER_BLUR_MULTIPLIER, pwater->getBlurMultiplier());
- F32 sunAngle = llmax(0.f, light_dir.mV[1]);
- F32 scaledAngle = 1.f - sunAngle;
+ F32 sunAngle = llmax(0.f, light_dir.mV[1]);
+ F32 scaledAngle = 1.f - sunAngle;
shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_up ? 1 : 0);
- shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE, sunAngle);
- shader->uniform1f(LLShaderMgr::WATER_SCALED_ANGLE, scaledAngle);
- shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE2, 0.1f + 0.2f * sunAngle);
- shader->uniform1i(LLShaderMgr::WATER_EDGE_FACTOR, edge ? 1 : 0);
+ shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE, sunAngle);
+ shader->uniform1f(LLShaderMgr::WATER_SCALED_ANGLE, scaledAngle);
+ shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE2, 0.1f + 0.2f*sunAngle);
+ shader->uniform1i(LLShaderMgr::WATER_EDGE_FACTOR, edge ? 1 : 0);
- LLVector4 rotated_light_direction = LLEnvironment::instance().getRotatedLightNorm();
- shader->uniform3fv(LLViewerShaderMgr::LIGHTNORM, 1, rotated_light_direction.mV);
- shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV);
+ // SL-15861 This was changed from getRotatedLightNorm() as it was causing
+ // lightnorm in shaders\class1\windlight\atmosphericsFuncs.glsl in have inconsistent additive lighting for 180 degrees of the FOV.
+ LLVector4 rotated_light_direction = LLEnvironment::instance().getClampedLightNorm();
+ shader->uniform3fv(LLViewerShaderMgr::LIGHTNORM, 1, rotated_light_direction.mV);
- if (LLViewerCamera::getInstance()->cameraUnderWater())
- {
- shader->uniform1f(LLShaderMgr::WATER_REFSCALE, pwater->getScaleBelow());
- }
- else
- {
- shader->uniform1f(LLShaderMgr::WATER_REFSCALE, pwater->getScaleAbove());
- }
+ shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV);
- LLGLDisable cullface(GL_CULL_FACE);
+ if (LLViewerCamera::getInstance()->cameraUnderWater())
+ {
+ shader->uniform1f(LLShaderMgr::WATER_REFSCALE, pwater->getScaleBelow());
+ }
+ else
+ {
+ shader->uniform1f(LLShaderMgr::WATER_REFSCALE, pwater->getScaleAbove());
+ }
+
+ LLGLDisable cullface(GL_CULL_FACE);
LLVOWater *water = nullptr;
for (LLFace *const &face : mDrawFace)
@@ -701,41 +704,41 @@ void LLDrawPoolWater::renderWater()
water = static_cast<LLVOWater *>(face->getViewerObject());
if (!water) continue;
- gGL.getTexUnit(diffTex)->bind(face->getTexture());
+ gGL.getTexUnit(diffTex)->bind(face->getTexture());
if ((bool)edge == (bool) water->getIsEdgePatch())
- {
- face->renderIndexed();
+ {
+ face->renderIndexed();
// Note non-void water being drawn, updates required
if (!edge) // SL-16461 remove !LLPipeline::sUseOcclusion check
- {
- sNeedsReflectionUpdate = TRUE;
- sNeedsDistortionUpdate = TRUE;
+ {
+ sNeedsReflectionUpdate = TRUE;
+ sNeedsDistortionUpdate = TRUE;
}
- }
+ }
}
- shader->disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP);
- shader->disableTexture(LLShaderMgr::WATER_SCREENTEX);
- shader->disableTexture(LLShaderMgr::BUMP_MAP);
- shader->disableTexture(LLShaderMgr::DIFFUSE_MAP);
- shader->disableTexture(LLShaderMgr::WATER_REFTEX);
- shader->disableTexture(LLShaderMgr::WATER_SCREENDEPTH);
+ shader->disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP);
+ shader->disableTexture(LLShaderMgr::WATER_SCREENTEX);
+ shader->disableTexture(LLShaderMgr::BUMP_MAP);
+ shader->disableTexture(LLShaderMgr::DIFFUSE_MAP);
+ shader->disableTexture(LLShaderMgr::WATER_REFTEX);
+ shader->disableTexture(LLShaderMgr::WATER_SCREENDEPTH);
// clean up
gPipeline.unbindDeferredShader(*shader);
gGL.getTexUnit(bumpTex)->unbind(LLTexUnit::TT_TEXTURE);
gGL.getTexUnit(bumpTex2)->unbind(LLTexUnit::TT_TEXTURE);
- }
+ }
- gGL.getTexUnit(0)->activate();
- gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
- if (!deferred_render)
- {
- gGL.setColorMask(true, false);
- }
+ gGL.getTexUnit(0)->activate();
+ gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
+ if (!deferred_render)
+ {
+ gGL.setColorMask(true, false);
+ }
}
LLViewerTexture *LLDrawPoolWater::getDebugTexture()
diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp
index 6678e244b9..4bd7536964 100644
--- a/indra/newview/lldrawpoolwlsky.cpp
+++ b/indra/newview/lldrawpoolwlsky.cpp
@@ -266,15 +266,15 @@ void LLDrawPoolWLSky::renderStars(const LLVector3& camPosLocal) const
gGL.pushMatrix();
gGL.translatef(camPosLocal.mV[0], camPosLocal.mV[1], camPosLocal.mV[2]);
gGL.rotatef(gFrameTimeSeconds*0.01f, 0.f, 0.f, 1.f);
- gCustomAlphaProgram.bind();
- gCustomAlphaProgram.uniform1f(sCustomAlpha, star_alpha.mV[3]);
+ gStarsProgram.bind();
+ gStarsProgram.uniform1f(sCustomAlpha, star_alpha.mV[3]);
gSky.mVOWLSkyp->drawStars();
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
gGL.popMatrix();
- gCustomAlphaProgram.unbind();
-}
+ gStarsProgram.unbind(); // SL-14113 was gCustomAlphaProgram
+ }
void LLDrawPoolWLSky::renderStarsDeferred(const LLVector3& camPosLocal) const
{
@@ -319,6 +319,7 @@ void LLDrawPoolWLSky::renderStarsDeferred(const LLVector3& camPosLocal) const
gGL.pushMatrix();
gGL.translatef(camPosLocal.mV[0], camPosLocal.mV[1], camPosLocal.mV[2]);
+ gGL.rotatef(gFrameTimeSeconds*0.01f, 0.f, 0.f, 1.f);
gDeferredStarProgram.uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor);
if (LLPipeline::sReflectionRender)
@@ -453,7 +454,8 @@ void LLDrawPoolWLSky::renderHeavenlyBodies()
{
if (!gSky.mVOSkyp) return;
- LLGLSPipelineBlendSkyBox gls_skybox(true, false);
+ //LLGLSPipelineBlendSkyBox gls_skybox(true, false);
+ LLGLSPipelineBlendSkyBox gls_skybox(true, true); // SL-14113 we need moon to write to depth to clip stars behind
LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
gGL.pushMatrix();
@@ -583,8 +585,8 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass)
if (gPipeline.canUseWindLightShaders())
{
renderSkyHazeDeferred(origin, camHeightLocal);
- renderStarsDeferred(origin);
renderHeavenlyBodies();
+ renderStarsDeferred(origin);
renderSkyCloudsDeferred(origin, camHeightLocal, cloud_shader);
}
gGL.setColorMask(true, true);
@@ -602,8 +604,8 @@ void LLDrawPoolWLSky::render(S32 pass)
LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
renderSkyHaze(origin, camHeightLocal);
+ renderHeavenlyBodies();
renderStars(origin);
- renderHeavenlyBodies();
renderSkyClouds(origin, camHeightLocal, cloud_shader);
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 6557bcb81d..878022a2c8 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -342,34 +342,6 @@ void LLFace::dirtyTexture()
gPipeline.markTextured(drawablep);
}
-void LLFace::notifyAboutCreatingTexture(LLViewerTexture *texture)
-{
- LLDrawable* drawablep = getDrawable();
- if(mVObjp.notNull() && mVObjp->getVolume())
- {
- LLVOVolume *vobj = drawablep->getVOVolume();
- if(vobj && vobj->notifyAboutCreatingTexture(texture))
- {
- gPipeline.markTextured(drawablep);
- gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_VOLUME);
- }
- }
-}
-
-void LLFace::notifyAboutMissingAsset(LLViewerTexture *texture)
-{
- LLDrawable* drawablep = getDrawable();
- if(mVObjp.notNull() && mVObjp->getVolume())
- {
- LLVOVolume *vobj = drawablep->getVOVolume();
- if(vobj && vobj->notifyAboutMissingAsset(texture))
- {
- gPipeline.markTextured(drawablep);
- gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_VOLUME);
- }
- }
-}
-
void LLFace::switchTexture(U32 ch, LLViewerTexture* new_texture)
{
llassert(ch < LLRender::NUM_TEXTURE_CHANNELS);
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index a5ea460061..0cb986b8ed 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -228,9 +228,6 @@ public:
LLVertexBuffer* getVertexBuffer() const { return mVertexBuffer; }
S32 getRiggedIndex(U32 type) const;
- void notifyAboutCreatingTexture(LLViewerTexture *texture);
- void notifyAboutMissingAsset(LLViewerTexture *texture);
-
// used to preserve draw order of faces that are batched together.
// Allows content creators to manipulate linked sets and face ordering
// for consistent alpha sorting results, particularly for rigged attachments
diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp
index 45de0b71ae..d04a674e91 100644
--- a/indra/newview/llgltfmateriallist.cpp
+++ b/indra/newview/llgltfmateriallist.cpp
@@ -32,7 +32,6 @@
#include "lldispatcher.h"
#include "llfetchedgltfmaterial.h"
#include "llfilesystem.h"
-#include "llmaterialeditor.h"
#include "llsdserialize.h"
#include "lltinygltfhelper.h"
#include "llviewercontrol.h"
@@ -147,6 +146,11 @@ public:
LLGLTFMaterialOverrideDispatchHandler() = default;
~LLGLTFMaterialOverrideDispatchHandler() override = default;
+ void addCallback(void(*callback)(const LLUUID& object_id, S32 side))
+ {
+ mSelectionCallbacks.push_back(callback);
+ }
+
bool operator()(const LLDispatcher* dispatcher, const std::string& key, const LLUUID& invoice, const sparam_t& strings) override
{
LL_PROFILE_ZONE_SCOPED;
@@ -210,7 +214,15 @@ public:
return true;
}
- static void applyData(const LLGLTFOverrideCacheEntry &object_override)
+ void doSelectionCallbacks(const LLUUID& object_id, S32 side)
+ {
+ for (auto& callback : mSelectionCallbacks)
+ {
+ callback(object_id, side);
+ }
+ }
+
+ void applyData(const LLGLTFOverrideCacheEntry &object_override)
{
// Parse the data
@@ -264,7 +276,7 @@ public:
}
return results;
},
- [object_override](std::vector<ReturnData> results) // Callback to main thread
+ [object_override, this](std::vector<ReturnData> results) // Callback to main thread
{
LLViewerObject * obj = gObjectList.findObject(object_override.mObjectId);
@@ -285,32 +297,31 @@ public:
// object not ready to receive override data, queue for later
gGLTFMaterialList.queueOverrideUpdate(object_override.mObjectId, results[i].mSide, results[i].mMaterial);
}
- else if (obj && obj->isAnySelected())
+ else if (obj && obj->getTE(i) && obj->getTE(i)->isSelected())
{
- LLMaterialEditor::updateLive(object_override.mObjectId, results[i].mSide);
+ doSelectionCallbacks(object_override.mObjectId, results[i].mSide);
}
}
else
{
// unblock material editor
- if (obj && obj->isAnySelected())
+ if (obj && obj->getTE(i) && obj->getTE(i)->isSelected())
{
- LLMaterialEditor::updateLive(object_override.mObjectId, results[i].mSide);
+ doSelectionCallbacks(object_override.mObjectId, results[i].mSide);
}
}
}
if (obj && side_set.size() != obj->getNumTEs())
{ // object exists and at least one texture entry needs to have its override data nulled out
- bool object_has_selection = obj->isAnySelected();
for (int i = 0; i < obj->getNumTEs(); ++i)
{
if (side_set.find(i) == side_set.end())
{
obj->setTEGLTFMaterialOverride(i, nullptr);
- if (object_has_selection)
+ if (obj->getTE(i) && obj->getTE(i)->isSelected())
{
- LLMaterialEditor::updateLive(object_override.mObjectId, i);
+ doSelectionCallbacks(object_override.mObjectId, i);
}
}
}
@@ -318,18 +329,21 @@ public:
}
else if (obj)
{ // override list was empty or an error occurred, null out all overrides for this object
- bool object_has_selection = obj->isAnySelected();
for (int i = 0; i < obj->getNumTEs(); ++i)
{
obj->setTEGLTFMaterialOverride(i, nullptr);
- if (object_has_selection)
+ if (obj->getTE(i) && obj->getTE(i)->isSelected())
{
- LLMaterialEditor::updateLive(obj->getID(), i);
+ doSelectionCallbacks(obj->getID(), i);
}
}
}
});
}
+
+private:
+
+ std::vector<void(*)(const LLUUID& object_id, S32 side)> mSelectionCallbacks;
};
namespace
@@ -357,20 +371,19 @@ void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj)
if (iter != mQueuedOverrides.end())
{
- bool object_has_selection = obj->isAnySelected();
override_list_t& overrides = iter->second;
for (int i = 0; i < overrides.size(); ++i)
{
if (overrides[i].notNull())
{
- if (!obj->getTE(i)->getGLTFMaterial())
+ if (!obj->getTE(i) || !obj->getTE(i)->getGLTFMaterial())
{ // object doesn't have its base GLTF material yet, don't apply override (yet)
return;
}
obj->setTEGLTFMaterialOverride(i, overrides[i]);
- if (object_has_selection)
+ if (obj->getTE(i)->isSelected())
{
- LLMaterialEditor::updateLive(id, i);
+ handle_gltf_override_message.doSelectionCallbacks(id, i);
}
}
}
@@ -459,6 +472,11 @@ void LLGLTFMaterialList::flushUpdates(void(*done_callback)(bool))
}
}
+void LLGLTFMaterialList::addSelectionUpdateCallback(void(*update_callback)(const LLUUID& object_id, S32 side))
+{
+ handle_gltf_override_message.addCallback(update_callback);
+}
+
class AssetLoadUserData
{
public:
@@ -713,5 +731,5 @@ void LLGLTFMaterialList::modifyMaterialCoro(std::string cap_url, LLSD overrides,
void LLGLTFMaterialList::loadCacheOverrides(const LLGLTFOverrideCacheEntry& override)
{
- LLGLTFMaterialOverrideDispatchHandler::applyData(override);
+ handle_gltf_override_message.applyData(override);
}
diff --git a/indra/newview/llgltfmateriallist.h b/indra/newview/llgltfmateriallist.h
index 0f0edf7414..abbb755599 100644
--- a/indra/newview/llgltfmateriallist.h
+++ b/indra/newview/llgltfmateriallist.h
@@ -74,6 +74,8 @@ public:
// Automatically called once per frame, but may be called explicitly
// for cases that care about the done_callback forwarded to LLCoros::instance().launch
static void flushUpdates(void(*done_callback)(bool) = nullptr);
+
+ static void addSelectionUpdateCallback(void(*update_callback)(const LLUUID& object_id, S32 side));
// Queue an explicit LLSD ModifyMaterialParams update apply given override data
// overrides -- LLSD map (or array of maps) in the format:
diff --git a/indra/newview/lllocalgltfmaterials.cpp b/indra/newview/lllocalgltfmaterials.cpp
index b07efff827..89f14c6cfa 100644
--- a/indra/newview/lllocalgltfmaterials.cpp
+++ b/indra/newview/lllocalgltfmaterials.cpp
@@ -93,27 +93,27 @@ LLLocalGLTFMaterial::~LLLocalGLTFMaterial()
}
/* accessors */
-std::string LLLocalGLTFMaterial::getFilename()
+std::string LLLocalGLTFMaterial::getFilename() const
{
return mFilename;
}
-std::string LLLocalGLTFMaterial::getShortName()
+std::string LLLocalGLTFMaterial::getShortName() const
{
return mShortName;
}
-LLUUID LLLocalGLTFMaterial::getTrackingID()
+LLUUID LLLocalGLTFMaterial::getTrackingID() const
{
return mTrackingID;
}
-LLUUID LLLocalGLTFMaterial::getWorldID()
+LLUUID LLLocalGLTFMaterial::getWorldID() const
{
return mWorldID;
}
-S32 LLLocalGLTFMaterial::getIndexInFile()
+S32 LLLocalGLTFMaterial::getIndexInFile() const
{
return mMaterialIndex;
}
diff --git a/indra/newview/lllocalgltfmaterials.h b/indra/newview/lllocalgltfmaterials.h
index 3bdccbbf3d..6919b9b4b2 100644
--- a/indra/newview/lllocalgltfmaterials.h
+++ b/indra/newview/lllocalgltfmaterials.h
@@ -42,11 +42,11 @@ public: /* main */
virtual ~LLLocalGLTFMaterial();
public: /* accessors */
- std::string getFilename();
- std::string getShortName();
- LLUUID getTrackingID();
- LLUUID getWorldID();
- S32 getIndexInFile();
+ std::string getFilename() const;
+ std::string getShortName() const;
+ LLUUID getTrackingID() const;
+ LLUUID getWorldID() const;
+ S32 getIndexInFile() const;
public:
bool updateSelf();
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index d5339777c4..07c283e9c2 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -46,6 +46,7 @@
#include "llsdutil.h"
#include "llselectmgr.h"
#include "llstatusbar.h" // can_afford_transaction()
+#include "lltoolpie.h"
#include "llviewerinventory.h"
#include "llinventory.h"
#include "llviewerregion.h"
@@ -322,9 +323,17 @@ bool LLSelectedTEGetMatData::apply(LLViewerObject* objectp, S32 te_index)
mLocalMaterial = local_mat;
}
mMaterial = tep->getGLTFRenderMaterial();
+
+ if (mMaterial.isNull())
+ {
+ // Shouldn't be possible?
+ LL_WARNS("MaterialEditor") << "Object has material id, but no material" << LL_ENDL;
+ mMaterial = gGLTFMaterialList.getMaterial(mat_id);
+ }
}
+ return true;
}
- return true;
+ return false;
}
///----------------------------------------------------------------------------
@@ -399,6 +408,9 @@ BOOL LLMaterialEditor::postBuild()
if (mIsOverride)
{
+ // Material override change success callback
+ LLGLTFMaterialList::addSelectionUpdateCallback(&LLMaterialEditor::updateLive);
+
// Live editing needs a recovery mechanism on cancel
mBaseColorTextureCtrl->setOnCancelCallback(boost::bind(&LLMaterialEditor::onCancelCtrl, this, _1, _2, MATERIAL_BASE_COLOR_TEX_DIRTY));
mMetallicTextureCtrl->setOnCancelCallback(boost::bind(&LLMaterialEditor::onCancelCtrl, this, _1, _2, MATERIAL_METALLIC_ROUGHTNESS_TEX_DIRTY));
@@ -1816,58 +1828,95 @@ void LLMaterialEditor::loadLive()
void LLMaterialEditor::saveObjectsMaterialAs()
{
-
- // Find an applicable material.
- // Do this before showing message, because
- // message is going to drop selection.
LLSelectedTEGetMatData func(false);
LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func, true /*first applicable*/);
+ saveMaterialAs(func.mMaterial, func.mLocalMaterial);
+}
+void LLMaterialEditor::savePickedMaterialAs()
+{
+ LLPickInfo pick = LLToolPie::getInstance()->getPick();
+ if (pick.mPickType != LLPickInfo::PICK_OBJECT || !pick.getObject())
+ {
+ return;
+ }
+
+ LLPointer<LLGLTFMaterial> render_material;
+ LLPointer<LLLocalGLTFMaterial> local_material;
- if (func.mLocalMaterial.notNull())
+ LLViewerObject *objectp = pick.getObject();
+ LLUUID mat_id = objectp->getRenderMaterialID(pick.mObjectFace);
+ if (mat_id.notNull() && objectp->permCopy())
+ {
+ // Try a face user picked first
+ // (likely the only method we need, but in such case
+ // enable_object_save_gltf_material will need to check this)
+ LLTextureEntry *tep = objectp->getTE(pick.mObjectFace);
+ LLGLTFMaterial *mat = tep->getGLTFMaterial();
+ LLLocalGLTFMaterial *local_mat = dynamic_cast<LLLocalGLTFMaterial*>(mat);
+
+ if (local_mat)
+ {
+ local_material = local_mat;
+ }
+ render_material = tep->getGLTFRenderMaterial();
+ }
+ else
+ {
+ // Find an applicable material.
+ // Do this before showing message, because
+ // message is going to drop selection.
+ LLSelectedTEGetMatData func(false);
+ LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func, true /*first applicable*/);
+ local_material = func.mLocalMaterial;
+ render_material = func.mMaterial;
+ }
+
+ saveMaterialAs(render_material, local_material);
+}
+
+void LLMaterialEditor::saveMaterialAs(const LLGLTFMaterial* render_material, const LLLocalGLTFMaterial *local_material)
+{
+ if (local_material)
{
// This is a local material, reload it from file
// so that user won't end up with grey textures
// on next login.
- LLMaterialEditor::loadMaterialFromFile(func.mLocalMaterial->getFilename(), func.mLocalMaterial->getIndexInFile());
+ LLMaterialEditor::loadMaterialFromFile(local_material->getFilename(), local_material->getIndexInFile());
LLMaterialEditor* me = (LLMaterialEditor*)LLFloaterReg::getInstance("material_editor");
if (me)
{
- // apply differences on top
- LLGLTFMaterial* local_mat = func.mLocalMaterial.get();
- // don't use override mat here, it has 'hacked ids'
- // and values, use end result.
- LLGLTFMaterial* cmp_mat = func.mMaterial.get();
-
- me->setBaseColor(cmp_mat->mBaseColor);
- me->setMetalnessFactor(cmp_mat->mMetallicFactor);
- me->setRoughnessFactor(cmp_mat->mRoughnessFactor);
- me->setEmissiveColor(cmp_mat->mEmissiveColor);
- me->setDoubleSided(cmp_mat->mDoubleSided);
- me->setAlphaMode(cmp_mat->getAlphaMode());
- me->setAlphaCutoff(cmp_mat->mAlphaCutoff);
+ // don't use override material here, it has 'hacked ids'
+ // and values, use end result, apply it on top of local.
+ me->setBaseColor(render_material->mBaseColor);
+ me->setMetalnessFactor(render_material->mMetallicFactor);
+ me->setRoughnessFactor(render_material->mRoughnessFactor);
+ me->setEmissiveColor(render_material->mEmissiveColor);
+ me->setDoubleSided(render_material->mDoubleSided);
+ me->setAlphaMode(render_material->getAlphaMode());
+ me->setAlphaCutoff(render_material->mAlphaCutoff);
// most things like colors we can apply without verifying
// but texture ids are going to be different from both, base and override
// so only apply override id if there is actually a difference
- if (local_mat->mBaseColorId != cmp_mat->mBaseColorId)
+ if (local_material->mBaseColorId != render_material->mBaseColorId)
{
- me->setBaseColorId(cmp_mat->mBaseColorId);
+ me->setBaseColorId(render_material->mBaseColorId);
me->childSetValue("base_color_upload_fee", me->getString("no_upload_fee_string"));
}
- if (local_mat->mNormalId != cmp_mat->mNormalId)
+ if (local_material->mNormalId != render_material->mNormalId)
{
- me->setNormalId(cmp_mat->mNormalId);
+ me->setNormalId(render_material->mNormalId);
me->childSetValue("normal_upload_fee", me->getString("no_upload_fee_string"));
}
- if (local_mat->mMetallicRoughnessId != cmp_mat->mMetallicRoughnessId)
+ if (local_material->mMetallicRoughnessId != render_material->mMetallicRoughnessId)
{
- me->setMetallicRoughnessId(cmp_mat->mMetallicRoughnessId);
+ me->setMetallicRoughnessId(render_material->mMetallicRoughnessId);
me->childSetValue("metallic_upload_fee", me->getString("no_upload_fee_string"));
}
- if (local_mat->mEmissiveId != cmp_mat->mEmissiveId)
+ if (local_material->mEmissiveId != render_material->mEmissiveId)
{
- me->setEmissiveId(cmp_mat->mEmissiveId);
+ me->setEmissiveId(render_material->mEmissiveId);
me->childSetValue("emissive_upload_fee", me->getString("no_upload_fee_string"));
}
@@ -1879,9 +1928,9 @@ void LLMaterialEditor::saveObjectsMaterialAs()
}
LLSD payload;
- if (func.mMaterial.notNull())
+ if (render_material)
{
- payload["data"] = func.mMaterial->asJSON();
+ payload["data"] = render_material->asJSON();
}
else
{
diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h
index 23d5434ff7..6deda5df50 100644
--- a/indra/newview/llmaterialeditor.h
+++ b/indra/newview/llmaterialeditor.h
@@ -35,6 +35,7 @@ class LLButton;
class LLColorSwatchCtrl;
class LLComboBox;
class LLGLTFMaterial;
+class LLLocalGLTFMaterial;
class LLTextureCtrl;
class LLTextBox;
@@ -111,6 +112,7 @@ public:
static void loadLive();
static void saveObjectsMaterialAs();
+ static void savePickedMaterialAs();
static void onSaveObjectsMaterialAsMsgCallback(const LLSD& notification, const LLSD& response);
static void loadFromGLTFMaterial(LLUUID &asset_id);
@@ -232,6 +234,8 @@ public:
static bool capabilitiesAvailable();
private:
+ static void saveMaterialAs(const LLGLTFMaterial *render_material, const LLLocalGLTFMaterial *local_material);
+
static bool updateInventoryItem(const std::string &buffer, const LLUUID &item_id, const LLUUID &task_id);
static void createInventoryItem(const std::string &buffer, const std::string &name, const std::string &desc);
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 84b1ff63f4..3d72865f69 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -32,7 +32,6 @@
// library includes
#include "llcalc.h"
#include "llerror.h"
-#include "llfocusmgr.h"
#include "llrect.h"
#include "llstring.h"
#include "llfontgl.h"
@@ -95,6 +94,8 @@
using namespace std::literals;
+LLPanelFace::Selection LLPanelFace::sMaterialOverrideSelection;
+
//
// Constant definitions for comboboxes
// Must match the commbobox definitions in panel_tools_texture.xml
@@ -136,7 +137,7 @@ LLGLTFMaterial::TextureInfo texture_info_from_pbrtype(S32 pbr_type)
}
}
-void updateSelectedGLTFMaterials(std::function<void(LLGLTFMaterial*)> func)
+void LLPanelFace::updateSelectedGLTFMaterials(std::function<void(LLGLTFMaterial*)> func)
{
struct LLSelectedTEGLTFMaterialFunctor : public LLSelectedTEFunctor
{
@@ -158,6 +159,7 @@ void updateSelectedGLTFMaterials(std::function<void(LLGLTFMaterial*)> func)
std::function<void(LLGLTFMaterial*)> mFunc;
} select_func(func);
+
LLSelectMgr::getInstance()->getSelection()->applyToTEs(&select_func);
}
@@ -268,11 +270,14 @@ BOOL LLPanelFace::postBuild()
childSetCommitCallback("add_media", &LLPanelFace::onClickBtnAddMedia, this);
childSetCommitCallback("delete_media", &LLPanelFace::onClickBtnDeleteMedia, this);
- childSetCommitCallback("gltfTextureScaleU", boost::bind(&LLPanelFace::onCommitGLTFTextureScaleU, this, _1), nullptr);
- childSetCommitCallback("gltfTextureScaleV", boost::bind(&LLPanelFace::onCommitGLTFTextureScaleV, this, _1), nullptr);
- childSetCommitCallback("gltfTextureRotation", boost::bind(&LLPanelFace::onCommitGLTFRotation, this, _1), nullptr);
- childSetCommitCallback("gltfTextureOffsetU", boost::bind(&LLPanelFace::onCommitGLTFTextureOffsetU, this, _1), nullptr);
- childSetCommitCallback("gltfTextureOffsetV", boost::bind(&LLPanelFace::onCommitGLTFTextureOffsetV, this, _1), nullptr);
+ getChild<LLUICtrl>("gltfTextureScaleU")->setCommitCallback(boost::bind(&LLPanelFace::onCommitGLTFTextureScaleU, this, _1), nullptr);
+ getChild<LLUICtrl>("gltfTextureScaleV")->setCommitCallback(boost::bind(&LLPanelFace::onCommitGLTFTextureScaleV, this, _1), nullptr);
+ getChild<LLUICtrl>("gltfTextureRotation")->setCommitCallback(boost::bind(&LLPanelFace::onCommitGLTFRotation, this, _1), nullptr);
+ getChild<LLUICtrl>("gltfTextureOffsetU")->setCommitCallback(boost::bind(&LLPanelFace::onCommitGLTFTextureOffsetU, this, _1), nullptr);
+ getChild<LLUICtrl>("gltfTextureOffsetV")->setCommitCallback(boost::bind(&LLPanelFace::onCommitGLTFTextureOffsetV, this, _1), nullptr);
+
+ LLGLTFMaterialList::addSelectionUpdateCallback(&LLPanelFace::onMaterialOverrideReceived);
+ sMaterialOverrideSelection.connect();
childSetAction("button align",&LLPanelFace::onClickAutoFix,this);
childSetAction("button align textures", &LLPanelFace::onAlignTexture, this);
@@ -486,6 +491,11 @@ void LLPanelFace::draw()
updateMediaTitle();
LLPanel::draw();
+
+ if (sMaterialOverrideSelection.update())
+ {
+ setMaterialOverridesFromSelection();
+ }
}
void LLPanelFace::sendTexture()
@@ -1773,7 +1783,7 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material,
{
has_pbr_material = false;
- BOOL editable = objectp->permModify() && !objectp->isPermanentEnforced();
+ const bool editable = objectp->permModify() && !objectp->isPermanentEnforced();
bool has_pbr_capabilities = LLMaterialEditor::capabilitiesAvailable();
// pbr material
@@ -1784,10 +1794,11 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material,
bool identical_pbr;
LLSelectedTE::getPbrMaterialId(pbr_id, identical_pbr);
+ has_pbr_material = pbr_id.notNull();
+
pbr_ctrl->setTentative(identical_pbr ? FALSE : TRUE);
pbr_ctrl->setEnabled(editable && has_pbr_capabilities);
pbr_ctrl->setImageAssetID(pbr_id);
- has_pbr_material = pbr_id.notNull();
}
getChildView("pbr_from_inventory")->setEnabled(editable && has_pbr_capabilities);
@@ -1797,14 +1808,13 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material,
const bool show_pbr = mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR && mComboMatMedia->getEnabled();
if (show_pbr)
{
-
const U32 pbr_type = findChild<LLRadioGroup>("radio_pbr_type")->getSelectedIndex();
const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(pbr_type);
const bool show_texture_info = texture_info != LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT;
LLUICtrl* gltfCtrlTextureScaleU = getChild<LLUICtrl>("gltfTextureScaleU");
- LLUICtrl* gltfCtrlTextureScaleV = getChild<LLUICtrl>("gltfTextureScaleV");
- LLUICtrl* gltfCtrlTextureRotation = getChild<LLUICtrl>("gltfTextureRotation");
+ LLUICtrl* gltfCtrlTextureScaleV = getChild<LLUICtrl>("gltfTextureScaleV");
+ LLUICtrl* gltfCtrlTextureRotation = getChild<LLUICtrl>("gltfTextureRotation");
LLUICtrl* gltfCtrlTextureOffsetU = getChild<LLUICtrl>("gltfTextureOffsetU");
LLUICtrl* gltfCtrlTextureOffsetV = getChild<LLUICtrl>("gltfTextureOffsetV");
@@ -1814,48 +1824,7 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material,
gltfCtrlTextureOffsetU->setEnabled(show_texture_info && has_pbr_capabilities);
gltfCtrlTextureOffsetV->setEnabled(show_texture_info && has_pbr_capabilities);
- if (show_texture_info)
- {
- LLGLTFMaterial::TextureTransform transform;
- bool scale_u_same = true;
- bool scale_v_same = true;
- bool rotation_same = true;
- bool offset_u_same = true;
- bool offset_v_same = true;
-
- readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat)
- {
- return mat ? mat->mTextureTransform[texture_info].mScale[VX] : 0.f;
- }, transform.mScale[VX], scale_u_same, true, 1e-3f);
- readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat)
- {
- return mat ? mat->mTextureTransform[texture_info].mScale[VY] : 0.f;
- }, transform.mScale[VY], scale_v_same, true, 1e-3f);
- readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat)
- {
- return mat ? mat->mTextureTransform[texture_info].mRotation : 0.f;
- }, transform.mRotation, rotation_same, true, 1e-3f);
- readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat)
- {
- return mat ? mat->mTextureTransform[texture_info].mOffset[VX] : 0.f;
- }, transform.mOffset[VX], offset_u_same, true, 1e-3f);
- readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat)
- {
- return mat ? mat->mTextureTransform[texture_info].mOffset[VY] : 0.f;
- }, transform.mOffset[VY], offset_v_same, true, 1e-3f);
-
- gltfCtrlTextureScaleU->setValue(transform.mScale[VX]);
- gltfCtrlTextureScaleV->setValue(transform.mScale[VY]);
- gltfCtrlTextureRotation->setValue(transform.mRotation * RAD_TO_DEG);
- gltfCtrlTextureOffsetU->setValue(transform.mOffset[VX]);
- gltfCtrlTextureOffsetV->setValue(transform.mOffset[VY]);
-
- gltfCtrlTextureScaleU->setTentative(!scale_u_same);
- gltfCtrlTextureScaleV->setTentative(!scale_v_same);
- gltfCtrlTextureRotation->setTentative(!rotation_same);
- gltfCtrlTextureOffsetU->setTentative(!offset_u_same);
- gltfCtrlTextureOffsetV->setTentative(!offset_v_same);
- }
+ // Control values are set in setMaterialOverridesFromSelection
}
}
@@ -2084,6 +2053,12 @@ void LLPanelFace::unloadMedia()
mTitleMedia->unloadMediaSource();
}
+// static
+void LLPanelFace::onMaterialOverrideReceived(const LLUUID& object_id, S32 side)
+{
+ sMaterialOverrideSelection.onSelectedObjectUpdated(object_id, side);
+}
+
//////////////////////////////////////////////////////////////////////////////
//
void LLPanelFace::navigateToTitleMedia( const std::string url )
@@ -2828,6 +2803,7 @@ void LLPanelFace::onCommitPbrType(LLUICtrl* ctrl, void* userdata)
// and generally reflecting old state when switching tabs or objects
//
self->updateUI();
+ self->setMaterialOverridesFromSelection();
}
// static
@@ -4677,7 +4653,7 @@ void LLPanelFace::onCommitPlanarAlign(LLUICtrl* ctrl, void* userdata)
self->sendTextureInfo();
}
-void updateGLTFTextureTransform(float value, U32 pbr_type, std::function<void(LLGLTFMaterial::TextureTransform*)> edit)
+void LLPanelFace::updateGLTFTextureTransform(float value, U32 pbr_type, std::function<void(LLGLTFMaterial::TextureTransform*)> edit)
{
U32 texture_info_start;
U32 texture_info_end;
@@ -4699,6 +4675,148 @@ void updateGLTFTextureTransform(float value, U32 pbr_type, std::function<void(LL
edit(&new_transform);
}
});
+
+ LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode();
+ if (node)
+ {
+ LLViewerObject* object = node->getObject();
+ sMaterialOverrideSelection.setObjectUpdatePending(object->getID(), node->getLastSelectedTE());
+ }
+}
+
+void LLPanelFace::setMaterialOverridesFromSelection()
+{
+ const U32 pbr_type = findChild<LLRadioGroup>("radio_pbr_type")->getSelectedIndex();
+ const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(pbr_type);
+ if (texture_info == LLGLTFMaterial::TextureInfo::GLTF_TEXTURE_INFO_COUNT)
+ {
+ return;
+ }
+
+ LLGLTFMaterial::TextureTransform transform;
+ bool scale_u_same = true;
+ bool scale_v_same = true;
+ bool rotation_same = true;
+ bool offset_u_same = true;
+ bool offset_v_same = true;
+
+ readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat)
+ {
+ return mat ? mat->mTextureTransform[texture_info].mScale[VX] : 0.f;
+ }, transform.mScale[VX], scale_u_same, true, 1e-3f);
+ readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat)
+ {
+ return mat ? mat->mTextureTransform[texture_info].mScale[VY] : 0.f;
+ }, transform.mScale[VY], scale_v_same, true, 1e-3f);
+ readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat)
+ {
+ return mat ? mat->mTextureTransform[texture_info].mRotation : 0.f;
+ }, transform.mRotation, rotation_same, true, 1e-3f);
+ readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat)
+ {
+ return mat ? mat->mTextureTransform[texture_info].mOffset[VX] : 0.f;
+ }, transform.mOffset[VX], offset_u_same, true, 1e-3f);
+ readSelectedGLTFMaterial<float>([&](const LLGLTFMaterial* mat)
+ {
+ return mat ? mat->mTextureTransform[texture_info].mOffset[VY] : 0.f;
+ }, transform.mOffset[VY], offset_v_same, true, 1e-3f);
+
+ LLUICtrl* gltfCtrlTextureScaleU = getChild<LLUICtrl>("gltfTextureScaleU");
+ LLUICtrl* gltfCtrlTextureScaleV = getChild<LLUICtrl>("gltfTextureScaleV");
+ LLUICtrl* gltfCtrlTextureRotation = getChild<LLUICtrl>("gltfTextureRotation");
+ LLUICtrl* gltfCtrlTextureOffsetU = getChild<LLUICtrl>("gltfTextureOffsetU");
+ LLUICtrl* gltfCtrlTextureOffsetV = getChild<LLUICtrl>("gltfTextureOffsetV");
+
+ gltfCtrlTextureScaleU->setValue(transform.mScale[VX]);
+ gltfCtrlTextureScaleV->setValue(transform.mScale[VY]);
+ gltfCtrlTextureRotation->setValue(transform.mRotation * RAD_TO_DEG);
+ gltfCtrlTextureOffsetU->setValue(transform.mOffset[VX]);
+ gltfCtrlTextureOffsetV->setValue(transform.mOffset[VY]);
+
+ gltfCtrlTextureScaleU->setTentative(!scale_u_same);
+ gltfCtrlTextureScaleV->setTentative(!scale_v_same);
+ gltfCtrlTextureRotation->setTentative(!rotation_same);
+ gltfCtrlTextureOffsetU->setTentative(!offset_u_same);
+ gltfCtrlTextureOffsetV->setTentative(!offset_v_same);
+}
+
+void LLPanelFace::Selection::connect()
+{
+ if (!mSelectConnection.connected())
+ {
+ mSelectConnection = LLSelectMgr::instance().mUpdateSignal.connect(boost::bind(&LLPanelFace::Selection::onSelectionChanged, this));
+ }
+}
+
+bool LLPanelFace::Selection::update()
+{
+ const bool selection_changed = compareSelection();
+ if (selection_changed)
+ {
+ clearObjectUpdatePending();
+ }
+ else if (isObjectUpdatePending())
+ {
+ return false;
+ }
+
+ const bool changed = mChanged;
+ mChanged = false;
+ return changed;
+}
+
+void LLPanelFace::Selection::setObjectUpdatePending(const LLUUID &object_id, S32 side)
+{
+ mPendingObjectID = object_id;
+ mPendingSide = side;
+}
+
+void LLPanelFace::Selection::onSelectedObjectUpdated(const LLUUID& object_id, S32 side)
+{
+ if (object_id == mSelectedObjectID && side == mSelectedSide)
+ {
+ mChanged = true;
+ clearObjectUpdatePending();
+ }
+}
+
+void LLPanelFace::Selection::clearObjectUpdatePending()
+{
+ mPendingObjectID = LLUUID::null;
+ mPendingSide = -1;
+}
+
+bool LLPanelFace::Selection::compareSelection()
+{
+ if (!mNeedsSelectionCheck)
+ {
+ return false;
+ }
+ mNeedsSelectionCheck = false;
+
+ const S32 old_object_count = mSelectedObjectCount;
+ const LLUUID old_object_id = mSelectedObjectID;
+ const S32 old_side = mSelectedSide;
+
+ LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
+ LLSelectNode* node = selection->getFirstNode();
+ if (node)
+ {
+ LLViewerObject* object = node->getObject();
+ mSelectedObjectCount = selection->getObjectCount();
+ mSelectedObjectID = object->getID();
+ mSelectedSide = node->getLastSelectedTE();
+ }
+ else
+ {
+ mSelectedObjectCount = 0;
+ mSelectedObjectID = LLUUID::null;
+ mSelectedSide = -1;
+ }
+
+ const bool selection_changed = old_object_count != mSelectedObjectCount || old_object_id != mSelectedObjectID || old_side != mSelectedSide;
+ mChanged = mChanged || selection_changed;
+ return selection_changed;
}
void LLPanelFace::onCommitGLTFTextureScaleU(LLUICtrl* ctrl)
diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h
index 69744689b5..c0afc79cbe 100644
--- a/indra/newview/llpanelface.h
+++ b/indra/newview/llpanelface.h
@@ -29,6 +29,7 @@
#include "v4color.h"
#include "llpanel.h"
+#include "llgltfmaterial.h"
#include "llmaterial.h"
#include "llmaterialmgr.h"
#include "lltextureentry.h"
@@ -102,7 +103,7 @@ public:
void refreshMedia();
void unloadMedia();
- static void onGLTFMaterialUpdate(const LLUUID& object_id, S32 side);
+ static void onMaterialOverrideReceived(const LLUUID& object_id, S32 side);
/*virtual*/ void draw();
@@ -176,7 +177,6 @@ protected:
//
// @param force_set_values forces spinners to set value even if they are focused
void updateUI(bool force_set_values = false);
- void updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material, bool force_set_values);
// Convenience func to determine if all faces in selection have
// identical planar texgen settings during edits
@@ -229,11 +229,13 @@ protected:
static void onCommitGlow( LLUICtrl* ctrl, void *userdata);
static void onCommitPlanarAlign( LLUICtrl* ctrl, void* userdata);
static void onCommitRepeatsPerMeter( LLUICtrl* ctrl, void* userinfo);
+
void onCommitGLTFTextureScaleU(LLUICtrl* ctrl);
void onCommitGLTFTextureScaleV(LLUICtrl* ctrl);
void onCommitGLTFRotation(LLUICtrl* ctrl);
void onCommitGLTFTextureOffsetU(LLUICtrl* ctrl);
void onCommitGLTFTextureOffsetV(LLUICtrl* ctrl);
+
static void onClickAutoFix(void*);
static void onAlignTexture(void*);
static void onClickBtnLoadInvPBR(void* userdata);
@@ -291,7 +293,6 @@ private:
// Do NOT call updateUI from within this function.
//
void updateVisibility();
- void updateVisibilityGLTF();
// Hey look everyone, a type-safe alternative to copy and paste! :)
//
@@ -451,29 +452,62 @@ private:
void onTextureSelectionChanged(LLInventoryItem* itemp);
void onPbrSelectionChanged(LLInventoryItem* itemp);
+ void updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material, bool force_set_values);
+ void updateVisibilityGLTF();
+
+ void updateSelectedGLTFMaterials(std::function<void(LLGLTFMaterial*)> func);
+ void updateGLTFTextureTransform(float value, U32 pbr_type, std::function<void(LLGLTFMaterial::TextureTransform*)> edit);
+
+ void setMaterialOverridesFromSelection();
+
LLMenuButton* mMenuClipboardColor;
LLMenuButton* mMenuClipboardTexture;
bool mIsAlpha;
- /* These variables interlock processing of materials updates sent to
- * the sim. mUpdateInFlight is set to flag that an update has been
- * sent to the sim and not acknowledged yet, and cleared when an
- * update is received from the sim. mUpdatePending is set when
- * there's an update in flight and another UI change has been made
- * that needs to be sent as a materials update, and cleared when the
- * update is sent. This prevents the sim from getting spammed with
- * update messages when, for example, the user holds down the
- * up-arrow on a spinner, and avoids running afoul of its throttle.
- */
- bool mUpdateInFlight;
- bool mUpdatePending;
-
LLSD mClipboardParams;
LLSD mMediaSettings;
bool mNeedMediaTitle;
+ class Selection
+ {
+ public:
+ void connect();
+
+ // Returns true if the selected objects or sides have changed since
+ // this was last called, and no object update is pending
+ bool update();
+
+ // Prevents update() returning true until the provided object is
+ // updated. Necessary to prevent controls updating when the mouse is
+ // held down.
+ void setObjectUpdatePending(const LLUUID &object_id, S32 side);
+
+ // Callbacks
+ void onSelectionChanged() { mNeedsSelectionCheck = true; }
+ void onSelectedObjectUpdated(const LLUUID &object_id, S32 side);
+
+ protected:
+ void clearObjectUpdatePending();
+ bool isObjectUpdatePending() { return mPendingSide != -1; }
+
+ bool compareSelection();
+
+ bool mChanged = false;
+
+ boost::signals2::scoped_connection mSelectConnection;
+ bool mNeedsSelectionCheck = true;
+ S32 mSelectedObjectCount = 0;
+ LLUUID mSelectedObjectID;
+ S32 mSelectedSide = -1;
+
+ LLUUID mPendingObjectID;
+ S32 mPendingSide = -1;
+ };
+
+ static Selection sMaterialOverrideSelection;
+
public:
#if defined(DEF_GET_MAT_STATE)
#undef DEF_GET_MAT_STATE
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index c67d76100a..8d0dd505bf 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -2962,7 +2962,7 @@ void handle_object_edit_gltf_material()
void handle_object_save_gltf_material()
{
- LLMaterialEditor::saveObjectsMaterialAs();
+ LLMaterialEditor::savePickedMaterialAs();
}
void handle_attachment_edit(const LLUUID& inv_item_id)
diff --git a/indra/newview/llviewermenu.h b/indra/newview/llviewermenu.h
index 0673652e61..7142763451 100644
--- a/indra/newview/llviewermenu.h
+++ b/indra/newview/llviewermenu.h
@@ -135,7 +135,6 @@ bool anyone_copy_selection(LLSelectNode* nodep);
// *TODO: Move to separate file
bool for_sale_selection(LLSelectNode* nodep);
-void handle_save_snapshot(void *);
void handle_toggle_flycam();
void handle_object_sit_or_stand();
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 9e2d28f29e..ff9f767940 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -74,7 +74,7 @@ LLVector4 gShinyOrigin;
LLGLSLShader gOcclusionProgram;
LLGLSLShader gSkinnedOcclusionProgram;
LLGLSLShader gOcclusionCubeProgram;
-LLGLSLShader gCustomAlphaProgram;
+LLGLSLShader gCustomAlphaProgram; // SL-14113 This used to be used for the stars with Atmospheric Shaders: OFF
LLGLSLShader gGlowCombineProgram;
LLGLSLShader gSplatTextureRectProgram;
LLGLSLShader gReflectionMipProgram;
@@ -143,6 +143,8 @@ LLGLSLShader gObjectAlphaMaskNoColorProgram;
LLGLSLShader gObjectAlphaMaskNoColorWaterProgram;
//environment shaders
+LLGLSLShader gMoonProgram;
+LLGLSLShader gStarsProgram;
LLGLSLShader gTerrainProgram;
LLGLSLShader gTerrainWaterProgram;
LLGLSLShader gWaterProgram;
@@ -753,6 +755,9 @@ void LLViewerShaderMgr::unloadShaders()
gWaterProgram.unload();
gWaterEdgeProgram.unload();
gUnderWaterProgram.unload();
+
+ gMoonProgram.unload();
+ gStarsProgram.unload();
gTerrainProgram.unload();
gTerrainWaterProgram.unload();
gGlowProgram.unload();
@@ -986,6 +991,34 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment()
llassert(success);
}
+ if (success)
+ {
+ gStarsProgram.mName = "Environment Stars Shader";
+ gStarsProgram.mShaderFiles.clear();
+ gStarsProgram.mShaderFiles.push_back(make_pair("environment/starsV.glsl", GL_VERTEX_SHADER_ARB));
+ gStarsProgram.mShaderFiles.push_back(make_pair("environment/starsF.glsl", GL_FRAGMENT_SHADER_ARB));
+ gStarsProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT];
+ gStarsProgram.addConstant( LLGLSLShader::SHADER_CONST_STAR_DEPTH ); // SL-14113
+ success = gStarsProgram.createShader(NULL, NULL);
+ llassert(success);
+ }
+
+ if (success)
+ {
+ gMoonProgram.mName = "Environment Moon Shader";
+ gMoonProgram.mShaderFiles.clear();
+ gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonV.glsl", GL_VERTEX_SHADER_ARB));
+ gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonF.glsl", GL_FRAGMENT_SHADER_ARB));
+ gMoonProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT];
+ gMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113
+ success = gMoonProgram.createShader(NULL, NULL);
+ if (success)
+ {
+ gMoonProgram.bind();
+ gMoonProgram.uniform1i(sTex0, 0);
+ }
+ }
+
if (!success)
{
mShaderLevel[SHADER_ENVIRONMENT] = 0;
@@ -2801,6 +2834,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsF.glsl", GL_FRAGMENT_SHADER));
gDeferredWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
gDeferredWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY;
+ gDeferredWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113
success = gDeferredWLCloudProgram.createShader(NULL, NULL);
llassert(success);
}
@@ -2840,6 +2874,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredWLMoonProgram.mShaderFiles.push_back(make_pair("deferred/moonF.glsl", GL_FRAGMENT_SHADER));
gDeferredWLMoonProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
gDeferredWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY;
+ gDeferredWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113
success = gDeferredWLMoonProgram.createShader(NULL, NULL);
llassert(success);
}
@@ -2852,6 +2887,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredStarProgram.mShaderFiles.push_back(make_pair("deferred/starsF.glsl", GL_FRAGMENT_SHADER));
gDeferredStarProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED];
gDeferredStarProgram.mShaderGroup = LLGLSLShader::SG_SKY;
+ gDeferredStarProgram.addConstant( LLGLSLShader::SHADER_CONST_STAR_DEPTH ); // SL-14113
success = gDeferredStarProgram.createShader(NULL, NULL);
llassert(success);
}
@@ -3901,6 +3937,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight()
gWLCloudProgram.mShaderFiles.push_back(make_pair("windlight/cloudsF.glsl", GL_FRAGMENT_SHADER));
gWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT];
gWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY;
+ gWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113
success = gWLCloudProgram.createShader(NULL, NULL);
}
@@ -3937,6 +3974,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight()
gWLMoonProgram.mShaderFiles.push_back(make_pair("windlight/moonF.glsl", GL_FRAGMENT_SHADER));
gWLMoonProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT];
gWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY;
+ gWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113
success = gWLMoonProgram.createShader(NULL, NULL);
}
#endif
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index 4ed6b02728..e32051f830 100644
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -211,6 +211,8 @@ extern LLGLSLShader gObjectShinyProgram;
extern LLGLSLShader gObjectShinyWaterProgram;
//environment shaders
+extern LLGLSLShader gMoonProgram;
+extern LLGLSLShader gStarsProgram;
extern LLGLSLShader gTerrainProgram;
extern LLGLSLShader gTerrainWaterProgram;
extern LLGLSLShader gWaterProgram;
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 32fb7c13a9..ee39b7d02f 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -65,6 +65,53 @@
#include "llinventorymodel.h"
#include "lluiusage.h"
+// "Minimal Vulkan" to get max API Version
+
+// Calls
+ #if defined(_WIN32)
+ #define VKAPI_ATTR
+ #define VKAPI_CALL __stdcall
+ #define VKAPI_PTR VKAPI_CALL
+ #else
+ #define VKAPI_ATTR
+ #define VKAPI_CALL
+ #define VKAPI_PTR
+ #endif // _WIN32
+
+// Macros
+ // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ // |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
+ // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ // <variant> <-------major-------><-----------minor-----------> <--------------patch-------------->
+ // 0x7 0x7F 0x3FF 0xFFF
+ #define VK_API_VERSION_MAJOR( version) (((uint32_t)(version) >> 22) & 0x07FU) // 7 bits
+ #define VK_API_VERSION_MINOR( version) (((uint32_t)(version) >> 12) & 0x3FFU) // 10 bits
+ #define VK_API_VERSION_PATCH( version) (((uint32_t)(version) ) & 0xFFFU) // 12 bits
+ #define VK_API_VERSION_VARIANT(version) (((uint32_t)(version) >> 29) & 0x007U) // 3 bits
+
+ // NOTE: variant is first parameter! This is to match vulkan/vulkan_core.h
+ #define VK_MAKE_API_VERSION(variant, major, minor, patch) (0\
+ | (((uint32_t)(major & 0x07FU)) << 22) \
+ | (((uint32_t)(minor & 0x3FFU)) << 12) \
+ | (((uint32_t)(patch & 0xFFFU)) ) \
+ | (((uint32_t)(variant & 0x007U)) << 29) )
+
+ #define VK_DEFINE_HANDLE(object) typedef struct object##_T* object;
+
+// Types
+ VK_DEFINE_HANDLE(VkInstance);
+
+ typedef enum VkResult
+ {
+ VK_SUCCESS = 0,
+ VK_RESULT_MAX_ENUM = 0x7FFFFFFF
+ } VkResult;
+
+// Prototypes
+ typedef void (VKAPI_PTR *PFN_vkVoidFunction )(void);
+ typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vkGetInstanceProcAddr )(VkInstance instance, const char* pName);
+ typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceVersion)(uint32_t* pApiVersion);
+
namespace LLStatViewer
{
@@ -592,19 +639,76 @@ void send_viewer_stats(bool include_preferences)
// detailed information on versions and extensions can come later.
static bool vulkan_oneshot = false;
static bool vulkan_detected = false;
+ static std::string vulkan_max_api_version( "0.0" ); // Unknown/None
if (!vulkan_oneshot)
{
- HMODULE vulkan_loader = LoadLibraryExA("vulkan-1.dll", NULL, LOAD_LIBRARY_AS_DATAFILE);
+ // The 32-bit and 64-bit versions normally exist in:
+ // C:\Windows\System32
+ // C:\Windows\SysWOW64
+ HMODULE vulkan_loader = LoadLibraryA("vulkan-1.dll");
if (NULL != vulkan_loader)
{
vulkan_detected = true;
+ vulkan_max_api_version = "1.0"; // We have at least 1.0. See the note about vkEnumerateInstanceVersion() below.
+
+ // We use Run-Time Dynamic Linking (via GetProcAddress()) instead of Load-Time Dynamic Linking (via directly calling vkGetInstanceProcAddr()).
+ // This allows us to:
+ // a) not need the header: #include <vulkan/vulkan.h>
+ // (and not need to set the corresponding "Additional Include Directories" as long as we provide the equivalent Vulkan types/prototypes/etc.)
+ // b) not need to link to: vulkan-1.lib
+ // (and not need to set the corresponding "Additional Library Directories")
+ // The former will allow Second Life to start and run even if the vulkan.dll is missing.
+ // The latter will require us to:
+ // a) link with vulkan-1.lib
+ // b) cause a System Error at startup if the .dll is not found:
+ // "The code execution cannot proceed because vulkan-1.dll was not found."
+ //
+ // See:
+ // https://docs.microsoft.com/en-us/windows/win32/dlls/using-run-time-dynamic-linking
+ // https://docs.microsoft.com/en-us/windows/win32/dlls/run-time-dynamic-linking
+
+ // NOTE: Technically we can use GetProcAddress() as a replacement for vkGetInstanceProcAddr()
+ // but the canonical recommendation (mandate?) is to use vkGetInstanceProcAddr().
+ PFN_vkGetInstanceProcAddr pGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) GetProcAddress(vulkan_loader, "vkGetInstanceProcAddr");
+ if(pGetInstanceProcAddr)
+ {
+ // Check for vkEnumerateInstanceVersion. If it exists then we have at least 1.1 and can query the max API version.
+ // NOTE: Each VkPhysicalDevice that supports Vulkan has its own VkPhysicalDeviceProperties.apiVersion which is separate from the max API version!
+ // See: https://www.lunarg.com/wp-content/uploads/2019/02/Vulkan-1.1-Compatibility-Statement_01_19.pdf
+ PFN_vkEnumerateInstanceVersion pEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion) pGetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion");
+ if(pEnumerateInstanceVersion)
+ {
+ uint32_t version = VK_MAKE_API_VERSION(0,1,1,0); // e.g. 4202631 = 1.2.135.0
+ VkResult status = pEnumerateInstanceVersion( &version );
+ if (status != VK_SUCCESS)
+ {
+ LL_INFOS("Vulkan") << "Failed to get Vulkan version. Assuming 1.0" << LL_ENDL;
+ }
+ else
+ {
+ // https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#extendingvulkan-coreversions-versionnumbers
+ int major = VK_API_VERSION_MAJOR ( version );
+ int minor = VK_API_VERSION_MINOR ( version );
+ int patch = VK_API_VERSION_PATCH ( version );
+ int variant = VK_API_VERSION_VARIANT( version );
+
+ vulkan_max_api_version = llformat( "%d.%d.%d.%d", major, minor, patch, variant );
+ LL_INFOS("Vulkan") << "Vulkan API version: " << vulkan_max_api_version << ", Raw version: " << version << LL_ENDL;
+ }
+ }
+ }
+ else
+ {
+ LL_WARNS("Vulkan") << "FAILED to get Vulkan vkGetInstanceProcAddr()!" << LL_ENDL;
+ }
FreeLibrary(vulkan_loader);
}
vulkan_oneshot = true;
}
misc["string_1"] = vulkan_detected ? llformat("Vulkan driver is detected") : llformat("No Vulkan driver detected");
+ misc["VulkanMaxApiVersion"] = vulkan_max_api_version;
#else
misc["string_1"] = llformat("Unused");
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index c2e09b2882..0fd796afba 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -659,8 +659,6 @@ S8 LLViewerTexture::getType() const
void LLViewerTexture::cleanup()
{
- notifyAboutMissingAsset();
-
if (LLAppViewer::getTextureFetch())
{
LLAppViewer::getTextureFetch()->updateRequestPriority(mID, 0.f);
@@ -673,30 +671,6 @@ void LLViewerTexture::cleanup()
mVolumeList[LLRender::SCULPT_TEX].clear();
}
-void LLViewerTexture::notifyAboutCreatingTexture()
-{
- LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
- for(U32 ch = 0; ch < LLRender::NUM_TEXTURE_CHANNELS; ++ch)
- {
- for(U32 f = 0; f < mNumFaces[ch]; f++)
- {
- mFaceList[ch][f]->notifyAboutCreatingTexture(this);
- }
- }
-}
-
-void LLViewerTexture::notifyAboutMissingAsset()
-{
- LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
- for(U32 ch = 0; ch < LLRender::NUM_TEXTURE_CHANNELS; ++ch)
- {
- for(U32 f = 0; f < mNumFaces[ch]; f++)
- {
- mFaceList[ch][f]->notifyAboutMissingAsset(this);
- }
- }
-}
-
// virtual
void LLViewerTexture::dump()
{
@@ -1579,8 +1553,6 @@ void LLViewerFetchedTexture::postCreateTexture()
mGLTexturep->checkActiveThread();
#endif
- notifyAboutCreatingTexture();
-
setActive();
if (!needsToSaveRawImage())
@@ -2221,8 +2193,6 @@ void LLViewerFetchedTexture::setIsMissingAsset(BOOL is_missing)
}
if (is_missing)
{
- notifyAboutMissingAsset();
-
if (mUrl.empty())
{
LL_WARNS() << mID << ": Marking image as missing" << LL_ENDL;
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index 312e2ca365..5fa5d893e7 100644
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -177,10 +177,7 @@ protected:
void cleanup() ;
void init(bool firstinit) ;
void reorganizeFaceList() ;
- void reorganizeVolumeList() ;
-
- void notifyAboutMissingAsset();
- void notifyAboutCreatingTexture();
+ void reorganizeVolumeList();
private:
friend class LLBumpImageList;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 038935963d..f06719634e 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -2367,243 +2367,11 @@ S32 LLVOVolume::setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID)
return res;
}
-bool LLVOVolume::notifyAboutCreatingTexture(LLViewerTexture *texture)
-{ //Ok, here we have confirmation about texture creation, check our wait-list
- //and make changes, or return false
-
- std::pair<mmap_UUID_MAP_t::iterator, mmap_UUID_MAP_t::iterator> range = mWaitingTextureInfo.equal_range(texture->getID());
-
- typedef std::map<U8, LLMaterialPtr> map_te_material;
- map_te_material new_material;
-
- for(mmap_UUID_MAP_t::iterator range_it = range.first; range_it != range.second; ++range_it)
- {
- LLMaterialPtr cur_material = getTEMaterialParams(range_it->second.te);
-
- //here we just interesting in DIFFUSE_MAP only!
- if(NULL != cur_material.get() && LLRender::DIFFUSE_MAP == range_it->second.map && GL_RGBA != texture->getPrimaryFormat())
- { //ok let's check the diffuse mode
- switch(cur_material->getDiffuseAlphaMode())
- {
- case LLMaterial::DIFFUSE_ALPHA_MODE_BLEND:
- case LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE:
- case LLMaterial::DIFFUSE_ALPHA_MODE_MASK:
- { //uups... we have non 32 bit texture with LLMaterial::DIFFUSE_ALPHA_MODE_* => LLMaterial::DIFFUSE_ALPHA_MODE_NONE
-
- LLMaterialPtr mat = NULL;
- map_te_material::iterator it = new_material.find(range_it->second.te);
- if(new_material.end() == it) {
- mat = new LLMaterial(cur_material->asLLSD());
- new_material.insert(map_te_material::value_type(range_it->second.te, mat));
- } else {
- mat = it->second;
- }
-
- mat->setDiffuseAlphaMode(LLMaterial::DIFFUSE_ALPHA_MODE_NONE);
-
- } break;
- } //switch
- } //if
- } //for
-
- //setup new materials
- for(map_te_material::const_iterator it = new_material.begin(), end = new_material.end(); it != end; ++it)
- {
- LLMaterialMgr::getInstance()->put(getID(), it->first, *it->second);
- LLViewerObject::setTEMaterialParams(it->first, it->second);
- }
-
- //clear wait-list
- mWaitingTextureInfo.erase(range.first, range.second);
-
- return 0 != new_material.size();
-}
-
-bool LLVOVolume::notifyAboutMissingAsset(LLViewerTexture *texture)
-{ //Ok, here if we wait information about texture and it's missing
- //then depending from the texture map (diffuse, normal, or specular)
- //make changes in material and confirm it. If not return false.
- std::pair<mmap_UUID_MAP_t::iterator, mmap_UUID_MAP_t::iterator> range = mWaitingTextureInfo.equal_range(texture->getID());
- if(range.first == range.second) return false;
-
- typedef std::map<U8, LLMaterialPtr> map_te_material;
- map_te_material new_material;
-
- for(mmap_UUID_MAP_t::iterator range_it = range.first; range_it != range.second; ++range_it)
- {
- LLMaterialPtr cur_material = getTEMaterialParams(range_it->second.te);
- if (cur_material.isNull())
- continue;
-
- switch(range_it->second.map)
- {
- case LLRender::DIFFUSE_MAP:
- {
- if(LLMaterial::DIFFUSE_ALPHA_MODE_NONE != cur_material->getDiffuseAlphaMode())
- { //missing texture + !LLMaterial::DIFFUSE_ALPHA_MODE_NONE => LLMaterial::DIFFUSE_ALPHA_MODE_NONE
- LLMaterialPtr mat = NULL;
- map_te_material::iterator it = new_material.find(range_it->second.te);
- if(new_material.end() == it) {
- mat = new LLMaterial(cur_material->asLLSD());
- new_material.insert(map_te_material::value_type(range_it->second.te, mat));
- } else {
- mat = it->second;
- }
-
- mat->setDiffuseAlphaMode(LLMaterial::DIFFUSE_ALPHA_MODE_NONE);
- }
- } break;
- case LLRender::NORMAL_MAP:
- { //missing texture => reset material texture id
- LLMaterialPtr mat = NULL;
- map_te_material::iterator it = new_material.find(range_it->second.te);
- if(new_material.end() == it) {
- mat = new LLMaterial(cur_material->asLLSD());
- new_material.insert(map_te_material::value_type(range_it->second.te, mat));
- } else {
- mat = it->second;
- }
-
- mat->setNormalID(LLUUID::null);
- } break;
- case LLRender::SPECULAR_MAP:
- { //missing texture => reset material texture id
- LLMaterialPtr mat = NULL;
- map_te_material::iterator it = new_material.find(range_it->second.te);
- if(new_material.end() == it) {
- mat = new LLMaterial(cur_material->asLLSD());
- new_material.insert(map_te_material::value_type(range_it->second.te, mat));
- } else {
- mat = it->second;
- }
-
- mat->setSpecularID(LLUUID::null);
- } break;
- case LLRender::NUM_TEXTURE_CHANNELS:
- //nothing to do, make compiler happy
- break;
- } //switch
- } //for
-
- //setup new materials
- for(map_te_material::const_iterator it = new_material.begin(), end = new_material.end(); it != end; ++it)
- {
- LLMaterialMgr::getInstance()->setLocalMaterial(getRegion()->getRegionID(), it->second);
- LLViewerObject::setTEMaterialParams(it->first, it->second);
- }
-
- //clear wait-list
- mWaitingTextureInfo.erase(range.first, range.second);
-
- return 0 != new_material.size();
-}
-
S32 LLVOVolume::setTEMaterialParams(const U8 te, const LLMaterialPtr pMaterialParams)
{
- LLMaterialPtr pMaterial = const_cast<LLMaterialPtr&>(pMaterialParams);
-
- if(pMaterialParams)
- { //check all of them according to material settings
-
- LLViewerTexture *img_diffuse = getTEImage(te);
- LLViewerTexture *img_normal = getTENormalMap(te);
- LLViewerTexture *img_specular = getTESpecularMap(te);
-
- llassert(NULL != img_diffuse);
-
- LLMaterialPtr new_material = NULL;
-
- //diffuse
- if(NULL != img_diffuse)
- { //guard
- if(0 == img_diffuse->getPrimaryFormat() && !img_diffuse->isMissingAsset())
- { //ok here we don't have information about texture, let's belief and leave material settings
- //but we remember this case
- mWaitingTextureInfo.insert(mmap_UUID_MAP_t::value_type(img_diffuse->getID(), material_info(LLRender::DIFFUSE_MAP, te)));
- }
- else
- {
- bool bSetDiffuseNone = false;
- if(img_diffuse->isMissingAsset())
- {
- bSetDiffuseNone = true;
- }
- else
- {
- switch(pMaterialParams->getDiffuseAlphaMode())
- {
- case LLMaterial::DIFFUSE_ALPHA_MODE_BLEND:
- case LLMaterial::DIFFUSE_ALPHA_MODE_EMISSIVE:
- case LLMaterial::DIFFUSE_ALPHA_MODE_MASK:
- { //all of them modes available only for 32 bit textures
- LLTextureEntry* tex_entry = getTE(te);
- bool bIsBakedImageId = false;
- if (tex_entry && LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::isBakedImageId(tex_entry->getID()))
- {
- bIsBakedImageId = true;
- }
- if (GL_RGBA != img_diffuse->getPrimaryFormat() && !bIsBakedImageId)
- {
- bSetDiffuseNone = true;
- }
- } break;
- }
- } //else
-
-
- if(bSetDiffuseNone)
- { //upps... we should substitute this material with LLMaterial::DIFFUSE_ALPHA_MODE_NONE
- new_material = new LLMaterial(pMaterialParams->asLLSD());
- new_material->setDiffuseAlphaMode(LLMaterial::DIFFUSE_ALPHA_MODE_NONE);
- }
- }
- }
-
- //normal
- if(LLUUID::null != pMaterialParams->getNormalID())
- {
- if(img_normal && img_normal->isMissingAsset() && img_normal->getID() == pMaterialParams->getNormalID())
- {
- if(!new_material) {
- new_material = new LLMaterial(pMaterialParams->asLLSD());
- }
- new_material->setNormalID(LLUUID::null);
- }
- else if(NULL == img_normal || 0 == img_normal->getPrimaryFormat())
- { //ok here we don't have information about texture, let's belief and leave material settings
- //but we remember this case
- mWaitingTextureInfo.insert(mmap_UUID_MAP_t::value_type(pMaterialParams->getNormalID(), material_info(LLRender::NORMAL_MAP,te)));
- }
-
- }
-
-
- //specular
- if(LLUUID::null != pMaterialParams->getSpecularID())
- {
- if(img_specular && img_specular->isMissingAsset() && img_specular->getID() == pMaterialParams->getSpecularID())
- {
- if(!new_material) {
- new_material = new LLMaterial(pMaterialParams->asLLSD());
- }
- new_material->setSpecularID(LLUUID::null);
- }
- else if(NULL == img_specular || 0 == img_specular->getPrimaryFormat())
- { //ok here we don't have information about texture, let's belief and leave material settings
- //but we remember this case
- mWaitingTextureInfo.insert(mmap_UUID_MAP_t::value_type(pMaterialParams->getSpecularID(), material_info(LLRender::SPECULAR_MAP, te)));
- }
- }
-
- if(new_material) {
- pMaterial = new_material;
- LLMaterialMgr::getInstance()->setLocalMaterial(getRegion()->getRegionID(), pMaterial);
- }
- }
-
- S32 res = LLViewerObject::setTEMaterialParams(te, pMaterial);
+ S32 res = LLViewerObject::setTEMaterialParams(te, pMaterialParams);
- LL_DEBUGS("MaterialTEs") << "te " << (S32)te << " material " << ((pMaterial) ? pMaterial->asLLSD() : LLSD("null")) << " res " << res
+ LL_DEBUGS("MaterialTEs") << "te " << (S32)te << " material " << ((pMaterialParams) ? pMaterialParams->asLLSD() : LLSD("null")) << " res " << res
<< ( LLSelectMgr::getInstance()->getSelection()->contains(const_cast<LLVOVolume*>(this), te) ? " selected" : " not selected" )
<< LL_ENDL;
setChanged(ALL_CHANGED);
diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h
index 003ab38d64..2c269d745d 100644
--- a/indra/newview/llvovolume.h
+++ b/indra/newview/llvovolume.h
@@ -476,26 +476,6 @@ protected:
static S32 sNumLODChanges;
friend class LLVolumeImplFlexible;
-
-public:
- bool notifyAboutCreatingTexture(LLViewerTexture *texture);
- bool notifyAboutMissingAsset(LLViewerTexture *texture);
-
-private:
- struct material_info
- {
- LLRender::eTexIndex map;
- U8 te;
-
- material_info(LLRender::eTexIndex map_, U8 te_)
- : map(map_)
- , te(te_)
- {}
- };
-
- typedef std::multimap<LLUUID, material_info> mmap_UUID_MAP_t;
- mmap_UUID_MAP_t mWaitingTextureInfo;
-
};
#endif // LL_LLVOVOLUME_H