summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llprimitive/llgltfmaterial.cpp2
-rw-r--r--indra/llrender/llglslshader.cpp1
-rw-r--r--indra/llrender/llglslshader.h1
-rw-r--r--indra/llrender/llpostprocess.cpp4
-rw-r--r--indra/llrender/llrender.cpp21
-rw-r--r--indra/llrender/llrender.h2
-rw-r--r--indra/llrender/llshadermgr.cpp13
-rw-r--r--indra/llrender/llshadermgr.h1
-rw-r--r--indra/llrender/llvertexbuffer.cpp92
-rw-r--r--indra/llrender/llvertexbuffer.h8
-rw-r--r--indra/newview/app_settings/settings.xml11
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl14
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl10
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/cofF.glsl10
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl27
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl18
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl14
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl16
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl15
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl16
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl14
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflPostF.glsl57
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflPostV.glsl39
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflUtil.glsl120
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl19
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl15
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/effects/glowV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl20
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/downsampleDepthV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl15
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl1
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl19
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl23
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl19
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl17
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/multiPointLightV.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl23
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl20
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl98
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostV.glsl48
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl138
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl27
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl23
-rw-r--r--indra/newview/llappviewer.cpp3
-rw-r--r--indra/newview/llglsandbox.cpp4
-rw-r--r--indra/newview/llgltfmateriallist.cpp553
-rw-r--r--indra/newview/llgltfmateriallist.h80
-rw-r--r--indra/newview/llhudtext.cpp4
-rw-r--r--indra/newview/llmaterialeditor.cpp130
-rw-r--r--indra/newview/llpanelface.cpp31
-rw-r--r--indra/newview/llreflectionmap.cpp138
-rw-r--r--indra/newview/llreflectionmapmanager.cpp18
-rw-r--r--indra/newview/llselectmgr.cpp73
-rw-r--r--indra/newview/llselectmgr.h5
-rw-r--r--indra/newview/llviewerdisplay.cpp9
-rw-r--r--indra/newview/llviewerobject.cpp11
-rw-r--r--indra/newview/llviewerobjectlist.cpp3
-rwxr-xr-xindra/newview/llviewerregion.cpp48
-rw-r--r--indra/newview/llviewerregion.h6
-rw-r--r--indra/newview/llviewershadermgr.cpp17
-rw-r--r--indra/newview/llviewershadermgr.h2
-rw-r--r--indra/newview/llviewerstats.cpp1
-rw-r--r--indra/newview/llviewerstats.h1
-rw-r--r--indra/newview/llvocache.cpp13
-rw-r--r--indra/newview/llvocache.h15
-rw-r--r--indra/newview/pipeline.cpp174
-rw-r--r--indra/newview/pipeline.h1
-rw-r--r--indra/newview/skins/default/xui/en/floater_stats.xml6
92 files changed, 1634 insertions, 874 deletions
diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp
index 6d23cb8039..6fbcf50482 100644
--- a/indra/llprimitive/llgltfmaterial.cpp
+++ b/indra/llprimitive/llgltfmaterial.cpp
@@ -88,7 +88,7 @@ LLGLTFMaterial& LLGLTFMaterial::operator=(const LLGLTFMaterial& rhs)
mTextureTransform = rhs.mTextureTransform;
mOverrideDoubleSided = rhs.mOverrideDoubleSided;
- mOverrideAlphaMode = rhs.mOverrideDoubleSided;
+ mOverrideAlphaMode = rhs.mOverrideAlphaMode;
return *this;
}
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 27de7070ff..0a834b28e3 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -84,6 +84,7 @@ LLShaderFeatures::LLShaderFeatures()
, hasSrgb(false)
, encodesNormal(false)
, isDeferred(false)
+ , hasScreenSpaceReflections(false)
, hasIndirect(false)
, hasShadows(false)
, hasAmbientOcclusion(false)
diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h
index 3401da832e..0df0531dce 100644
--- a/indra/llrender/llglslshader.h
+++ b/indra/llrender/llglslshader.h
@@ -54,6 +54,7 @@ public:
bool hasSrgb;
bool encodesNormal; // include: shaders\class1\environment\encodeNormF.glsl
bool isDeferred;
+ bool hasScreenSpaceReflections;
bool hasIndirect;
S32 mIndexedTextureChannels;
bool disableTextureIndex;
diff --git a/indra/llrender/llpostprocess.cpp b/indra/llrender/llpostprocess.cpp
index 74154e5676..0d87800690 100644
--- a/indra/llrender/llpostprocess.cpp
+++ b/indra/llrender/llpostprocess.cpp
@@ -390,7 +390,7 @@ void LLPostProcess::doEffects(void)
void LLPostProcess::copyFrameBuffer(U32 & texture, unsigned int width, unsigned int height)
{
- gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture);
+ gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, texture);
glCopyTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA, 0, 0, width, height, 0);
}
@@ -502,7 +502,7 @@ void LLPostProcess::createTexture(LLPointer<LLImageGL>& texture, unsigned int wi
texture = new LLImageGL(FALSE) ;
if(texture->createGLTexture())
{
- gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, texture->getTexName());
+ gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, texture->getTexName());
glTexImage2D(GL_TEXTURE_RECTANGLE, 0, 4, width, height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, &data[0]);
gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 39e3a0243c..c58fbe6c8e 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -1087,13 +1087,20 @@ void LLRender::syncMatrices()
{ //update projection matrix, normal, and MVP
glh::matrix4f& mat = mMatrix[MM_PROJECTION][mMatIdx[MM_PROJECTION]];
- // it would be nice to have this automatically track the state of the proj matrix
- // but certain render paths (deferred lighting) require it to be mismatched *sigh*
- //if (shader->getUniformLocation(LLShaderMgr::INVERSE_PROJECTION_MATRIX))
- //{
- // glh::matrix4f inv_proj = mat.inverse();
- // shader->uniformMatrix4fv(LLShaderMgr::INVERSE_PROJECTION_MATRIX, 1, FALSE, inv_proj.m);
- //}
+ // GZ: This was previously disabled seemingly due to a bug involving the deferred renderer's regular pushing and popping of mats.
+ // We're reenabling this and cleaning up the code around that - that would've been the appropriate course initially.
+ // Anything beyond the standard proj and inv proj mats are special cases. Please setup special uniforms accordingly in the future.
+ if (shader->getUniformLocation(LLShaderMgr::INVERSE_PROJECTION_MATRIX))
+ {
+ glh::matrix4f inv_proj = mat.inverse();
+ shader->uniformMatrix4fv(LLShaderMgr::INVERSE_PROJECTION_MATRIX, 1, FALSE, inv_proj.m);
+ }
+
+ // Used by some full screen effects - such as full screen lights, glow, etc.
+ if (shader->getUniformLocation(LLShaderMgr::IDENTITY_MATRIX))
+ {
+ shader->uniformMatrix4fv(LLShaderMgr::IDENTITY_MATRIX, 1, GL_FALSE, glh::matrix4f::identity().m);
+ }
shader->uniformMatrix4fv(name[MM_PROJECTION], 1, GL_FALSE, mat.m);
shader->mMatHash[MM_PROJECTION] = mMatHash[MM_PROJECTION];
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index 6dd5f9601e..9fabeb1d7a 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -339,7 +339,7 @@ public:
BF_ONE_MINUS_SOURCE_COLOR,
BF_DEST_ALPHA,
BF_SOURCE_ALPHA,
- BF_ONE_MINUS_DEST_ALPHA,
+ BF_ONE_MINUS_DEST_ALPHA,
BF_ONE_MINUS_SOURCE_ALPHA,
BF_UNDEF
diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index e8cf7ec758..b189e5452c 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -222,6 +222,14 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader)
}
}
+ if (features->hasScreenSpaceReflections)
+ {
+ if (!shader->attachFragmentObject("deferred/screenSpaceReflUtil.glsl"))
+ {
+ return FALSE;
+ }
+ }
+
if (features->hasShadows)
{
if (!shader->attachFragmentObject("deferred/shadowUtil.glsl"))
@@ -1163,10 +1171,6 @@ void LLShaderMgr::initAttribsAndUniforms()
mReservedAttribs.push_back("weight4");
mReservedAttribs.push_back("clothing");
mReservedAttribs.push_back("texture_index");
- mReservedAttribs.push_back("basecolor_texcoord"); // GLTF
- mReservedAttribs.push_back("normal_texcoord"); // GLTF
- mReservedAttribs.push_back("metallic_roughness_texcoord"); // GLTF
- mReservedAttribs.push_back("emissive_texcoord"); // GLTF
//matrix state
mReservedUniforms.push_back("modelview_matrix");
@@ -1174,6 +1178,7 @@ void LLShaderMgr::initAttribsAndUniforms()
mReservedUniforms.push_back("inv_proj");
mReservedUniforms.push_back("modelview_projection_matrix");
mReservedUniforms.push_back("inv_modelview");
+ mReservedUniforms.push_back("identity_matrix");
mReservedUniforms.push_back("normal_matrix");
mReservedUniforms.push_back("texture_matrix0");
mReservedUniforms.push_back("texture_matrix1");
diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h
index e1fb60eccf..90a8c2853c 100644
--- a/indra/llrender/llshadermgr.h
+++ b/indra/llrender/llshadermgr.h
@@ -44,6 +44,7 @@ public:
INVERSE_PROJECTION_MATRIX, // "inv_proj"
MODELVIEW_PROJECTION_MATRIX, // "modelview_projection_matrix"
INVERSE_MODELVIEW_MATRIX, // "inv_modelview"
+ IDENTITY_MATRIX, // "identity_matrix"
NORMAL_MATRIX, // "normal_matrix"
TEXTURE_MATRIX0, // "texture_matrix0"
TEXTURE_MATRIX1, // "texture_matrix1"
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index b33708cae6..f51000b9a6 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -358,10 +358,6 @@ const S32 LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_MAX] =
sizeof(LLVector4), // TYPE_WEIGHT4,
sizeof(LLVector4), // TYPE_CLOTHWEIGHT,
sizeof(LLVector4), // TYPE_TEXTURE_INDEX (actually exists as position.w), no extra data, but stride is 16 bytes
- sizeof(LLVector2), // TYPE_BASECOLOR_TEXCOORD,
- sizeof(LLVector2), // TYPE_NORMAL_TEXCOORD,
- sizeof(LLVector2), // TYPE_METALLIC_ROUGHNESS_TEXCOORD,
- sizeof(LLVector2), // TYPE_EMISSIVE_TEXCOORD,
};
static const std::string vb_type_name[] =
@@ -379,10 +375,6 @@ static const std::string vb_type_name[] =
"TYPE_WEIGHT4",
"TYPE_CLOTHWEIGHT",
"TYPE_TEXTURE_INDEX",
- "TYPE_BASECOLOR_TEXCOORD",
- "TYPE_NORMAL_TEXCOORD",
- "TYPE_METALLIC_ROUGHNESS_TEXCOORD",
- "TYPE_EMISSIVE_TEXCOORD",
"TYPE_MAX",
"TYPE_INDEX",
};
@@ -1278,10 +1270,6 @@ void LLVertexBuffer::setupVertexArray()
4, //TYPE_WEIGHT4,
4, //TYPE_CLOTHWEIGHT,
1, //TYPE_TEXTURE_INDEX
- 2, // TYPE_BASECOLOR_TEXCOORD,
- 2, // TYPE_NORMAL_TEXCOORD,
- 2, // TYPE_METALLIC_ROUGHNESS_TEXCOORD,
- 2, // TYPE_EMISSIVE_TEXCOORD,
};
static const U32 attrib_type[] =
@@ -1299,10 +1287,6 @@ void LLVertexBuffer::setupVertexArray()
GL_FLOAT, //TYPE_WEIGHT4,
GL_FLOAT, //TYPE_CLOTHWEIGHT,
GL_UNSIGNED_INT, //TYPE_TEXTURE_INDEX
- GL_FLOAT, // TYPE_BASECOLOR_TEXCOORD,
- GL_FLOAT, // TYPE_NORMAL_TEXCOORD,
- GL_FLOAT, // TYPE_METALLIC_ROUGHNESS_TEXCOORD,
- GL_FLOAT, // TYPE_EMISSIVE_TEXCOORD,
};
static const bool attrib_integer[] =
@@ -1320,10 +1304,6 @@ void LLVertexBuffer::setupVertexArray()
false, //TYPE_WEIGHT4,
false, //TYPE_CLOTHWEIGHT,
true, //TYPE_TEXTURE_INDEX
- false, // TYPE_BASECOLOR_TEXCOORD,
- false, // TYPE_NORMAL_TEXCOORD,
- false, // TYPE_METALLIC_ROUGHNESS_TEXCOORD,
- false, // TYPE_EMISSIVE_TEXCOORD,
};
static const U32 attrib_normalized[] =
@@ -1341,10 +1321,6 @@ void LLVertexBuffer::setupVertexArray()
GL_FALSE, //TYPE_WEIGHT4,
GL_FALSE, //TYPE_CLOTHWEIGHT,
GL_FALSE, //TYPE_TEXTURE_INDEX
- GL_FALSE, // TYPE_BASECOLOR_TEXCOORD,
- GL_FALSE, // TYPE_NORMAL_TEXCOORD,
- GL_FALSE, // TYPE_METALLIC_ROUGHNESS_TEXCOORD,
- GL_FALSE, // TYPE_EMISSIVE_TEXCOORD,
};
bindGLBuffer(true);
@@ -1985,26 +1961,6 @@ bool LLVertexBuffer::getClothWeightStrider(LLStrider<LLVector4>& strider, S32 in
return VertexBufferStrider<LLVector4,TYPE_CLOTHWEIGHT>::get(*this, strider, index, count, map_range);
}
-bool LLVertexBuffer::getBasecolorTexcoordStrider(LLStrider<LLVector2>& strider, S32 index, S32 count, bool map_range)
-{
- return VertexBufferStrider<LLVector2,TYPE_BASECOLOR_TEXCOORD>::get(*this, strider, index, count, map_range);
-}
-
-bool LLVertexBuffer::getNormalTexcoordStrider(LLStrider<LLVector2>& strider, S32 index, S32 count, bool map_range)
-{
- return VertexBufferStrider<LLVector2,TYPE_NORMAL_TEXCOORD>::get(*this, strider, index, count, map_range);
-}
-
-bool LLVertexBuffer::getMetallicRoughnessTexcoordStrider(LLStrider<LLVector2>& strider, S32 index, S32 count, bool map_range)
-{
- return VertexBufferStrider<LLVector2,TYPE_METALLIC_ROUGHNESS_TEXCOORD>::get(*this, strider, index, count, map_range);
-}
-
-bool LLVertexBuffer::getEmissiveTexcoordStrider(LLStrider<LLVector2>& strider, S32 index, S32 count, bool map_range)
-{
- return VertexBufferStrider<LLVector2,TYPE_EMISSIVE_TEXCOORD>::get(*this, strider, index, count, map_range);
-}
-
//----------------------------------------------------------------------------
bool LLVertexBuffer::bindGLArray()
@@ -2423,30 +2379,6 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask)
void* ptr = (void*)(base + mOffsets[TYPE_VERTEX]);
glVertexAttribPointer(loc, 3,GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_VERTEX], ptr);
}
- if (data_mask & MAP_BASECOLOR_TEXCOORD)
- {
- S32 loc = TYPE_BASECOLOR_TEXCOORD;
- void* ptr = (void*)(base + mOffsets[TYPE_BASECOLOR_TEXCOORD]);
- glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_BASECOLOR_TEXCOORD], ptr);
- }
- if (data_mask & MAP_NORMAL_TEXCOORD)
- {
- S32 loc = TYPE_NORMAL_TEXCOORD;
- void* ptr = (void*)(base + mOffsets[TYPE_NORMAL_TEXCOORD]);
- glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_NORMAL_TEXCOORD], ptr);
- }
- if (data_mask & MAP_METALLIC_ROUGHNESS_TEXCOORD)
- {
- S32 loc = TYPE_METALLIC_ROUGHNESS_TEXCOORD;
- void* ptr = (void*)(base + mOffsets[TYPE_METALLIC_ROUGHNESS_TEXCOORD]);
- glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_METALLIC_ROUGHNESS_TEXCOORD], ptr);
- }
- if (data_mask & MAP_EMISSIVE_TEXCOORD)
- {
- S32 loc = TYPE_EMISSIVE_TEXCOORD;
- void* ptr = (void*)(base + mOffsets[TYPE_EMISSIVE_TEXCOORD]);
- glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_EMISSIVE_TEXCOORD], ptr);
- }
llglassertok();
}
@@ -2540,30 +2472,6 @@ 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);
}
- if (data_mask & MAP_BASECOLOR_TEXCOORD)
- {
- S32 loc = TYPE_BASECOLOR_TEXCOORD;
- void* ptr = (void*)(base + mOffsets[TYPE_BASECOLOR_TEXCOORD]);
- glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_BASECOLOR_TEXCOORD], ptr);
- }
- if (data_mask & MAP_NORMAL_TEXCOORD)
- {
- S32 loc = TYPE_NORMAL_TEXCOORD;
- void* ptr = (void*)(base + mOffsets[TYPE_NORMAL_TEXCOORD]);
- glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_NORMAL_TEXCOORD], ptr);
- }
- if (data_mask & MAP_METALLIC_ROUGHNESS_TEXCOORD)
- {
- S32 loc = TYPE_METALLIC_ROUGHNESS_TEXCOORD;
- void* ptr = (void*)(base + mOffsets[TYPE_METALLIC_ROUGHNESS_TEXCOORD]);
- glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_METALLIC_ROUGHNESS_TEXCOORD], ptr);
- }
- if (data_mask & MAP_EMISSIVE_TEXCOORD)
- {
- S32 loc = TYPE_EMISSIVE_TEXCOORD;
- void* ptr = (void*)(base + mOffsets[TYPE_EMISSIVE_TEXCOORD]);
- glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_EMISSIVE_TEXCOORD], ptr);
- }
}
LLVertexBuffer::MappedRegion::MappedRegion(S32 type, S32 index, S32 count)
diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h
index b54e99ca27..99b8b54d69 100644
--- a/indra/llrender/llvertexbuffer.h
+++ b/indra/llrender/llvertexbuffer.h
@@ -182,10 +182,6 @@ public:
TYPE_WEIGHT4, // "weight4"
TYPE_CLOTHWEIGHT, // "clothing"
TYPE_TEXTURE_INDEX, // "texture_index"
- TYPE_BASECOLOR_TEXCOORD, // "basecolor_texcoord" (GLTF)
- TYPE_NORMAL_TEXCOORD, // "normal_texcoord" (GLTF)
- TYPE_METALLIC_ROUGHNESS_TEXCOORD, // "metallic_roughness_texcoord" (GLTF)
- TYPE_EMISSIVE_TEXCOORD, // "emissive_texcoord" (GLTF)
TYPE_MAX, // TYPE_MAX is the size/boundary marker for attributes that go in the vertex buffer
TYPE_INDEX, // TYPE_INDEX is beyond _MAX because it lives in a separate (index) buffer
};
@@ -205,10 +201,6 @@ public:
MAP_WEIGHT4 = (1<<TYPE_WEIGHT4),
MAP_CLOTHWEIGHT = (1<<TYPE_CLOTHWEIGHT),
MAP_TEXTURE_INDEX = (1<<TYPE_TEXTURE_INDEX),
- MAP_BASECOLOR_TEXCOORD = (1<<TYPE_BASECOLOR_TEXCOORD),
- MAP_NORMAL_TEXCOORD = (1<<TYPE_NORMAL_TEXCOORD),
- MAP_METALLIC_ROUGHNESS_TEXCOORD = (1<<TYPE_METALLIC_ROUGHNESS_TEXCOORD),
- MAP_EMISSIVE_TEXCOORD = (1<<TYPE_EMISSIVE_TEXCOORD),
};
protected:
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 3f9a91e38f..71611a58bc 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -9133,6 +9133,17 @@
<real>0.00</real>
</array>
</map>
+ <key>RenderScreenSpaceReflections</key>
+ <map>
+ <key>Comment</key>
+ <string>Renders screen space reflections to better account for dynamic objects with reflection probes.</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Boolean</string>
+ <key>Value</key>
+ <integer>0</integer>
+ </map>
<key>RenderBumpmapMinDistanceSquared</key>
<map>
<key>Comment</key>
diff --git a/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl
index 23adbded5e..f93ed6bc6d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl
@@ -24,8 +24,8 @@
*/
uniform sampler2D noiseMap;
-uniform sampler2DRect normalMap;
-uniform sampler2DRect depthMap;
+uniform sampler2D normalMap;
+uniform sampler2D depthMap;
uniform float ssao_radius;
uniform float ssao_max_radius;
@@ -38,23 +38,19 @@ uniform vec2 screen_res;
vec2 getScreenCoordinateAo(vec2 screenpos)
{
vec2 sc = screenpos.xy * 2.0;
- if (screen_res.x > 0 && screen_res.y > 0)
- {
- sc /= screen_res;
- }
return sc - vec2(1.0, 1.0);
}
float getDepthAo(vec2 pos_screen)
{
- float depth = texture2DRect(depthMap, pos_screen).r;
+ float depth = texture2D(depthMap, pos_screen).r;
return depth;
}
vec4 getPositionAo(vec2 pos_screen)
{
float depth = getDepthAo(pos_screen);
- vec2 sc = getScreenCoordinateAo(pos_screen);
+ vec2 sc = (pos_screen);
vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
vec4 pos = inv_proj * ndc;
pos /= pos.w;
@@ -83,7 +79,7 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen)
{
float ret = 1.0;
vec3 pos_world = pos.xyz;
- vec2 noise_reflect = texture2D(noiseMap, pos_screen.xy/128.0).xy;
+ vec2 noise_reflect = texture2D(noiseMap, pos_screen.xy).xy;
float angle_hidden = 0.0;
float points = 0;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
index fa3634f3b6..9bead273ff 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
@@ -33,8 +33,8 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect normalMap;
-uniform sampler2DRect lightMap;
+uniform sampler2D normalMap;
+uniform sampler2D lightMap;
uniform float dist_factor;
uniform float blur_size;
@@ -52,7 +52,7 @@ void main()
vec2 tc = vary_fragcoord.xy;
vec3 norm = getNorm(tc);
vec3 pos = getPosition(tc).xyz;
- vec4 ccol = texture2DRect(lightMap, tc).rgba;
+ vec4 ccol = texture2D(lightMap, tc).rgba;
vec2 dlt = kern_scale * delta / (1.0+norm.xy*norm.xy);
dlt /= max(-pos.z*dist_factor, 1.0);
@@ -89,7 +89,7 @@ void main()
if (d*d <= pointplanedist_tolerance_pow2)
{
- col += texture2DRect(lightMap, samptc)*k[i].xyxx;
+ col += texture2D(lightMap, samptc)*k[i].xyxx;
defined_weight += k[i].xy;
}
}
@@ -103,7 +103,7 @@ void main()
if (d*d <= pointplanedist_tolerance_pow2)
{
- col += texture2DRect(lightMap, samptc)*k[i].xyxx;
+ col += texture2D(lightMap, samptc)*k[i].xyxx;
defined_weight += k[i].xy;
}
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl
index 212f7e56ad..5e0f01981b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl
@@ -23,8 +23,6 @@
* $/LicenseInfo$
*/
-uniform mat4 modelview_projection_matrix;
-
ATTRIBUTE vec3 position;
VARYING vec2 vary_fragcoord;
@@ -33,7 +31,7 @@ uniform vec2 screen_res;
void main()
{
//transform vertex
- vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
+ vec4 pos = vec4(position.xyz, 1.0);
gl_Position = pos;
- vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
+ vary_fragcoord = (pos.xy*0.5+0.5);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl
index 079d8458c9..1e640d95ae 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl
@@ -33,8 +33,8 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect depthMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D depthMap;
uniform sampler2D bloomMap;
uniform float depth_cutoff;
@@ -69,19 +69,19 @@ void main()
{
vec2 tc = vary_fragcoord.xy;
- float z = texture2DRect(depthMap, tc).r;
+ float z = texture2D(depthMap, tc).r;
z = z*2.0-1.0;
vec4 ndc = vec4(0.0, 0.0, z, 1.0);
vec4 p = inv_proj*ndc;
float depth = p.z/p.w;
- vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy);
+ vec4 diff = texture2D(diffuseRect, vary_fragcoord.xy);
float sc = calc_cof(depth);
sc = min(sc, max_cof);
sc = max(sc, -max_cof);
- vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy/screen_res);
+ vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy);
frag_color.rgb = diff.rgb + bloom.rgb;
frag_color.a = sc/max_cof*0.5+0.5;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
index 1a96ee0736..c87e754eca 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
@@ -48,8 +48,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
-uniform sampler2DRect normalMap;
-uniform sampler2DRect depthMap;
+uniform sampler2D normalMap;
+uniform sampler2D depthMap;
uniform sampler2D projectionMap; // rgba
uniform sampler2D brdfLut;
@@ -138,10 +138,6 @@ bool clipProjectedLightVars(vec3 light_center, vec3 pos, out float dist, out flo
vec2 getScreenCoordinate(vec2 screenpos)
{
vec2 sc = screenpos.xy * 2.0;
- if (screen_res.x > 0 && screen_res.y > 0)
- {
- sc /= screen_res;
- }
return sc - vec2(1.0, 1.0);
}
@@ -149,7 +145,7 @@ vec2 getScreenCoordinate(vec2 screenpos)
// Method #4: Spheremap Transform, Lambert Azimuthal Equal-Area projection
vec3 getNorm(vec2 screenpos)
{
- vec2 enc = texture2DRect(normalMap, screenpos.xy).xy;
+ vec2 enc = texture2D(normalMap, screenpos.xy).xy;
vec2 fenc = enc*4-2;
float f = dot(fenc,fenc);
float g = sqrt(1-f/4);
@@ -175,7 +171,7 @@ vec3 getNormalFromPacked(vec4 packedNormalEnvIntensityFlags)
// See: C++: addDeferredAttachments(), GLSL: softenLightF
vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensity)
{
- vec4 packedNormalEnvIntensityFlags = texture2DRect(normalMap, screenpos.xy);
+ vec4 packedNormalEnvIntensityFlags = texture2D(normalMap, screenpos.xy);
n = getNormalFromPacked( packedNormalEnvIntensityFlags );
envIntensity = packedNormalEnvIntensityFlags.z;
return packedNormalEnvIntensityFlags;
@@ -188,9 +184,14 @@ float linearDepth(float d, float znear, float zfar)
return znear * 2.0 * zfar / (zfar + znear - d * (zfar - znear));
}
+float linearDepth01(float d, float znear, float zfar)
+{
+ return linearDepth(d, znear, zfar) / zfar;
+}
+
float getDepth(vec2 pos_screen)
{
- float depth = texture2DRect(depthMap, pos_screen).r;
+ float depth = texture2D(depthMap, pos_screen).r;
return depth;
}
@@ -333,6 +334,14 @@ vec4 getPositionWithDepth(vec2 pos_screen, float depth)
return vec4(getPositionWithNDC(ndc), 1.0);
}
+vec2 getScreenCoord(vec4 clip)
+{
+ vec4 ndc = clip;
+ ndc.xyz /= clip.w;
+ vec2 screen = vec2( ndc.xy * 0.5 );
+ screen += 0.5;
+ return screen;
+}
vec2 getScreenXY(vec4 clip)
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl b/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl
index 8d48bb016b..d9c0e590c8 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl
@@ -33,8 +33,8 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect lightMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D lightMap;
uniform mat4 inv_proj;
uniform vec2 screen_res;
@@ -46,12 +46,12 @@ uniform float dof_height;
VARYING vec2 vary_fragcoord;
-vec4 dofSample(sampler2DRect tex, vec2 tc)
+vec4 dofSample(sampler2D tex, vec2 tc)
{
tc.x = min(tc.x, dof_width);
tc.y = min(tc.y, dof_height);
- return texture2DRect(tex, tc);
+ return texture2D(tex, tc);
}
void main()
@@ -60,7 +60,7 @@ void main()
vec4 dof = dofSample(diffuseRect, vary_fragcoord.xy*res_scale);
- vec4 diff = texture2DRect(lightMap, vary_fragcoord.xy);
+ vec4 diff = texture2D(lightMap, vary_fragcoord.xy);
float a = min(abs(diff.a*2.0-1.0) * max_cof*res_scale*res_scale, 1.0);
@@ -69,10 +69,10 @@ void main()
float sc = a/res_scale;
vec4 col;
- col = texture2DRect(lightMap, vary_fragcoord.xy+vec2(sc,sc));
- col += texture2DRect(lightMap, vary_fragcoord.xy+vec2(-sc,sc));
- col += texture2DRect(lightMap, vary_fragcoord.xy+vec2(sc,-sc));
- col += texture2DRect(lightMap, vary_fragcoord.xy+vec2(-sc,-sc));
+ col = texture2D(lightMap, vary_fragcoord.xy+vec2(sc,sc)/screen_res);
+ col += texture2D(lightMap, vary_fragcoord.xy+vec2(-sc,sc)/screen_res);
+ col += texture2D(lightMap, vary_fragcoord.xy+vec2(sc,-sc)/screen_res);
+ col += texture2D(lightMap, vary_fragcoord.xy+vec2(-sc,-sc)/screen_res);
diff = mix(diff, col*0.25, a);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
index be1003a7e0..185c1150ef 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
@@ -31,10 +31,10 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect diffuseMap;
+uniform sampler2D diffuseMap;
VARYING vec2 vary_fragcoord;
void main()
{
- frag_color = texture2DRect(diffuseMap, vary_fragcoord.xy);
+ frag_color = texture2D(diffuseMap, vary_fragcoord.xy);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl
index f2dc60aa5d..5488a63c6a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl
@@ -39,7 +39,7 @@ void main()
vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
gl_Position = pos;
- vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res;
+ vary_fragcoord = (pos.xy * 0.5 + 0.5);
vertex_color = diffuse_color;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index 0ae4bbfc5d..8feeff848b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -33,9 +33,9 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect depthMap;
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
+uniform sampler2D depthMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
uniform sampler2D noiseMap;
uniform sampler2D lightFunc;
@@ -54,6 +54,8 @@ VARYING vec4 vary_fragcoord;
vec4 getPosition(vec2 pos_screen);
vec3 getNorm(vec2 pos_screen);
vec3 srgb_to_linear(vec3 c);
+float getDepth(vec2 tc);
+vec2 getScreenCoord(vec4 clip);
void main()
{
@@ -62,7 +64,7 @@ void main()
#endif
vec3 out_col = vec3(0, 0, 0);
- vec2 frag = (vary_fragcoord.xy * 0.5 + 0.5) * screen_res;
+ vec2 frag = getScreenCoord(vary_fragcoord);
vec3 pos = getPosition(frag.xy).xyz;
if (pos.z < far_z)
{
@@ -71,8 +73,8 @@ void main()
vec3 norm = getNorm(frag.xy);
- vec4 spec = texture2DRect(specularRect, frag.xy);
- vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb;
+ vec4 spec = texture2D(specularRect, frag.xy);
+ vec3 diff = texture2D(diffuseRect, frag.xy).rgb;
float noise = texture2D(noiseMap, frag.xy / 128.0).b;
vec3 npos = normalize(-pos);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl
index eefefa640d..d71dc76423 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl
@@ -23,8 +23,6 @@
* $/LicenseInfo$
*/
-uniform mat4 modelview_projection_matrix;
-
ATTRIBUTE vec3 position;
VARYING vec4 vary_fragcoord;
@@ -32,7 +30,7 @@ VARYING vec4 vary_fragcoord;
void main()
{
//transform vertex
- vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
+ vec4 pos = vec4(position.xyz, 1.0);
vary_fragcoord = pos;
gl_Position = pos;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
index 8dcc18080d..42a52d7908 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
@@ -38,10 +38,10 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect depthMap;
-uniform sampler2DRect normalMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D depthMap;
+uniform sampler2D normalMap;
uniform sampler2D noiseMap;
uniform sampler2D projectionMap;
uniform sampler2D lightFunc;
@@ -72,6 +72,7 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
vec3 getNorm(vec2 pos_screen);
vec3 srgb_to_linear(vec3 c);
+float getDepth(vec2 tc);
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
{
@@ -137,7 +138,6 @@ void main()
vec4 frag = vary_fragcoord;
frag.xyz /= frag.w;
frag.xyz = frag.xyz*0.5+0.5;
- frag.xy *= screen_res;
vec3 pos = getPosition(frag.xy).xyz;
vec3 lv = center.xyz-pos.xyz;
@@ -148,7 +148,7 @@ void main()
discard;
}
- float envIntensity = texture2DRect(normalMap, frag.xy).z;
+ float envIntensity = texture2D(normalMap, frag.xy).z;
vec3 norm = getNorm(frag.xy);
float l_dist = -dot(lv, proj_n);
@@ -180,7 +180,7 @@ void main()
float da = dot(norm, lv);
- vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
+ vec3 diff_tex = texture2D(diffuseRect, frag.xy).rgb;
vec3 dlit = vec3(0, 0, 0);
@@ -220,7 +220,7 @@ void main()
}
- vec4 spec = texture2DRect(specularRect, frag.xy);
+ vec4 spec = texture2D(specularRect, frag.xy);
if (spec.a > 0.0)
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
index 5bb034d5c1..40a4f86c37 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
@@ -33,12 +33,12 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect normalMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D normalMap;
uniform sampler2D noiseMap;
uniform sampler2D lightFunc;
-uniform sampler2DRect depthMap;
+uniform sampler2D depthMap;
uniform vec3 env_mat[3];
uniform float sun_wash;
@@ -57,6 +57,7 @@ uniform vec4 viewport;
vec3 getNorm(vec2 pos_screen);
vec4 getPosition(vec2 pos_screen);
+float getDepth(vec2 pos);
vec3 srgb_to_linear(vec3 c);
void main()
@@ -64,7 +65,6 @@ void main()
vec4 frag = vary_fragcoord;
frag.xyz /= frag.w;
frag.xyz = frag.xyz*0.5+0.5;
- frag.xy *= screen_res;
vec3 pos = getPosition(frag.xy).xyz;
vec3 lv = trans_center.xyz-pos;
@@ -88,7 +88,7 @@ void main()
float noise = texture2D(noiseMap, frag.xy/128.0).b;
- vec3 col = texture2DRect(diffuseRect, frag.xy).rgb;
+ vec3 col = texture2D(diffuseRect, frag.xy).rgb;
float fa = falloff+1.0;
float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
@@ -99,7 +99,7 @@ void main()
col = color.rgb*lit*col;
- vec4 spec = texture2DRect(specularRect, frag.xy);
+ vec4 spec = texture2D(specularRect, frag.xy);
if (spec.a > 0.0)
{
lit = min(da*6.0, 1.0) * dist_atten;
@@ -125,6 +125,7 @@ void main()
{
discard;
}
+ final_color.rgb = vec3(getDepth(frag.xy));
frag_color.rgb = col;
frag_color.a = 0.0;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
index f06f8c870b..5ca39d6966 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
@@ -33,7 +33,7 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect diffuseRect;
+uniform sampler2D diffuseRect;
uniform mat4 inv_proj;
uniform vec2 screen_res;
@@ -44,7 +44,7 @@ VARYING vec2 vary_fragcoord;
void dofSample(inout vec4 diff, inout float w, float min_sc, vec2 tc)
{
- vec4 s = texture2DRect(diffuseRect, tc);
+ vec4 s = texture2D(diffuseRect, tc);
float sc = abs(s.a*2.0-1.0)*max_cof;
@@ -63,7 +63,7 @@ void dofSample(inout vec4 diff, inout float w, float min_sc, vec2 tc)
void dofSampleNear(inout vec4 diff, inout float w, float min_sc, vec2 tc)
{
- vec4 s = texture2DRect(diffuseRect, tc);
+ vec4 s = texture2D(diffuseRect, tc);
float wg = 0.25;
@@ -79,7 +79,7 @@ void main()
{
vec2 tc = vary_fragcoord.xy;
- vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy);
+ vec4 diff = texture2D(diffuseRect, vary_fragcoord.xy);
{
float w = 1.0;
@@ -93,14 +93,14 @@ void main()
{
while (sc > 0.5)
{
- int its = int(max(1.0,(sc*3.7)));
+ int its = int(max(1.0,(sc*3.7)));
for (int i=0; i<its; ++i)
{
float ang = sc+i*2*PI/its; // sc is added for rotary perturbance
float samp_x = sc*sin(ang);
float samp_y = sc*cos(ang);
// you could test sample coords against an interesting non-circular aperture shape here, if desired.
- dofSampleNear(diff, w, sc, vary_fragcoord.xy + vec2(samp_x,samp_y));
+ dofSampleNear(diff, w, sc, vary_fragcoord.xy + (vec2(samp_x,samp_y) / screen_res));
}
sc -= 1.0;
}
@@ -117,7 +117,7 @@ void main()
float samp_x = sc*sin(ang);
float samp_y = sc*cos(ang);
// you could test sample coords against an interesting non-circular aperture shape here, if desired.
- dofSample(diff, w, sc, vary_fragcoord.xy + vec2(samp_x,samp_y));
+ dofSample(diff, w, sc, vary_fragcoord.xy + (vec2(samp_x,samp_y) / screen_res));
}
sc -= 1.0;
}
@@ -125,6 +125,6 @@ void main()
diff /= w;
}
-
+
frag_color = diff;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl
index b61f37fe47..a73a59bc6f 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl
@@ -33,7 +33,7 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect diffuseRect;
+uniform sampler2D diffuseRect;
uniform vec2 screen_res;
VARYING vec2 vary_fragcoord;
@@ -82,7 +82,7 @@ float noise(vec2 x) {
void main()
{
//this is the one of the rare spots where diffuseRect contains linear color values (not sRGB)
- vec4 diff = texture2DRect(diffuseRect, vary_fragcoord);
+ vec4 diff = texture2D(diffuseRect, vary_fragcoord);
diff.rgb = linear_to_srgb(diff.rgb);
vec3 seed = (diff.rgb+vec3(1.0))*vec3(vary_fragcoord.xy, vary_fragcoord.x+vary_fragcoord.y);
vec3 nz = vec3(noise(seed.rg), noise(seed.gb), noise(seed.rb));
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl
index 058941bfb2..a79f644aef 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl
@@ -33,7 +33,7 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect diffuseRect;
+uniform sampler2D diffuseRect;
uniform sampler2D bloomMap;
uniform vec2 screen_res;
@@ -41,9 +41,9 @@ VARYING vec2 vary_fragcoord;
void main()
{
- vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy);
+ vec4 diff = texture2D(diffuseRect, vary_fragcoord.xy);
- vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy/screen_res);
+ vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy);
frag_color = diff + bloom;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl
index bd0cb50464..4d24b4de9a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl
@@ -23,8 +23,6 @@
* $/LicenseInfo$
*/
-uniform mat4 modelview_projection_matrix;
-
ATTRIBUTE vec3 position;
VARYING vec2 vary_fragcoord;
@@ -34,7 +32,7 @@ uniform vec2 screen_res;
void main()
{
//transform vertex
- vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
+ vec4 pos = vec4(position.xyz, 1.0);
gl_Position = pos;
- vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
+ vary_fragcoord = (pos.xy*0.5+0.5);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl
index 8edf5b2723..86f0077edb 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl
@@ -23,8 +23,6 @@
* $/LicenseInfo$
*/
-uniform mat4 modelview_projection_matrix;
-
ATTRIBUTE vec3 position;
VARYING vec2 vary_fragcoord;
@@ -37,8 +35,8 @@ uniform vec2 screen_res;
void main()
{
//transform vertex
- vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
+ vec4 pos = vec4(position.xyz, 1.0);
gl_Position = pos;
vary_tc = (pos.xy*0.5+0.5)*tc_scale;
- vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
+ vary_fragcoord = (pos.xy*0.5+0.5);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
index cf994d3547..8111f43c28 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
@@ -31,9 +31,9 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect depthMap;
-uniform sampler2DRect normalMap;
-uniform sampler2DRect giLightMap;
+uniform sampler2D depthMap;
+uniform sampler2D normalMap;
+uniform sampler2D giLightMap;
uniform sampler2D noiseMap;
uniform vec2 kern[32];
@@ -53,11 +53,11 @@ vec4 getPosition(vec2 pos_screen);
void main()
{
- vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz;
+ vec3 norm = texture2D(normalMap, vary_fragcoord.xy).xyz;
norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
vec3 pos = getPosition(vary_fragcoord.xy).xyz;
- vec3 ccol = texture2DRect(giLightMap, vary_fragcoord.xy).rgb;
+ vec3 ccol = texture2D(giLightMap, vary_fragcoord.xy).rgb;
vec2 dlt = kern_scale * delta/(1.0+norm.xy*norm.xy);
dlt /= max(-pos.z*dist_factor, 1.0);
float defined_weight = kern[0].x;
@@ -66,7 +66,7 @@ void main()
for (int i = 0; i < kern_length; i++)
{
vec2 tc = vary_fragcoord.xy + kern[i].y*dlt;
- vec3 sampNorm = texture2DRect(normalMap, tc.xy).xyz;
+ vec3 sampNorm = texture2D(normalMap, tc.xy).xyz;
sampNorm = vec3((sampNorm.xy-0.5)*2.0,sampNorm.z); // unpack norm
float d = dot(norm.xyz, sampNorm);
@@ -77,7 +77,7 @@ void main()
samppos -= pos;
if (dot(samppos,samppos) < -0.05*pos.z)
{
- col += texture2DRect(giLightMap, tc).rgb*kern[i].x;
+ col += texture2D(giLightMap, tc).rgb*kern[i].x;
defined_weight += kern[i].x;
}
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflPostF.glsl b/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflPostF.glsl
new file mode 100644
index 0000000000..8373567bb0
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflPostF.glsl
@@ -0,0 +1,57 @@
+/**
+ * @file class3/deferred/screenSpaceReflPostF.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$
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+
+/*[EXTRA_CODE_HERE]*/
+
+#ifdef DEFINE_GL_FRAGCOLOR
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor
+#endif
+
+uniform vec2 screen_res;
+uniform mat4 projection_matrix;
+uniform mat4 inv_proj;
+uniform float zNear;
+uniform float zFar;
+
+VARYING vec2 vary_fragcoord;
+
+uniform sampler2D depthMap;
+uniform sampler2D normalMap;
+uniform sampler2D sceneMap;
+uniform sampler2D diffuseRect;
+
+vec3 getNorm(vec2 screenpos);
+float getDepth(vec2 pos_screen);
+float linearDepth(float d, float znear, float zfar);
+
+void main() {
+ vec2 tc = vary_fragcoord.xy;
+ vec4 pos = getPositionWithDepth(tc, getDepth(tc));
+ frag_color = pos;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflPostV.glsl b/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflPostV.glsl
new file mode 100644
index 0000000000..966e7e1cbb
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflPostV.glsl
@@ -0,0 +1,39 @@
+/**
+ * @file class3/deferred/screenSpaceReflPostV.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$
+ */
+
+ATTRIBUTE vec3 position;
+
+uniform vec2 screen_res;
+
+VARYING vec2 vary_fragcoord;
+
+void main()
+{
+ //transform vertex
+ vec4 pos = vec4(position.xyz, 1.0);
+ gl_Position = pos;
+
+ vary_fragcoord = pos.xy * 0.5 + 0.5;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflUtil.glsl
new file mode 100644
index 0000000000..6dfc89a6c6
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflUtil.glsl
@@ -0,0 +1,120 @@
+/**
+ * @file class3/deferred/screenSpaceReflUtil.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 sampler2D depthMap;
+uniform sampler2D normalMap;
+uniform sampler2D sceneMap;
+uniform vec2 screen_res;
+uniform mat4 projection_matrix;
+
+// Shamelessly taken from http://casual-effects.blogspot.com/2014/08/screen-space-ray-tracing.html
+// Original paper: https://jcgt.org/published/0003/04/04/
+// By Morgan McGuire and Michael Mara at Williams College 2014
+// Released as open source under the BSD 2-Clause License
+// http://opensource.org/licenses/BSD-2-Clause
+
+float distanceSquared(vec2 a, vec2 b) { a -= b; return dot(a, a); }
+
+bool traceScreenSpaceRay1(vec3 csOrig, vec3 csDir, mat4 proj, float zThickness,
+ float nearPlaneZ, float stride, float jitter, const float maxSteps, float maxDistance,
+ out vec2 hitPixel, out vec3 hitPoint)
+{
+
+ // Clip to the near plane
+ float rayLength = ((csOrig.z + csDir.z * maxDistance) > nearPlaneZ) ?
+ (nearPlaneZ - csOrig.z) / csDir.z : maxDistance;
+ vec3 csEndPoint = csOrig + csDir * rayLength;
+
+ // Project into homogeneous clip space
+ vec4 H0 = proj * vec4(csOrig, 1.0);
+ vec4 H1 = proj * vec4(csEndPoint, 1.0);
+ float k0 = 1.0 / H0.w, k1 = 1.0 / H1.w;
+
+ // The interpolated homogeneous version of the camera-space points
+ vec3 Q0 = csOrig * k0, Q1 = csEndPoint * k1;
+
+ // Screen-space endpoints
+ vec2 P0 = H0.xy * k0, P1 = H1.xy * k1;
+
+ // If the line is degenerate, make it cover at least one pixel
+ // to avoid handling zero-pixel extent as a special case later
+ P1 += vec2((distanceSquared(P0, P1) < 0.0001) ? 0.01 : 0.0);
+ vec2 delta = P1 - P0;
+
+ // Permute so that the primary iteration is in x to collapse
+ // all quadrant-specific DDA cases later
+ bool permute = false;
+ if (abs(delta.x) < abs(delta.y)) {
+ // This is a more-vertical line
+ permute = true; delta = delta.yx; P0 = P0.yx; P1 = P1.yx;
+ }
+
+ float stepDir = sign(delta.x);
+ float invdx = stepDir / delta.x;
+
+ // Track the derivatives of Q and k
+ vec3 dQ = (Q1 - Q0) * invdx;
+ float dk = (k1 - k0) * invdx;
+ vec2 dP = vec2(stepDir, delta.y * invdx);
+
+ // Scale derivatives by the desired pixel stride and then
+ // offset the starting values by the jitter fraction
+ dP *= stride; dQ *= stride; dk *= stride;
+ P0 += dP * jitter; Q0 += dQ * jitter; k0 += dk * jitter;
+
+ // Slide P from P0 to P1, (now-homogeneous) Q from Q0 to Q1, k from k0 to k1
+ vec3 Q = Q0;
+
+ // Adjust end condition for iteration direction
+ float end = P1.x * stepDir;
+
+ float k = k0, stepCount = 0.0, prevZMaxEstimate = csOrig.z;
+ float rayZMin = prevZMaxEstimate, rayZMax = prevZMaxEstimate;
+ float sceneZMax = rayZMax + 100;
+ for (vec2 P = P0;
+ ((P.x * stepDir) <= end) && (stepCount < maxSteps) &&
+ ((rayZMax < sceneZMax - zThickness) || (rayZMin > sceneZMax)) &&
+ (sceneZMax != 0);
+ P += dP, Q.z += dQ.z, k += dk, ++stepCount) {
+
+ rayZMin = prevZMaxEstimate;
+ rayZMax = (dQ.z * 0.5 + Q.z) / (dk * 0.5 + k);
+ prevZMaxEstimate = rayZMax;
+ if (rayZMin > rayZMax) {
+ float t = rayZMin; rayZMin = rayZMax; rayZMax = t;
+ }
+
+ hitPixel = permute ? P.yx : P;
+ hitPixel.y = screen_res.y - hitPixel.y;
+ // You may need hitPixel.y = screen_res.y - hitPixel.y; here if your vertical axis
+ // is different than ours in screen space
+ sceneZMax = texelFetch(depthMap, ivec2(hitPixel)).r;
+ }
+
+ // Advance Q based on the number of steps
+ Q.xy += dQ.xy * stepCount;
+ hitPoint = Q * (1.0 / k);
+ return (rayZMax >= sceneZMax - zThickness) && (rayZMin < sceneZMax);
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
index 4134220306..5dc219702d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
@@ -23,8 +23,8 @@
* $/LicenseInfo$
*/
-uniform sampler2DRect normalMap;
-uniform sampler2DRect depthMap;
+uniform sampler2D normalMap;
+uniform sampler2D depthMap;
uniform sampler2DShadow shadowMap0;
uniform sampler2DShadow shadowMap1;
uniform sampler2DShadow shadowMap2;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 4b34e55efd..152402907b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -34,11 +34,11 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect normalMap;
-uniform sampler2DRect lightMap;
-uniform sampler2DRect depthMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D normalMap;
+uniform sampler2D lightMap;
+uniform sampler2D depthMap;
uniform samplerCube environmentMap;
uniform sampler2D lightFunc;
@@ -58,6 +58,7 @@ uniform vec2 screen_res;
vec3 getNorm(vec2 pos_screen);
vec4 getPositionWithDepth(vec2 pos_screen, float depth);
+float getDepth(vec2 pos_screen);
void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao);
float getAmbientClamp();
@@ -76,9 +77,9 @@ vec4 applyWaterFogView(vec3 pos, vec4 color);
void main()
{
vec2 tc = vary_fragcoord.xy;
- float depth = texture2DRect(depthMap, tc.xy).r;
+ float depth = getDepth(tc);
vec4 pos = getPositionWithDepth(tc, depth);
- vec4 norm = texture2DRect(normalMap, tc);
+ vec4 norm = texture2D(normalMap, tc);
float envIntensity = norm.z;
norm.xyz = getNorm(tc);
@@ -87,12 +88,12 @@ void main()
float light_gamma = 1.0/1.3;
da = pow(da, light_gamma);
- vec4 diffuse = texture2DRect(diffuseRect, tc);
+ vec4 diffuse = texture2D(diffuseRect, tc);
//convert to gamma space
diffuse.rgb = linear_to_srgb(diffuse.rgb); // SL-14035
- vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
+ vec4 spec = texture2D(specularRect, vary_fragcoord.xy);
vec3 color = vec3(0);
float bloom = 0.0;
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl
index 8891315e15..23ad332db4 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl
@@ -22,8 +22,6 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
-
-uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
@@ -36,10 +34,10 @@ VARYING vec2 vary_fragcoord;
void main()
{
//transform vertex
- vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
+ vec4 pos = vec4(position.xyz, 1.0);
gl_Position = pos;
// appease OSX GLSL compiler/linker by touching all the varyings we said we would
setAtmosAttenuation(vec3(1));
setAdditiveColor(vec3(0));
- vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
+ vary_fragcoord = (pos.xy*0.5+0.5);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index 694b19cdfb..7f21a074bd 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -36,10 +36,10 @@ out vec4 frag_color;
//class 1 -- no shadows
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect depthMap;
-uniform sampler2DRect normalMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D depthMap;
+uniform sampler2D normalMap;
uniform samplerCube environmentMap;
uniform sampler2D noiseMap;
uniform sampler2D projectionMap;
@@ -137,7 +137,6 @@ void main()
vec4 frag = vary_fragcoord;
frag.xyz /= frag.w;
frag.xyz = frag.xyz*0.5+0.5;
- frag.xy *= screen_res;
vec3 pos = getPosition(frag.xy).xyz;
vec3 lv = trans_center.xyz-pos.xyz;
@@ -148,7 +147,7 @@ void main()
discard;
}
- vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+ vec3 norm = texture2D(normalMap, frag.xy).xyz;
float envIntensity = norm.z;
norm = getNorm(frag.xy);
norm = normalize(norm);
@@ -176,11 +175,11 @@ void main()
lv = normalize(lv);
float da = dot(norm, lv);
- vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
+ vec3 diff_tex = texture2D(diffuseRect, frag.xy).rgb;
//light shaders output linear and are gamma corrected later in postDeferredGammaCorrectF.glsl
diff_tex.rgb = srgb_to_linear(diff_tex.rgb);
- vec4 spec = texture2DRect(specularRect, frag.xy);
+ vec4 spec = texture2D(specularRect, frag.xy);
float noise = texture2D(noiseMap, frag.xy/128.0).b;
vec3 dlit = vec3(0, 0, 0);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
index 15f141cbe5..d9a0b6c702 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
@@ -35,7 +35,7 @@ out vec4 frag_color;
//class 1 -- no shadow, SSAO only
-uniform sampler2DRect normalMap;
+uniform sampler2D normalMap;
// Inputs
VARYING vec2 vary_fragcoord;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl
index 473d6df8fa..9d70b9d98d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl
@@ -22,8 +22,6 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
-
-uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
@@ -34,8 +32,8 @@ uniform vec2 screen_res;
void main()
{
//transform vertex
- vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
+ vec4 pos = vec4(position.xyz, 1.0);
gl_Position = pos;
- vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res;
+ vary_fragcoord = (pos.xy * 0.5 + 0.5);
}
diff --git a/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl b/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl
index 36563982ba..4e535f7e18 100644
--- a/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl
+++ b/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl
@@ -33,7 +33,7 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect diffuseMap;
+uniform sampler2D diffuseMap;
uniform float minLuminance;
uniform float maxExtractAlpha;
uniform vec3 lumWeights;
@@ -44,7 +44,7 @@ VARYING vec2 vary_texcoord0;
void main()
{
- vec4 col = texture2DRect(diffuseMap, vary_texcoord0.xy);
+ vec4 col = texture2D(diffuseMap, vary_texcoord0.xy);
/// CALCULATING LUMINANCE (Using NTSC lum weights)
/// http://en.wikipedia.org/wiki/Luma_%28video%29
float lum = smoothstep(minLuminance, minLuminance+1.0, dot(col.rgb, lumWeights ) );
diff --git a/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl b/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl
index 1396dc6973..db0662ad89 100644
--- a/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl
+++ b/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl
@@ -32,7 +32,7 @@ VARYING vec2 vary_texcoord0;
void main()
{
- gl_Position = modelview_projection_matrix * vec4(position, 1.0);
+ gl_Position = vec4(position, 1.0);
- vary_texcoord0.xy = texcoord0;
+ vary_texcoord0.xy = position.xy * 0.5 + 0.5;
}
diff --git a/indra/newview/app_settings/shaders/class1/effects/glowV.glsl b/indra/newview/app_settings/shaders/class1/effects/glowV.glsl
index cdb2281578..ea66e8271b 100644
--- a/indra/newview/app_settings/shaders/class1/effects/glowV.glsl
+++ b/indra/newview/app_settings/shaders/class1/effects/glowV.glsl
@@ -37,7 +37,7 @@ VARYING vec4 vary_texcoord3;
void main()
{
- gl_Position = modelview_projection_matrix * vec4(position, 1.0);
+ gl_Position = vec4(position, 1.0);
vary_texcoord0.xy = texcoord0 + glowDelta*(-3.5);
vary_texcoord1.xy = texcoord0 + glowDelta*(-2.5);
diff --git a/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl
index 011b3c8643..4a0bb3fe98 100644
--- a/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl
@@ -68,7 +68,6 @@ vec4 applyWaterFogView(vec3 pos, vec4 color)
float D = pow(0.98, l*kd);
color.rgb = color.rgb * D + kc.rgb * L;
- color.a = kc.a + color.a;
return color;
}
@@ -114,7 +113,6 @@ vec4 applyWaterFogViewLinear(vec3 pos, vec4 color)
float D = pow(0.98, l * kd);
color.rgb = color.rgb * D + kc.rgb * L;
- color.a = kc.a + color.a;
return color;
}
@@ -122,6 +120,6 @@ vec4 applyWaterFogViewLinear(vec3 pos, vec4 color)
vec4 applyWaterFog(vec4 color)
{
//normalize view vector
- return applyWaterFogView(getPositionEye(), color);
+ return applyWaterFogViewLinear(getPositionEye(), color);
}
diff --git a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl
index cff8d9d50f..99662097bb 100644
--- a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl
@@ -33,7 +33,7 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect depthMap;
+uniform sampler2D depthMap;
VARYING vec2 tc0;
VARYING vec2 tc1;
@@ -48,22 +48,22 @@ VARYING vec2 tc8;
void main()
{
vec4 depth1 =
- vec4(texture2DRect(depthMap, tc0).r,
- texture2DRect(depthMap, tc1).r,
- texture2DRect(depthMap, tc2).r,
- texture2DRect(depthMap, tc3).r);
+ vec4(texture2D(depthMap, tc0).r,
+ texture2D(depthMap, tc1).r,
+ texture2D(depthMap, tc2).r,
+ texture2D(depthMap, tc3).r);
vec4 depth2 =
- vec4(texture2DRect(depthMap, tc4).r,
- texture2DRect(depthMap, tc5).r,
- texture2DRect(depthMap, tc6).r,
- texture2DRect(depthMap, tc7).r);
+ vec4(texture2D(depthMap, tc4).r,
+ texture2D(depthMap, tc5).r,
+ texture2D(depthMap, tc6).r,
+ texture2D(depthMap, tc7).r);
depth1 = min(depth1, depth2);
float depth = min(depth1.x, depth1.y);
depth = min(depth, depth1.z);
depth = min(depth, depth1.w);
- depth = min(depth, texture2DRect(depthMap, tc8).r);
+ depth = min(depth, texture2D(depthMap, tc8).r);
gl_FragDepth = depth;
}
diff --git a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthV.glsl b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthV.glsl
index 71d80911d6..e104377037 100644
--- a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthV.glsl
@@ -45,7 +45,7 @@ void main()
{
gl_Position = vec4(position, 1.0);
- vec2 tc = (position.xy*0.5+0.5)*screen_res;
+ vec2 tc = (position.xy*0.5+0.5);
tc0 = tc+vec2(-delta.x,-delta.y);
tc1 = tc+vec2(0,-delta.y);
tc2 = tc+vec2(delta.x,-delta.y);
diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl
index b5bbbb5c73..0b4680767a 100644
--- a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl
@@ -34,7 +34,7 @@ out vec4 frag_color;
#endif
uniform sampler2D glowMap;
-uniform sampler2DRect screenMap;
+uniform sampler2D screenMap;
VARYING vec2 vary_texcoord0;
VARYING vec2 vary_texcoord1;
@@ -42,5 +42,5 @@ VARYING vec2 vary_texcoord1;
void main()
{
frag_color = texture2D(glowMap, vary_texcoord0.xy) +
- texture2DRect(screenMap, vary_texcoord1.xy);
+ texture2D(screenMap, vary_texcoord1.xy);
}
diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl
index a9e7ea1de8..6a4c2ca623 100644
--- a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl
@@ -33,14 +33,14 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect diffuseRect;
+uniform sampler2D diffuseRect;
uniform vec2 screen_res;
VARYING vec2 vary_tc;
void main()
{
- vec3 col = texture2DRect(diffuseRect, vary_tc*screen_res).rgb;
+ vec3 col = texture2D(diffuseRect, vary_tc).rgb;
frag_color = vec4(col.rgb, dot(col.rgb, vec3(0.299, 0.587, 0.144)));
}
diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl
index 058f3b1b82..48aab1ce21 100644
--- a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl
@@ -23,7 +23,6 @@
* $/LicenseInfo$
*/
-uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
@@ -31,7 +30,7 @@ VARYING vec2 vary_tc;
void main()
{
- vec4 pos = modelview_projection_matrix*vec4(position.xyz, 1.0);
+ vec4 pos = vec4(position.xyz, 1.0);
gl_Position = pos;
vary_tc = pos.xy*0.5+0.5;
diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl
index f7970b7f78..e08284f762 100644
--- a/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl
@@ -34,7 +34,7 @@ VARYING vec2 vary_texcoord1;
void main()
{
- gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+ gl_Position = vec4(position.xyz, 1.0);
vary_texcoord0 = texcoord0;
vary_texcoord1 = texcoord1;
}
diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl
index 839e10ce5e..858052281b 100644
--- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl
@@ -36,6 +36,7 @@ VARYING vec3 vary_dir;
//uniform float roughness;
uniform float mipLevel;
+uniform int u_width;
// =============================================================================================================
// Parts of this file are (c) 2018 Sascha Willems
@@ -124,7 +125,7 @@ vec4 prefilterEnvMap(vec3 R)
vec3 V = R;
vec4 color = vec4(0.0);
float totalWeight = 0.0;
- float envMapDim = 128.0;
+ float envMapDim = u_width;
int numSamples = 4;
float numMips = 6.0;
diff --git a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl
index f0d579f85e..a9c28b2974 100644
--- a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl
@@ -35,8 +35,8 @@ out vec4 frag_color;
// NOTE screenMap should always be texture channel 0 and
// depthmap should always be channel 1
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect depthMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D depthMap;
uniform float resScale;
uniform float znear;
@@ -76,26 +76,25 @@ void main()
for (int i = 0; i < 9; ++i)
{
- color += texture2DRect(screenMap, vary_texcoord0.xy+tc[i]).rgb * w[i];
- //color += texture2DRect(screenMap, vary_texcoord0.xy+tc[i]*2.0).rgb * w[i]*0.5;
+ color += texture2D(screenMap, vary_texcoord0.xy+tc[i]).rgb * w[i];
+ //color += texture2D(screenMap, vary_texcoord0.xy+tc[i]*2.0).rgb * w[i]*0.5;
}
//color /= wsum;
frag_color = vec4(color, 1.0);
#else
- vec2 depth_tc = vary_texcoord0.xy * resScale;
- float depth = texture(depthMap, depth_tc).r;
+ float depth = texture(depthMap, vary_texcoord0.xy).r;
float dist = linearDepth(depth, znear, zfar);
// convert linear depth to distance
vec3 v;
- v.xy = depth_tc / 256.0 * 2.0 - 1.0;
+ v.xy = vary_texcoord0.xy / 512.0 * 2.0 - 1.0;
v.z = 1.0;
v = normalize(v);
dist /= v.z;
- vec3 col = texture2DRect(diffuseRect, vary_texcoord0.xy).rgb;
+ vec3 col = texture2D(diffuseRect, vary_texcoord0.xy).rgb;
frag_color = vec4(col, dist/256.0);
#endif
}
diff --git a/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl b/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl
index 7614075cfd..bf6c1b355c 100644
--- a/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl
@@ -33,12 +33,12 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect screenMap;
+uniform sampler2D screenMap;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
void main()
{
- frag_color = texture2DRect(screenMap, vary_texcoord0.xy) * vertex_color;
+ frag_color = texture2D(screenMap, vary_texcoord0.xy) * vertex_color;
}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
index e255c78b86..25b0a0b970 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
@@ -180,7 +180,6 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec
void main()
{
vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
- frag *= screen_res;
vec4 pos = vec4(vary_position, 1.0);
#ifndef IS_AVATAR_SKIN
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index 1b7a1cc6ec..24068c04b5 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -34,12 +34,12 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect depthMap;
-uniform sampler2DRect normalMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D depthMap;
+uniform sampler2D normalMap;
uniform samplerCube environmentMap;
-uniform sampler2DRect lightMap;
+uniform sampler2D lightMap;
uniform sampler2D noiseMap;
uniform sampler2D projectionMap;
uniform sampler2D lightFunc;
@@ -138,7 +138,6 @@ void main()
vec4 frag = vary_fragcoord;
frag.xyz /= frag.w;
frag.xyz = frag.xyz*0.5+0.5;
- frag.xy *= screen_res;
vec3 pos = getPosition(frag.xy).xyz;
vec3 lv = center.xyz-pos.xyz;
@@ -154,13 +153,13 @@ void main()
if (proj_shadow_idx >= 0)
{
- vec4 shd = texture2DRect(lightMap, frag.xy);
+ vec4 shd = texture2D(lightMap, frag.xy);
shadow = (proj_shadow_idx==0)?shd.b:shd.a;
shadow += shadow_fade;
shadow = clamp(shadow, 0.0, 1.0);
}
- vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+ vec3 norm = texture2D(normalMap, frag.xy).xyz;
float envIntensity = norm.z;
@@ -190,9 +189,9 @@ void main()
lv = normalize(lv);
float da = dot(norm, lv);
- vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
+ vec3 diff_tex = texture2D(diffuseRect, frag.xy).rgb;
- vec4 spec = texture2DRect(specularRect, frag.xy);
+ vec4 spec = texture2D(specularRect, frag.xy);
vec3 dlit = vec3(0, 0, 0);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
index 6500c4bb1f..d81102991e 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
@@ -35,7 +35,7 @@ uniform float roughnessFactor;
uniform vec3 emissiveColor;
#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO)
-uniform sampler2DRect lightMap;
+uniform sampler2D lightMap;
#endif
uniform int sun_up_factor;
@@ -189,7 +189,6 @@ void main()
#ifdef HAS_SUN_SHADOW
vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
- frag *= screen_res;
scol = sampleDirectionalShadow(pos.xyz, norm.xyz, frag);
#endif
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 677c9c244c..fab227f5a4 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -34,11 +34,11 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect normalMap;
-uniform sampler2DRect lightMap;
-uniform sampler2DRect depthMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D normalMap;
+uniform sampler2D lightMap;
+uniform sampler2D depthMap;
uniform samplerCube environmentMap;
uniform sampler2D lightFunc;
@@ -58,6 +58,7 @@ uniform vec2 screen_res;
vec3 getNorm(vec2 pos_screen);
vec4 getPositionWithDepth(vec2 pos_screen, float depth);
+float getDepth(vec2 pos_screen);
void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao);
float getAmbientClamp();
@@ -76,9 +77,9 @@ vec4 applyWaterFogView(vec3 pos, vec4 color);
void main()
{
vec2 tc = vary_fragcoord.xy;
- float depth = texture2DRect(depthMap, tc.xy).r;
+ float depth = getDepth(tc.xy);
vec4 pos = getPositionWithDepth(tc, depth);
- vec4 norm = texture2DRect(normalMap, tc);
+ vec4 norm = texture2D(normalMap, tc);
float envIntensity = norm.z;
norm.xyz = getNorm(tc);
@@ -87,11 +88,11 @@ void main()
float light_gamma = 1.0 / 1.3;
da = pow(da, light_gamma);
- vec4 diffuse = texture2DRect(diffuseRect, tc);
+ vec4 diffuse = texture2D(diffuseRect, tc);
diffuse.rgb = linear_to_srgb(diffuse.rgb); // SL-14035
- vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
+ vec4 spec = texture2D(specularRect, vary_fragcoord.xy);
- vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
+ vec2 scol_ambocc = texture2D(lightMap, vary_fragcoord.xy).rg;
scol_ambocc = pow(scol_ambocc, vec2(light_gamma));
float scol = max(scol_ambocc.r, diffuse.a);
float ambocc = scol_ambocc.g;
@@ -153,6 +154,6 @@ void main()
// convert to linear as fullscreen lights need to sum in linear colorspace
// and will be gamma (re)corrected downstream...
- frag_color.rgb = srgb_to_linear(color.rgb);
+ frag_color.rgb = pos.xyz;// srgb_to_linear(color.rgb);
frag_color.a = bloom;
}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl
index bd11aa3f05..1e7ccb747a 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl
@@ -23,8 +23,6 @@
* $/LicenseInfo$
*/
-uniform mat4 modelview_projection_matrix;
-
ATTRIBUTE vec3 position;
uniform vec2 screen_res;
@@ -38,12 +36,12 @@ void setAdditiveColor(vec3 c);
void main()
{
//transform vertex
- vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
+ vec4 pos = vec4(position.xyz, 1.0);
gl_Position = pos;
// appease OSX GLSL compiler/linker by touching all the varyings we said we would
setAtmosAttenuation(vec3(1));
setAdditiveColor(vec3(0));
- vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
+ vary_fragcoord = (pos.xy*0.5+0.5);
}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
index 774f537821..c41b7b210c 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -34,12 +34,12 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect depthMap;
-uniform sampler2DRect normalMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D depthMap;
+uniform sampler2D normalMap;
uniform samplerCube environmentMap;
-uniform sampler2DRect lightMap;
+uniform sampler2D lightMap;
uniform sampler2D noiseMap;
uniform sampler2D projectionMap;
uniform sampler2D lightFunc;
@@ -138,7 +138,6 @@ void main()
vec4 frag = vary_fragcoord;
frag.xyz /= frag.w;
frag.xyz = frag.xyz*0.5+0.5;
- frag.xy *= screen_res;
vec3 pos = getPosition(frag.xy).xyz;
vec3 lv = trans_center.xyz-pos.xyz;
@@ -154,13 +153,13 @@ void main()
if (proj_shadow_idx >= 0)
{
- vec4 shd = texture2DRect(lightMap, frag.xy);
+ vec4 shd = texture2D(lightMap, frag.xy);
shadow = (proj_shadow_idx == 0) ? shd.b : shd.a;
shadow += shadow_fade;
shadow = clamp(shadow, 0.0, 1.0);
}
- vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+ vec3 norm = texture2D(normalMap, frag.xy).xyz;
float envIntensity = norm.z;
norm = getNorm(frag.xy);
@@ -189,8 +188,8 @@ void main()
lv = normalize(lv);
float da = dot(norm, lv);
- vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
- vec4 spec = texture2DRect(specularRect, frag.xy);
+ vec3 diff_tex = texture2D(diffuseRect, frag.xy).rgb;
+ vec4 spec = texture2D(specularRect, frag.xy);
vec3 dlit = vec3(0, 0, 0);
float noise = texture2D(noiseMap, frag.xy/128.0).b;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl
index bc5eb5181d..3dfca0f655 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl
@@ -23,8 +23,6 @@
* $/LicenseInfo$
*/
-uniform mat4 modelview_projection_matrix;
-
ATTRIBUTE vec3 position;
VARYING vec2 vary_fragcoord;
@@ -34,8 +32,8 @@ uniform vec2 screen_res;
void main()
{
//transform vertex
- vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
+ vec4 pos = vec4(position.xyz, 1.0);
gl_Position = pos;
- vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res;
+ vary_fragcoord = (pos.xy * 0.5 + 0.5);
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
index 6dd446d9f7..43327be49f 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
@@ -33,10 +33,10 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect depthMap;
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
+uniform sampler2D depthMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
uniform sampler2D noiseMap;
uniform sampler2D lightFunc;
@@ -57,6 +57,7 @@ float calcLegacyDistanceAttenuation(float distance, float falloff);
vec4 getPosition(vec2 pos_screen);
vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensity);
vec2 getScreenXY(vec4 clip);
+vec2 getScreenCoord(vec4 clip);
vec3 srgb_to_linear(vec3 c);
// Util
@@ -76,7 +77,7 @@ void main()
discard; // Bail immediately
#else
vec3 final_color = vec3(0, 0, 0);
- vec2 tc = getScreenXY(vary_fragcoord);
+ vec2 tc = getScreenCoord(vary_fragcoord);
vec3 pos = getPosition(tc).xyz;
if (pos.z < far_z)
{
@@ -87,15 +88,15 @@ void main()
vec3 n;
vec4 norm = getNormalEnvIntensityFlags(tc, n, envIntensity); // need `norm.w` for GET_GBUFFER_FLAG()
- vec4 spec = texture2DRect(specularRect, tc);
- vec3 diffuse = texture2DRect(diffuseRect, tc).rgb;
+ vec4 spec = texture2D(specularRect, tc);
+ vec3 diffuse = texture2D(diffuseRect, tc).rgb;
vec3 h, l, v = -normalize(pos);
float nh, nv, vh, lightDist;
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
{
- vec3 colorEmissive = texture2DRect(emissiveRect, tc).rgb;
+ vec3 colorEmissive = texture2D(emissiveRect, tc).rgb;
vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightV.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightV.glsl
index ad6a0fa752..831b3b2684 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightV.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightV.glsl
@@ -23,8 +23,6 @@
* $/LicenseInfo$
*/
-uniform mat4 modelview_projection_matrix;
-
ATTRIBUTE vec3 position;
VARYING vec4 vary_fragcoord;
@@ -32,7 +30,7 @@ VARYING vec4 vary_fragcoord;
void main()
{
//transform vertex
- vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
+ vec4 pos = vec4(position.xyz, 1.0);
vary_fragcoord = pos;
gl_Position = pos;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
index cb8877ebe5..4a172f7a10 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
@@ -34,13 +34,13 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect depthMap;
-uniform sampler2DRect normalMap;
-uniform sampler2DRect emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D depthMap;
+uniform sampler2D normalMap;
+uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
uniform samplerCube environmentMap;
-uniform sampler2DRect lightMap;
+uniform sampler2D lightMap;
uniform sampler2D noiseMap;
uniform sampler2D projectionMap; // rgba
uniform sampler2D lightFunc;
@@ -82,6 +82,7 @@ vec3 getProjectedLightAmbiance(float amb_da, float attenuation, float lit, float
vec3 getProjectedLightDiffuseColor(float light_distance, vec2 projected_uv );
vec3 getProjectedLightSpecularColor(vec3 pos, vec3 n);
vec2 getScreenXY(vec4 clip);
+vec2 getScreenCoord(vec4 clip);
vec3 srgb_to_linear(vec3 cs);
vec4 texture2DLodSpecular(vec2 tc, float lod);
@@ -102,7 +103,7 @@ void main()
discard;
#else
vec3 final_color = vec3(0,0,0);
- vec2 tc = getScreenXY(vary_fragcoord);
+ vec2 tc = getScreenCoord(vary_fragcoord);
vec3 pos = getPosition(tc).xyz;
vec3 lv;
@@ -117,7 +118,7 @@ void main()
if (proj_shadow_idx >= 0)
{
- vec4 shd = texture2DRect(lightMap, tc);
+ vec4 shd = texture2D(lightMap, tc);
shadow = (proj_shadow_idx==0)?shd.b:shd.a;
shadow += shadow_fade;
shadow = clamp(shadow, 0.0, 1.0);
@@ -138,8 +139,8 @@ void main()
float nh, nl, nv, vh, lightDist;
calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist);
- vec3 diffuse = texture2DRect(diffuseRect, tc).rgb;
- vec4 spec = texture2DRect(specularRect, tc);
+ vec3 diffuse = texture2D(diffuseRect, tc).rgb;
+ vec4 spec = texture2D(specularRect, tc);
vec3 dlit = vec3(0, 0, 0);
vec3 slit = vec3(0, 0, 0);
@@ -147,7 +148,7 @@ void main()
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
{
- vec3 colorEmissive = texture2DRect(emissiveRect, tc).rgb;
+ vec3 colorEmissive = texture2D(emissiveRect, tc).rgb;
vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
index cdffcf103d..0c8baab14f 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
@@ -33,13 +33,13 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect normalMap;
-uniform sampler2DRect emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D normalMap;
+uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
uniform sampler2D noiseMap;
uniform sampler2D lightFunc;
-uniform sampler2DRect depthMap;
+uniform sampler2D depthMap;
uniform vec3 env_mat[3];
uniform float sun_wash;
@@ -62,7 +62,9 @@ float calcLegacyDistanceAttenuation(float distance, float falloff);
vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensity);
vec4 getPosition(vec2 pos_screen);
vec2 getScreenXY(vec4 clip);
+vec2 getScreenCoord(vec4 clip);
vec3 srgb_to_linear(vec3 c);
+float getDepth(vec2 tc);
vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
@@ -74,15 +76,15 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
void main()
{
vec3 final_color = vec3(0);
- vec2 tc = getScreenXY(vary_fragcoord);
+ vec2 tc = getScreenCoord(vary_fragcoord);
vec3 pos = getPosition(tc).xyz;
float envIntensity;
vec3 n;
vec4 norm = getNormalEnvIntensityFlags(tc, n, envIntensity); // need `norm.w` for GET_GBUFFER_FLAG()
- vec3 diffuse = texture2DRect(diffuseRect, tc).rgb;
- vec4 spec = texture2DRect(specularRect, tc);
+ vec3 diffuse = texture2D(diffuseRect, tc).rgb;
+ vec4 spec = texture2D(specularRect, tc);
// Common half vectors calcs
vec3 lv = trans_center.xyz-pos;
@@ -99,7 +101,7 @@ void main()
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
{
- vec3 colorEmissive = texture2DRect(emissiveRect, tc).rgb;
+ vec3 colorEmissive = texture2D(emissiveRect, tc).rgb;
vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl
new file mode 100644
index 0000000000..9172789b38
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl
@@ -0,0 +1,98 @@
+/**
+ * @file class3/deferred/screenSpaceReflPostF.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$
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+
+/*[EXTRA_CODE_HERE]*/
+
+#ifdef DEFINE_GL_FRAGCOLOR
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor
+#endif
+
+uniform vec2 screen_res;
+uniform mat4 projection_matrix;
+uniform mat4 inv_proj;
+uniform float zNear;
+uniform float zFar;
+
+VARYING vec2 vary_fragcoord;
+VARYING vec3 camera_ray;
+
+uniform sampler2D depthMap;
+uniform sampler2D normalMap;
+uniform sampler2D sceneMap;
+uniform sampler2D diffuseRect;
+
+vec3 getNorm(vec2 screenpos);
+float getDepth(vec2 pos_screen);
+float linearDepth(float d, float znear, float zfar);
+float linearDepth01(float d, float znear, float zfar);
+
+vec4 getPositionWithDepth(vec2 pos_screen, float depth);
+vec4 getPosition(vec2 pos_screen);
+
+bool traceScreenRay(vec3 position, vec3 reflection, out vec3 hitColor, out float hitDepth, float depth, sampler2D textureFrame);
+float random (vec2 uv);
+void main() {
+ vec2 tc = vary_fragcoord.xy;
+ float depth = linearDepth01(getDepth(tc), zNear, zFar);
+ vec3 pos = getPositionWithDepth(tc, getDepth(tc)).xyz;
+ vec3 viewPos = camera_ray * depth;
+ vec3 rayDirection = normalize(reflect(normalize(viewPos), getNorm(tc))) * -viewPos.z;
+ vec2 hitpixel;
+ vec3 hitpoint;
+
+ vec2 uv2 = tc * screen_res;
+ float c = (uv2.x + uv2.y) * 0.125;
+ float jitter = mod( c, 1.0);
+
+ vec3 firstBasis = normalize(cross(vec3(0.f, 0.f, 1.f), rayDirection));
+ vec3 secondBasis = normalize(cross(rayDirection, firstBasis));
+
+ frag_color.rgb = texture(diffuseRect, tc).rgb;
+ vec4 collectedColor;
+ for (int i = 0; i < 1; i++) {
+ vec2 coeffs = vec2(random(tc + vec2(0, i)) + random(tc + vec2(i, 0))) * 0.25;
+ vec3 reflectionDirectionRandomized = rayDirection + firstBasis * coeffs.x + secondBasis * coeffs.y;
+
+ bool hit = traceScreenRay(pos, reflectionDirectionRandomized, hitpoint, depth, depth, diffuseRect);
+ if (hit) {
+ vec2 screenpos = tc * 2 - 1;
+ float vignette = 1;// clamp((1 - dot(screenpos, screenpos)) * 4,0, 1);
+ vignette *= dot(normalize(viewPos), getNorm(tc)) * 0.5 + 0.5;
+ vignette *= min(linearDepth(getDepth(tc), zNear, zFar) / (zFar * 0.0125), 1);
+ collectedColor.rgb = hitpoint * vignette * 0.25;
+ frag_color.rgb = hitpoint;
+ }
+ }
+
+ //frag_color.rgb = collectedColor.rgb;
+
+
+
+ frag_color.a = 1.0;
+}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostV.glsl b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostV.glsl
new file mode 100644
index 0000000000..b084094d4d
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostV.glsl
@@ -0,0 +1,48 @@
+/**
+ * @file class3/deferred/screenSpaceReflPostV.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;
+uniform mat4 inv_proj;
+
+ATTRIBUTE vec3 position;
+
+uniform vec2 screen_res;
+
+VARYING vec2 vary_fragcoord;
+VARYING vec3 camera_ray;
+
+
+void main()
+{
+ //transform vertex
+ vec4 pos = vec4(position.xyz, 1.0);
+ gl_Position = pos;
+
+ vary_fragcoord = pos.xy * 0.5 + 0.5;
+
+ vec4 rayOrig = inv_proj * vec4(pos.xy, 1, 1);
+ camera_ray = rayOrig.xyz / rayOrig.w;
+
+}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl
new file mode 100644
index 0000000000..5eefd99d00
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflUtil.glsl
@@ -0,0 +1,138 @@
+/**
+ * @file class3/deferred/screenSpaceReflUtil.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 sampler2D depthMap;
+uniform sampler2D normalMap;
+uniform sampler2D sceneMap;
+uniform vec2 screen_res;
+uniform mat4 projection_matrix;
+uniform float zNear;
+uniform float zFar;
+uniform mat4 inv_proj;
+
+vec4 getPositionWithDepth(vec2 pos_screen, float depth);
+float linearDepth(float depth, float near, float far);
+float getDepth(vec2 pos_screen);
+float linearDepth01(float d, float znear, float zfar);
+
+float random (vec2 uv) {
+ return fract(sin(dot(uv, vec2(12.9898, 78.233))) * 43758.5453123); //simple random function
+}
+
+// Based off of https://github.com/RoundedGlint585/ScreenSpaceReflection/
+// A few tweaks here and there to suit our needs.
+
+vec2 generateProjectedPosition(vec3 pos){
+ vec4 samplePosition = projection_matrix * vec4(pos, 1.f);
+ samplePosition.xy = (samplePosition.xy / samplePosition.w) * 0.5 + 0.5;
+ return samplePosition.xy;
+}
+
+bool isBinarySearchEnabled = true;
+bool isAdaptiveStepEnabled = true;
+bool isExponentialStepEnabled = false;
+bool debugDraw = false;
+int iterationCount = 100;
+float rayStep = 0.2;
+float distanceBias = 0.05;
+float depthRejectBias = 0.001;
+float epsilon = 0.1;
+
+bool traceScreenRay(vec3 position, vec3 reflection, out vec3 hitColor, out float hitDepth, float depth, sampler2D textureFrame) {
+ vec3 step = rayStep * reflection;
+ vec3 marchingPosition = position + step;
+ float delta;
+ float depthFromScreen;
+ vec2 screenPosition;
+ bool hit = false;
+ hitColor = vec3(0);
+
+ int i = 0;
+ if (depth > depthRejectBias) {
+ for (; i < iterationCount && !hit; i++) {
+ screenPosition = generateProjectedPosition(marchingPosition);
+ depthFromScreen = abs(getPositionWithDepth(screenPosition, linearDepth(getDepth(screenPosition), zNear, zFar)).z);
+ delta = abs(marchingPosition.z) - depthFromScreen;
+
+ if (depth < depthFromScreen + epsilon && depth > depthFromScreen - epsilon) {
+ break;
+ }
+
+ if (abs(delta) < distanceBias) {
+ vec3 color = vec3(1);
+ if(debugDraw)
+ color = vec3( 0.5+ sign(delta)/2,0.3,0.5- sign(delta)/2);
+ hitColor = texture(textureFrame, screenPosition).xyz * color;
+ hitDepth = depthFromScreen;
+ hit = true;
+ break;
+ }
+ if (isBinarySearchEnabled && delta > 0) {
+ break;
+ }
+ if (isAdaptiveStepEnabled){
+ float directionSign = sign(abs(marchingPosition.z) - depthFromScreen);
+ //this is sort of adapting step, should prevent lining reflection by doing sort of iterative converging
+ //some implementation doing it by binary search, but I found this idea more cheaty and way easier to implement
+ step = step * (1.0 - rayStep * max(directionSign, 0.0));
+ marchingPosition += step * (-directionSign);
+ }
+ else {
+ marchingPosition += step;
+ }
+
+ if (isExponentialStepEnabled){
+ step *= 1.05;
+ }
+ }
+ if(isBinarySearchEnabled){
+ for(; i < iterationCount && !hit; i++){
+
+ step *= 0.5;
+ marchingPosition = marchingPosition - step * sign(delta);
+
+ screenPosition = generateProjectedPosition(marchingPosition);
+ depthFromScreen = abs(getPositionWithDepth(screenPosition, getDepth(screenPosition)).z);
+ delta = abs(marchingPosition.z) - depthFromScreen;
+
+ if (depth < depthFromScreen + epsilon && depth > depthFromScreen - epsilon) {
+ break;
+ }
+
+ if (abs(delta) < distanceBias && depthFromScreen != (depth - distanceBias)) {
+ vec3 color = vec3(1);
+ if(debugDraw)
+ color = vec3( 0.5+ sign(delta)/2,0.3,0.5- sign(delta)/2);
+ hitColor = texture(textureFrame, screenPosition).xyz * color;
+ hitDepth = depthFromScreen;
+ hit = true;
+ break;
+ }
+ }
+ }
+ }
+
+ return hit;
+}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 879f4ef510..5f6982746b 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -37,19 +37,19 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect normalMap;
-uniform sampler2DRect emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D normalMap;
+uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
uniform sampler2D altDiffuseMap; // PBR: irradiance, skins/default/textures/default_irradiance.png
const float M_PI = 3.14159265;
#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO)
-uniform sampler2DRect lightMap;
+uniform sampler2D lightMap;
#endif
-uniform sampler2DRect depthMap;
+uniform sampler2D depthMap;
uniform sampler2D lightFunc;
uniform float blur_size;
@@ -81,6 +81,7 @@ void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout
vec3 pos, vec3 norm, float glossiness, float envIntensity);
void applyGlossEnv(inout vec3 color, vec3 glossenv, vec4 spec, vec3 pos, vec3 norm);
void applyLegacyEnv(inout vec3 color, vec3 legacyenv, vec4 spec, vec3 pos, vec3 norm, float envIntensity);
+float getDepth(vec2 pos_screen);
vec3 linear_to_srgb(vec3 c);
vec3 srgb_to_linear(vec3 c);
@@ -118,18 +119,18 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
void main()
{
vec2 tc = vary_fragcoord.xy;
- float depth = texture2DRect(depthMap, tc.xy).r;
+ float depth = getDepth(tc.xy);
vec4 pos = getPositionWithDepth(tc, depth);
- vec4 norm = texture2DRect(normalMap, tc);
+ vec4 norm = texture2D(normalMap, tc);
float envIntensity = norm.z;
norm.xyz = getNorm(tc);
vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
- vec4 baseColor = texture2DRect(diffuseRect, tc);
- vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); // NOTE: PBR linear Emissive
+ vec4 baseColor = texture2D(diffuseRect, tc);
+ vec4 spec = texture2D(specularRect, vary_fragcoord.xy); // NOTE: PBR linear Emissive
#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO)
- vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
+ vec2 scol_ambocc = texture2D(lightMap, vary_fragcoord.xy).rg;
#endif
#if defined(HAS_SUN_SHADOW)
@@ -155,12 +156,12 @@ void main()
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
{
- vec3 orm = texture2DRect(specularRect, tc).rgb;
+ vec3 orm = texture2D(specularRect, tc).rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
float ao = orm.r * ambocc;
- vec3 colorEmissive = texture2DRect(emissiveRect, tc).rgb;
+ vec3 colorEmissive = texture2D(emissiveRect, tc).rgb;
// PBR IBL
float gloss = 1.0 - perceptualRoughness;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
index 3274153a46..8618159313 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
@@ -44,13 +44,13 @@ out vec4 frag_color;
#define frag_color gl_FragColor
#endif
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect depthMap;
-uniform sampler2DRect normalMap;
-uniform sampler2DRect emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D depthMap;
+uniform sampler2D normalMap;
+uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
uniform samplerCube environmentMap;
-uniform sampler2DRect lightMap;
+uniform sampler2D lightMap;
uniform sampler2D noiseMap;
uniform sampler2D projectionMap; // rgba
uniform sampler2D lightFunc;
@@ -90,6 +90,7 @@ vec3 getProjectedLightAmbiance(float amb_da, float attenuation, float lit, float
vec3 getProjectedLightDiffuseColor(float light_distance, vec2 projected_uv );
vec3 getProjectedLightSpecularColor(vec3 pos, vec3 n);
vec2 getScreenXY(vec4 clip_point);
+vec2 getScreenCoord(vec4 clip_point);
vec3 srgb_to_linear(vec3 c);
vec4 texture2DLodSpecular(vec2 tc, float lod);
@@ -110,7 +111,7 @@ void main()
discard;
#else
vec3 final_color = vec3(0,0,0);
- vec2 tc = getScreenXY(vary_fragcoord);
+ vec2 tc = getScreenCoord(vary_fragcoord);
vec3 pos = getPosition(tc).xyz;
vec3 lv;
@@ -125,7 +126,7 @@ void main()
if (proj_shadow_idx >= 0)
{
- vec4 shd = texture2DRect(lightMap, tc);
+ vec4 shd = texture2D(lightMap, tc);
shadow = (proj_shadow_idx == 0) ? shd.b : shd.a;
shadow += shadow_fade;
shadow = clamp(shadow, 0.0, 1.0);
@@ -146,15 +147,15 @@ void main()
float nh, nl, nv, vh, lightDist;
calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist);
- vec3 diffuse = texture2DRect(diffuseRect, tc).rgb;
- vec4 spec = texture2DRect(specularRect, tc);
+ vec3 diffuse = texture2D(diffuseRect, tc).rgb;
+ vec4 spec = texture2D(specularRect, tc);
vec3 dlit = vec3(0, 0, 0);
vec3 slit = vec3(0, 0, 0);
vec3 amb_rgb = vec3(0);
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
{
- vec3 colorEmissive = texture2DRect(emissiveRect, tc).rgb;
+ vec3 colorEmissive = texture2D(emissiveRect, tc).rgb;
vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 66316a18d4..f3f512a6f2 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -107,6 +107,7 @@
#include "llscenemonitor.h"
#include "llavatarrenderinfoaccountant.h"
#include "lllocalbitmaps.h"
+#include "llgltfmateriallist.h"
// Linden library includes
#include "llavatarnamecache.h"
@@ -4705,6 +4706,8 @@ void LLAppViewer::idle()
LLDirPickerThread::clearDead();
F32 dt_raw = idle_timer.getElapsedTimeAndResetF32();
+ LLGLTFMaterialList::flushUpdates();
+
// Service the WorkQueue we use for replies from worker threads.
// Use function statics for the timeslice setting so we only have to fetch
// and convert MainWorkTime once.
diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp
index 38ec24cae8..78dba81d9a 100644
--- a/indra/newview/llglsandbox.cpp
+++ b/indra/newview/llglsandbox.cpp
@@ -815,7 +815,7 @@ void LLViewerObjectList::renderObjectBeacons()
const LLVector3 &thisline = debug_beacon.mPositionAgent;
gGL.begin(LLRender::LINES);
- gGL.color4fv(color.mV);
+ gGL.color4fv(linearColor4(color).mV);
draw_cross_lines(thisline, 2.0f, 2.0f, 50.f);
draw_line_cube(0.10f, thisline);
@@ -844,7 +844,7 @@ void LLViewerObjectList::renderObjectBeacons()
const LLVector3 &thisline = debug_beacon.mPositionAgent;
gGL.begin(LLRender::LINES);
- gGL.color4fv(debug_beacon.mColor.mV);
+ gGL.color4fv(linearColor4(debug_beacon.mColor).mV);
draw_cross_lines(thisline, 0.5f, 0.5f, 0.5f);
draw_line_cube(0.10f, thisline);
diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp
index 8e184c719d..07c6d9ff93 100644
--- a/indra/newview/llgltfmateriallist.cpp
+++ b/indra/newview/llgltfmateriallist.cpp
@@ -27,6 +27,7 @@
#include "llgltfmateriallist.h"
+#include "llagent.h"
#include "llassetstorage.h"
#include "lldispatcher.h"
#include "llfetchedgltfmaterial.h"
@@ -37,8 +38,11 @@
#include "llviewercontrol.h"
#include "llviewergenericmessage.h"
#include "llviewerobjectlist.h"
+#include "llviewerregion.h"
+#include "llviewerstats.h"
#include "llcorehttputil.h"
#include "llagent.h"
+#include "llworld.h"
#include "tinygltf/tiny_gltf.h"
#include <strstream>
@@ -51,125 +55,239 @@
LLGLTFMaterialList gGLTFMaterialList;
LLGLTFMaterialList::modify_queue_t LLGLTFMaterialList::sModifyQueue;
+LLGLTFMaterialList::apply_queue_t LLGLTFMaterialList::sApplyQueue;
+LLSD LLGLTFMaterialList::sUpdates;
const LLUUID LLGLTFMaterialList::BLANK_MATERIAL_ASSET_ID("968cbad0-4dad-d64e-71b5-72bf13ad051a");
-namespace
+#ifdef SHOW_ASSERT
+// return true if given data is (probably) valid update message for ModifyMaterialParams capability
+static bool is_valid_update(const LLSD& data)
{
- class LLGLTFMaterialOverrideDispatchHandler : public LLDispatchHandler
+ llassert(data.isMap());
+
+ U32 count = 0;
+
+ if (data.has("object_id"))
{
- LOG_CLASS(LLGLTFMaterialOverrideDispatchHandler);
- public:
- LLGLTFMaterialOverrideDispatchHandler() = default;
- ~LLGLTFMaterialOverrideDispatchHandler() override = default;
+ if (!data["object_id"].isUUID())
+ {
+ LL_WARNS() << "object_id is not a UUID" << LL_ENDL;
+ return false;
+ }
+ ++count;
+ }
+ else
+ {
+ LL_WARNS() << "Missing required parameter: object_id" << LL_ENDL;
+ return false;
+ }
- bool operator()(const LLDispatcher* dispatcher, const std::string& key, const LLUUID& invoice, const sparam_t& strings) override
+ if (data.has("side"))
+ {
+ if (!data["side"].isInteger())
{
- LL_PROFILE_ZONE_SCOPED;
- // receive override data from simulator via LargeGenericMessage
- // message should have:
- // object_id - UUID of LLViewerObject
- // side - S32 index of texture entry
- // gltf_json - String of GLTF json for override data
+ LL_WARNS() << "side is not an integer" << LL_ENDL;
+ return false;
+ }
+ if (data["side"].asInteger() < -1)
+ {
+ LL_WARNS() << "side is invalid" << LL_ENDL;
+ }
+ ++count;
+ }
+ else
+ {
+ LL_WARNS() << "Missing required parameter: side" << LL_ENDL;
+ return false;
+ }
- LLSD message;
+ if (data.has("gltf_json"))
+ {
+ if (!data["gltf_json"].isString())
+ {
+ LL_WARNS() << "gltf_json is not a string" << LL_ENDL;
+ return false;
+ }
+ ++count;
+ }
- sparam_t::const_iterator it = strings.begin();
- if (it != strings.end()) {
- const std::string& llsdRaw = *it++;
- std::istringstream llsdData(llsdRaw);
- if (!LLSDSerialize::deserialize(message, llsdData, llsdRaw.length()))
- {
- LL_WARNS() << "LLGLTFMaterialOverrideDispatchHandler: Attempted to read parameter data into LLSD but failed:" << llsdRaw << LL_ENDL;
- }
+ if (data.has("asset_id"))
+ {
+ if (!data["asset_id"].isUUID())
+ {
+ LL_WARNS() << "asset_id is not a UUID" << LL_ENDL;
+ return false;
+ }
+ ++count;
+ }
+
+ if (count < 3)
+ {
+ LL_WARNS() << "Only specified object_id and side, update won't actually change anything and is just noise" << LL_ENDL;
+ return false;
+ }
+
+ if (data.size() != count)
+ {
+ LL_WARNS() << "update data contains unrecognized parameters" << LL_ENDL;
+ return false;
+ }
+
+ return true;
+}
+#endif
+
+class LLGLTFMaterialOverrideDispatchHandler : public LLDispatchHandler
+{
+ LOG_CLASS(LLGLTFMaterialOverrideDispatchHandler);
+public:
+ LLGLTFMaterialOverrideDispatchHandler() = default;
+ ~LLGLTFMaterialOverrideDispatchHandler() override = default;
+
+ bool operator()(const LLDispatcher* dispatcher, const std::string& key, const LLUUID& invoice, const sparam_t& strings) override
+ {
+ LL_PROFILE_ZONE_SCOPED;
+ // receive override data from simulator via LargeGenericMessage
+ // message should have:
+ // object_id - UUID of LLViewerObject
+ // side - S32 index of texture entry
+ // gltf_json - String of GLTF json for override data
+
+
+ LLSD message;
+
+ sparam_t::const_iterator it = strings.begin();
+ if (it != strings.end()) {
+ const std::string& llsdRaw = *it++;
+ std::istringstream llsdData(llsdRaw);
+ if (!LLSDSerialize::deserialize(message, llsdData, llsdRaw.length()))
+ {
+ LL_WARNS() << "LLGLTFMaterialOverrideDispatchHandler: Attempted to read parameter data into LLSD but failed:" << llsdRaw << LL_ENDL;
}
+ LLGLTFMaterialList::writeCacheOverrides(message, llsdRaw);
+ }
+ else
+ {
+ // malformed message, nothing we can do to handle it
+ return false;
+ }
- LLUUID object_id = message["object_id"].asUUID();
-
- LLViewerObject * obj = gObjectList.findObject(object_id); // NOTE: null object here does NOT mean nothing to do, parse message and queue results for later
- bool clear_all = true;
+ LL::WorkQueue::ptr_t main_queue = LL::WorkQueue::getInstance("mainloop");
+ LL::WorkQueue::ptr_t general_queue = LL::WorkQueue::getInstance("General");
+
+ struct ReturnData
+ {
+ public:
+ std::vector<LLPointer<LLGLTFMaterial> > mMaterialVector;
+ std::vector<bool> mResults;
+ };
+
+ // fromJson() is performance heavy offload to a thread.
+ main_queue->postTo(
+ general_queue,
+ [message]() // Work done on general queue
+ {
+ ReturnData result;
if (message.has("sides") && message.has("gltf_json"))
{
- LLSD& sides = message["sides"];
- LLSD& gltf_json = message["gltf_json"];
+ LLSD const& sides = message.get("sides");
+ LLSD const& gltf_json = message.get("gltf_json");
if (sides.isArray() && gltf_json.isArray() &&
sides.size() != 0 &&
sides.size() == gltf_json.size())
{
- clear_all = false;
-
// message should be interpreted thusly:
/// sides is a list of face indices
// gltf_json is a list of corresponding json
// any side not represented in "sides" has no override
+ result.mResults.resize(sides.size());
+ result.mMaterialVector.resize(sides.size());
// parse json
- std::unordered_set<S32> side_set;
-
for (int i = 0; i < sides.size(); ++i)
{
LLPointer<LLGLTFMaterial> override_data = new LLGLTFMaterial();
-
- std::string gltf_json = message["gltf_json"][i].asString();
+
+ std::string gltf_json_str = gltf_json[i].asString();
std::string warn_msg, error_msg;
-
- bool success = override_data->fromJSON(gltf_json, warn_msg, error_msg);
- if (!success)
- {
- LL_WARNS() << "failed to parse GLTF override data. errors: " << error_msg << " | warnings: " << warn_msg << LL_ENDL;
+ bool success = override_data->fromJSON(gltf_json_str, warn_msg, error_msg);
- // unblock material editor
- if (obj && obj->isAnySelected())
- {
- LLMaterialEditor::updateLive(object_id, sides[i].asInteger());
- }
+ result.mResults[i] = success;
+
+ if (success)
+ {
+ result.mMaterialVector[i] = override_data;
}
else
{
- S32 side = sides[i].asInteger();
- // flag this side to not be nulled out later
- side_set.insert(sides[i]);
+ LL_WARNS() << "failed to parse GLTF override data. errors: " << error_msg << " | warnings: " << warn_msg << LL_ENDL;
+ }
+ }
+ }
+ }
+ return result;
+ },
+ [message](ReturnData result) // Callback to main thread
+ mutable {
- if (!obj || !obj->setTEGLTFMaterialOverride(side, override_data))
- {
- // object not ready to receive override data, queue for later
- gGLTFMaterialList.queueOverrideUpdate(object_id, side, override_data);
- }
- else if (obj && obj->isAnySelected())
- {
- LLMaterialEditor::updateLive(object_id, side);
- }
+ LLUUID object_id = message["object_id"].asUUID();
+ LLSD& sides = message["sides"];
+ LLViewerObject * obj = gObjectList.findObject(object_id);
+ std::unordered_set<S32> side_set;
+
+ if (result.mResults.size() > 0 )
+ {
+ for (int i = 0; i < result.mResults.size(); ++i)
+ {
+ if (result.mResults[i])
+ {
+ S32 side = sides[i].asInteger();
+ // flag this side to not be nulled out later
+ side_set.insert(sides[i]);
+
+ if (!obj || !obj->setTEGLTFMaterialOverride(side, result.mMaterialVector[i]))
+ {
+ // object not ready to receive override data, queue for later
+ gGLTFMaterialList.queueOverrideUpdate(object_id, side, result.mMaterialVector[i]);
+ }
+ else if (obj && obj->isAnySelected())
+ {
+ LLMaterialEditor::updateLive(object_id, side);
+ }
+ }
+ else
+ {
+ // unblock material editor
+ if (obj && obj->isAnySelected())
+ {
+ LLMaterialEditor::updateLive(object_id, sides[i].asInteger());
}
}
+ }
- 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 (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())
{
- if (side_set.find(i) == side_set.end())
+ obj->setTEGLTFMaterialOverride(i, nullptr);
+ if (object_has_selection)
{
- obj->setTEGLTFMaterialOverride(i, nullptr);
- if (object_has_selection)
- {
- LLMaterialEditor::updateLive(object_id, i);
- }
+ LLMaterialEditor::updateLive(object_id, i);
}
}
}
}
- else
- {
- LL_WARNS() << "Malformed GLTF override message data: " << message << LL_ENDL;
- }
}
-
- if (clear_all && obj)
+ 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)
@@ -181,9 +299,14 @@ namespace
}
}
}
- return true;
- }
- };
+ });
+
+ return true;
+ }
+};
+
+namespace
+{
LLGLTFMaterialOverrideDispatchHandler handle_gltf_override_message;
}
@@ -229,134 +352,214 @@ void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj)
}
}
-void LLGLTFMaterialList::queueModifyMaterial(const LLUUID& id, S32 side, const LLGLTFMaterial& mat)
+void LLGLTFMaterialList::queueModify(const LLUUID& id, S32 side, const LLGLTFMaterial* mat)
+{
+ if (mat == nullptr)
+ {
+ sModifyQueue.push_back({ id, side, LLGLTFMaterial(), false });
+ }
+ else
+ {
+ sModifyQueue.push_back({ id, side, *mat, true});
+ }
+}
+
+void LLGLTFMaterialList::queueApply(const LLUUID& object_id, S32 side, const LLUUID& asset_id)
+{
+ sApplyQueue.push_back({ object_id, side, asset_id});
+}
+
+void LLGLTFMaterialList::queueUpdate(const LLSD& data)
{
- sModifyQueue.push_back({ id, side, mat, LLUUID::null, true, false });
+ llassert(is_valid_update(data));
+
+ if (!sUpdates.isArray())
+ {
+ sUpdates = LLSD::emptyArray();
+ }
+
+ sUpdates[sUpdates.size()] = data;
}
-void LLGLTFMaterialList::flushModifyMaterialQueue(void(*done_callback)(bool))
+void LLGLTFMaterialList::flushUpdates(void(*done_callback)(bool))
{
- LLSD data = LLSD::emptyArray();
+ LLSD& data = sUpdates;
+
+ S32 i = data.size();
- S32 i = 0;
for (auto& e : sModifyQueue)
{
data[i]["object_id"] = e.object_id;
data[i]["side"] = e.side;
- if (e.has_asset_id)
- {
- data[i]["asset_id"] = e.asset_id;
- }
-
if (e.has_override)
{
data[i]["gltf_json"] = e.override_data.asJSON();
}
+ llassert(is_valid_update(data[i]));
++i;
}
+ sModifyQueue.clear();
- std::stringstream str;
+ for (auto& e : sApplyQueue)
+ {
+ data[i]["object_id"] = e.object_id;
+ data[i]["side"] = e.side;
+ data[i]["asset_id"] = e.asset_id;
+ data[i]["gltf_json"] = ""; // null out any existing overrides when applying a material asset
+ llassert(is_valid_update(data[i]));
+ ++i;
+ }
+ sApplyQueue.clear();
+
+#if 0 // debug output of data being sent to capability
+ std::stringstream str;
LLSDSerialize::serialize(data, str, LLSDSerialize::LLSD_NOTATION, LLSDFormatter::OPTIONS_PRETTY);
LL_INFOS() << "\n" << str.str() << LL_ENDL;
+#endif
- LLCoros::instance().launch("modifyMaterialCoro",
- std::bind(&LLGLTFMaterialList::modifyMaterialCoro,
- gAgent.getRegionCapability("ModifyMaterialParams"),
- data,
- done_callback));
+ if (sUpdates.size() > 0)
+ {
+ LLCoros::instance().launch("modifyMaterialCoro",
+ std::bind(&LLGLTFMaterialList::modifyMaterialCoro,
+ gAgent.getRegionCapability("ModifyMaterialParams"),
+ sUpdates,
+ done_callback));
- sModifyQueue.clear();
+ sUpdates = LLSD::emptyArray();
+ }
+
+
}
-LLGLTFMaterial* LLGLTFMaterialList::getMaterial(const LLUUID& id)
+class AssetLoadUserData
{
- LL_PROFILE_ZONE_SCOPED;
- uuid_mat_map_t::iterator iter = mList.find(id);
- if (iter == mList.end())
+public:
+ AssetLoadUserData() {}
+ tinygltf::Model mModelIn;
+ LLPointer<LLFetchedGLTFMaterial> mMaterial;
+};
+
+void LLGLTFMaterialList::onAssetLoadComplete(const LLUUID& id, LLAssetType::EType asset_type, void* user_data, S32 status, LLExtStat ext_status)
+{
+ LL_PROFILE_ZONE_NAMED("gltf asset callback");
+ AssetLoadUserData* asset_data = (AssetLoadUserData*)user_data;
+
+ if (status != LL_ERR_NOERR)
+ {
+ LL_WARNS() << "Error getting material asset data: " << LLAssetStorage::getErrorString(status) << " (" << status << ")" << LL_ENDL;
+ asset_data->mMaterial->mFetching = false;
+ delete asset_data;
+ }
+ else
{
- LL_PROFILE_ZONE_NAMED("gltf fetch")
- LLFetchedGLTFMaterial* mat = new LLFetchedGLTFMaterial();
- mList[id] = mat;
- if (!mat->mFetching)
- {
- // if we do multiple getAssetData calls,
- // some will get distched, messing ref counter
- // Todo: get rid of mat->ref()
- mat->mFetching = true;
- mat->ref();
+ LL::WorkQueue::ptr_t main_queue = LL::WorkQueue::getInstance("mainloop");
+ LL::WorkQueue::ptr_t general_queue = LL::WorkQueue::getInstance("General");
+
+ typedef std::pair<U32, tinygltf::Model> return_data_t;
- gAssetStorage->getAssetData(id, LLAssetType::AT_MATERIAL,
- [=](const LLUUID& id, LLAssetType::EType asset_type, void* user_data, S32 status, LLExtStat ext_status)
+ main_queue->postTo(
+ general_queue,
+ [id, asset_type, asset_data]() // Work done on general queue
+ {
+ std::vector<char> buffer;
{
- LL_PROFILE_ZONE_NAMED("gltf asset callback");
- if (status)
+ LL_PROFILE_ZONE_NAMED("gltf read asset");
+ LLFileSystem file(id, asset_type, LLFileSystem::READ);
+ auto size = file.getSize();
+ if (!size)
{
- LL_WARNS() << "Error getting material asset data: " << LLAssetStorage::getErrorString(status) << " (" << status << ")" << LL_ENDL;
+ return false;
}
- std::vector<char> buffer;
-
- {
- LL_PROFILE_ZONE_NAMED("gltf read asset");
- LLFileSystem file(id, asset_type, LLFileSystem::READ);
- auto size = file.getSize();
- if (!size)
- {
- LL_DEBUGS() << "Zero size material." << LL_ENDL;
- mat->mFetching = false;
- mat->unref();
- return;
- }
+ buffer.resize(size);
+ file.read((U8*)&buffer[0], buffer.size());
+ }
+ {
+ LL_PROFILE_ZONE_NAMED("gltf deserialize asset");
+ LLSD asset;
- buffer.resize(size);
- file.read((U8*)&buffer[0], buffer.size());
- }
+ // read file into buffer
+ std::istrstream str(&buffer[0], buffer.size());
+ if (LLSDSerialize::deserialize(asset, str, buffer.size()))
{
- LL_PROFILE_ZONE_NAMED("gltf deserialize asset");
-
- LLSD asset;
-
- // read file into buffer
- std::istrstream str(&buffer[0], buffer.size());
-
- if (LLSDSerialize::deserialize(asset, str, buffer.size()))
+ if (asset.has("version") && asset["version"] == "1.0")
{
- if (asset.has("version") && asset["version"] == "1.0")
+ if (asset.has("type") && asset["type"].asString() == "GLTF 2.0")
{
- if (asset.has("type") && asset["type"].asString() == "GLTF 2.0")
+ if (asset.has("data") && asset["data"].isString())
{
- if (asset.has("data") && asset["data"].isString())
- {
- std::string data = asset["data"];
+ std::string data = asset["data"];
+
+ std::string warn_msg, error_msg;
- std::string warn_msg, error_msg;
+ LL_PROFILE_ZONE_SCOPED;
+ tinygltf::TinyGLTF gltf;
- if (!mat->fromJSON(data, warn_msg, error_msg))
- {
- LL_WARNS() << "Failed to decode material asset: " << LL_ENDL;
- LL_WARNS() << warn_msg << LL_ENDL;
- LL_WARNS() << error_msg << LL_ENDL;
- }
+ if (!gltf.LoadASCIIFromString(&asset_data->mModelIn, &error_msg, &warn_msg, data.c_str(), data.length(), ""))
+ {
+ LL_WARNS() << "Failed to decode material asset: "
+ << LL_NEWLINE
+ << warn_msg
+ << LL_NEWLINE
+ << error_msg
+ << LL_ENDL;
+ return false;
}
+ return true;
}
}
}
- else
- {
- LL_WARNS() << "Failed to deserialize material LLSD" << LL_ENDL;
- }
}
+ else
+ {
+ LL_WARNS() << "Failed to deserialize material LLSD" << LL_ENDL;
+ }
+ }
+
+ return false;
+ },
+ [id, asset_data](bool result) // Callback to main thread
+ mutable {
+
+ if (result)
+ {
+ asset_data->mMaterial->setFromModel(asset_data->mModelIn, 0/*only one index*/);
+ }
+ else
+ {
+ LL_DEBUGS() << "Failed to get material " << id << LL_ENDL;
+ }
+ asset_data->mMaterial->mFetching = false;
+ delete asset_data;
+ });
+ }
+}
+
+LLGLTFMaterial* LLGLTFMaterialList::getMaterial(const LLUUID& id)
+{
+ LL_PROFILE_ZONE_SCOPED;
+ uuid_mat_map_t::iterator iter = mList.find(id);
+ if (iter == mList.end())
+ {
+ LL_PROFILE_ZONE_NAMED("gltf fetch")
+ LLFetchedGLTFMaterial* mat = new LLFetchedGLTFMaterial();
+ mList[id] = mat;
- mat->mFetching = false;
- mat->unref();
- }, nullptr);
+ if (!mat->mFetching)
+ {
+ mat->mFetching = true;
+
+ AssetLoadUserData *user_data = new AssetLoadUserData();
+ user_data->mMaterial = mat;
+
+ gAssetStorage->getAssetData(id, LLAssetType::AT_MATERIAL, onAssetLoadComplete, (void*)user_data);
}
return mat;
@@ -433,6 +636,11 @@ void LLGLTFMaterialList::flushMaterials()
{
mLastUpdateKey.setNull();
}
+
+ {
+ using namespace LLStatViewer;
+ sample(NUM_MATERIALS, mList.size());
+ }
}
// static
@@ -477,3 +685,40 @@ void LLGLTFMaterialList::modifyMaterialCoro(std::string cap_url, LLSD overrides,
done_callback(success);
}
}
+
+void LLGLTFMaterialList::writeCacheOverrides(LLSD const & message, std::string const & llsdRaw)
+{
+ LL_DEBUGS() << "material overrides cache" << LL_ENDL;
+
+ // default to main region if message doesn't specify
+ LLViewerRegion * region = gAgent.getRegion();;
+
+ if (message.has("region_handle"))
+ {
+ // TODO start requiring this once server sends this for all messages
+ std::vector<U8> const & buffer = message["region_handle"].asBinary();
+ if (buffer.size() == sizeof(U64))
+ {
+ U64 region_handle = ntohll(*reinterpret_cast<U64 const *>(&buffer[0]));
+ region = LLWorld::instance().getRegionFromHandle(region_handle);
+ }
+ else
+ {
+ LL_WARNS() << "bad region_handle in material override message" << LL_ENDL;
+ llassert(false);
+ }
+ }
+
+ if (region) {
+ region->cacheFullUpdateExtras(message, llsdRaw);
+ } else {
+ LL_WARNS() << "could not access region for material overrides message cache, region_handle: " << LL_ENDL;
+ }
+}
+
+void LLGLTFMaterialList::loadCacheOverrides(std::string const & message)
+{
+ std::vector<std::string> strings(1, message);
+
+ handle_gltf_override_message(nullptr, "", LLUUID::null, strings);
+}
diff --git a/indra/newview/llgltfmateriallist.h b/indra/newview/llgltfmateriallist.h
index e035d2108d..805b477248 100644
--- a/indra/newview/llgltfmateriallist.h
+++ b/indra/newview/llgltfmateriallist.h
@@ -26,6 +26,8 @@
#pragma once
+#include "llassettype.h"
+#include "llextendedstatus.h"
#include "llfetchedgltfmaterial.h"
#include "llgltfmaterial.h"
#include "llpointer.h"
@@ -51,25 +53,63 @@ public:
static void registerCallbacks();
- // save an override update that we want to send to the simulator for later
- static void queueModifyMaterial(const LLUUID& id, S32 side, const LLGLTFMaterial& mat);
+ // Queue an modification of a material that we want to send to the simulator. Call "flushUpdates" to flush pending updates.
+ // id - ID of object to modify
+ // side - TexureEntry index to modify, or -1 for all sides
+ // mat - material to apply as override, or nullptr to remove existing overrides and revert to asset
+ //
+ // NOTE: do not use to revert to asset when applying a new asset id, use queueApplyMaterialAsset below
+ static void queueModify(const LLUUID& id, S32 side, const LLGLTFMaterial* mat);
+
+ // Queue an application of a material asset we want to send to the simulator. Call "flushUpdates" to flush pending updates.
+ // object_id - ID of object to apply material asset to
+ // side - TextureEntry index to apply material to, or -1 for all sides
+ // asset_id - ID of material asset to apply, or LLUUID::null to disassociate current material asset
+ //
+ // NOTE: implicitly removes any override data if present
+ static void queueApply(const LLUUID& object_id, S32 side, const LLUUID& asset_id);
// flush pending material updates to the simulator
- static void flushModifyMaterialQueue(void(*done_callback)(bool));
-
- // apply given override data via given cap url
- // cap_url -- should be gAgent.getRegionCapability("ModifyMaterialParams")
- // overrides -- LLSD map in the format
- // "object_id": LLUUID - object to be modified
- // "side": integer - index of face to be modified
- // "gltf_json" : string - GLTF compliant json of override data (optional, if omitted any existing override data will be cleared)
- static void modifyMaterialCoro(std::string cap_url, LLSD overrides, void(*done_callback)(bool));
+ // 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);
+ // Queue an explicit LLSD ModifyMaterialParams update apply given override data
+ // overrides -- LLSD map (or array of maps) in the format:
+ // object_id UUID(required) id of object
+ // side integer(required) TE index of face to set, or -1 for all faces
+ // gltf_json string(optional) override data to set, empty string nulls out override data, omissions of this parameter keeps existing data
+ // asset_id UUID(optional) id of material asset to set, omission of this parameter keeps existing material asset id
+ //
+ // NOTE: Unless you already have a gltf_json string you want to send, strongly prefer using queueModify
+ // If the queue/flush API is insufficient, extend it.
+ static void queueUpdate(const LLSD& data);
+
+ // Called by batch builder to give LLGLTMaterialList an opportunity to apply
+ // any override data that arrived before the object was ready to receive it
+ void applyQueuedOverrides(LLViewerObject* obj);
+
+ // takes both the parsed message and its raw text to avoid unnecessary re serialization
+ static void writeCacheOverrides(LLSD const & message, std::string const & llsdRaw);
+
+ static void loadCacheOverrides(std::string const & message_raw);
+
+private:
+ friend class LLGLTFMaterialOverrideDispatchHandler;
// save an override update that we got from the simulator for later (for example, if an override arrived for an unknown object)
+ // NOTE: this is NOT for applying overrides from the UI, see queueModifyMaterial above
void queueOverrideUpdate(const LLUUID& id, S32 side, LLGLTFMaterial* override_data);
- void applyQueuedOverrides(LLViewerObject* obj);
-private:
+ static void modifyMaterialCoro(std::string cap_url, LLSD overrides, void(*done_callback)(bool));
+
+protected:
+ static void onAssetLoadComplete(
+ const LLUUID& asset_uuid,
+ LLAssetType::EType type,
+ void* user_data,
+ S32 status,
+ LLExtStat ext_status);
+
typedef std::unordered_map<LLUUID, LLPointer<LLFetchedGLTFMaterial > > uuid_mat_map_t;
uuid_mat_map_t mList;
@@ -84,15 +124,25 @@ private:
LLUUID object_id;
S32 side = -1;
LLGLTFMaterial override_data;
- LLUUID asset_id;
bool has_override = false;
- bool has_asset_id = false;
};
typedef std::list<ModifyMaterialData> modify_queue_t;
static modify_queue_t sModifyQueue;
+ struct ApplyMaterialAssetData
+ {
+ LLUUID object_id;
+ S32 side = -1;
+ LLUUID asset_id;
+ };
+
+ typedef std::list<ApplyMaterialAssetData> apply_queue_t;
+ static apply_queue_t sApplyQueue;
+
+ // data to be flushed to ModifyMaterialParams capability
+ static LLSD sUpdates;
};
extern LLGLTFMaterialList gGLTFMaterialList;
diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp
index 7511dabd5b..5544f33aea 100644
--- a/indra/newview/llhudtext.cpp
+++ b/indra/newview/llhudtext.cpp
@@ -224,6 +224,10 @@ void LLHUDText::renderText()
}
text_color = segment_iter->mColor;
+ if (mOnHUDAttachment)
+ {
+ text_color = linearColor4(text_color);
+ }
text_color.mV[VALPHA] *= alpha_factor;
hud_render_text(segment_iter->getText(), render_position, *fontp, style, shadow, x_offset, y_offset, text_color, mOnHUDAttachment);
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index a0cb4e1c8f..a9728e26da 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -908,29 +908,35 @@ void LLMaterialEditor::onSelectCtrl(LLUICtrl* ctrl, const LLSD& data, S32 dirty_
S32 num_tes = llmin((S32)objectp->getNumTEs(), (S32)objectp->getNumFaces()); // avatars have TEs but no faces
for (S32 te = 0; te < num_tes; ++te)
{
- if (nodep->isTESelected(te) && nodep->mSavedGLTFRenderMaterials.size() > te)
+ if (nodep->isTESelected(te) && nodep->mSavedGLTFOverrideMaterials.size() > te)
{
+ if (nodep->mSavedGLTFOverrideMaterials[te].isNull())
+ {
+ // populate with default values, default values basically mean 'not in use'
+ nodep->mSavedGLTFOverrideMaterials[te] = new LLGLTFMaterial();
+ }
+
switch (mDirtyFlag)
{
//Textures
case MATERIAL_BASE_COLOR_TEX_DIRTY:
{
- nodep->mSavedGLTFRenderMaterials[te]->mBaseColorId = mCtrl->getValue().asUUID();
+ nodep->mSavedGLTFOverrideMaterials[te]->setBaseColorId(mCtrl->getValue().asUUID(), true);
break;
}
case MATERIAL_METALLIC_ROUGHTNESS_TEX_DIRTY:
{
- nodep->mSavedGLTFRenderMaterials[te]->mMetallicRoughnessId = mCtrl->getValue().asUUID();
+ nodep->mSavedGLTFOverrideMaterials[te]->setMetallicRoughnessId(mCtrl->getValue().asUUID(), true);
break;
}
case MATERIAL_EMISIVE_TEX_DIRTY:
{
- nodep->mSavedGLTFRenderMaterials[te]->mEmissiveId = mCtrl->getValue().asUUID();
+ nodep->mSavedGLTFOverrideMaterials[te]->setEmissiveId(mCtrl->getValue().asUUID(), true);
break;
}
case MATERIAL_NORMAL_TEX_DIRTY:
{
- nodep->mSavedGLTFRenderMaterials[te]->mNormalId = mCtrl->getValue().asUUID();
+ nodep->mSavedGLTFOverrideMaterials[te]->setNormalId(mCtrl->getValue().asUUID(), true);
break;
}
// Colors
@@ -938,13 +944,13 @@ void LLMaterialEditor::onSelectCtrl(LLUICtrl* ctrl, const LLSD& data, S32 dirty_
{
LLColor4 ret = linearColor4(LLColor4(mCtrl->getValue()));
// except transparency
- ret.mV[3] = nodep->mSavedGLTFRenderMaterials[te]->mBaseColor.mV[3];
- nodep->mSavedGLTFRenderMaterials[te]->mBaseColor = ret;
+ ret.mV[3] = nodep->mSavedGLTFOverrideMaterials[te]->mBaseColor.mV[3];
+ nodep->mSavedGLTFOverrideMaterials[te]->setBaseColorFactor(ret, true);
break;
}
case MATERIAL_EMISIVE_COLOR_DIRTY:
{
- nodep->mSavedGLTFRenderMaterials[te]->mEmissiveColor = LLColor4(mCtrl->getValue());
+ nodep->mSavedGLTFOverrideMaterials[te]->setEmissiveColorFactor(LLColor3(mCtrl->getValue()), true);
break;
}
default:
@@ -2347,11 +2353,9 @@ class LLRenderMaterialOverrideFunctor : public LLSelectedNodeFunctor
public:
LLRenderMaterialOverrideFunctor(
LLMaterialEditor * me,
- std::string const & url,
const LLUUID &report_on_object_id,
S32 report_on_te)
: mEditor(me)
- , mCapUrl(url)
, mSuccess(false)
, mObjectId(report_on_object_id)
, mObjectTE(report_on_te)
@@ -2379,158 +2383,157 @@ public:
{
continue;
}
-
// Get material from object
// Selection can cover multiple objects, and live editor is
// supposed to overwrite changed values only
LLTextureEntry* tep = objectp->getTE(te);
- LLPointer<LLGLTFMaterial> material = tep->getGLTFRenderMaterial();
- if (material.isNull())
+ if (tep->getGLTFMaterial() == nullptr)
{
// overrides are not supposed to work or apply if
// there is no base material to work from
return false;
}
-
+ LLPointer<LLGLTFMaterial> material = tep->getGLTFMaterialOverride();
// make a copy to not invalidate existing
// material for multiple objects
- material = new LLGLTFMaterial(*material);
+ if (material.isNull())
+ {
+ // Start with a material override which does not make any changes
+ material = new LLGLTFMaterial();
+ }
+ else
+ {
+ material = new LLGLTFMaterial(*material);
+ }
U32 changed_flags = mEditor->getUnsavedChangesFlags();
U32 reverted_flags = mEditor->getRevertedChangesFlags();
- bool can_revert = nodep->mSavedGLTFRenderMaterials.size() > te;
+
+ LLPointer<LLGLTFMaterial> revert_mat;
+ if (nodep->mSavedGLTFOverrideMaterials.size() > te)
+ {
+ if (nodep->mSavedGLTFOverrideMaterials[te].notNull())
+ {
+ revert_mat = nodep->mSavedGLTFOverrideMaterials[te];
+ }
+ else
+ {
+ // mSavedGLTFOverrideMaterials[te] being present but null
+ // means we need to use a default value
+ revert_mat = new LLGLTFMaterial();
+ }
+ }
+ // else can not revert at all
// Override object's values with values from editor where appropriate
if (changed_flags & MATERIAL_BASE_COLOR_DIRTY)
{
material->setBaseColorFactor(mEditor->getBaseColor(), true);
}
- else if ((reverted_flags & MATERIAL_BASE_COLOR_DIRTY) && can_revert)
+ else if ((reverted_flags & MATERIAL_BASE_COLOR_DIRTY) && revert_mat.notNull())
{
- material->setBaseColorFactor(nodep->mSavedGLTFRenderMaterials[te]->mBaseColor, true);
+ material->setBaseColorFactor(revert_mat->mBaseColor, false);
}
if (changed_flags & MATERIAL_BASE_COLOR_TEX_DIRTY)
{
material->setBaseColorId(mEditor->getBaseColorId(), true);
}
- else if ((reverted_flags & MATERIAL_BASE_COLOR_TEX_DIRTY) && can_revert)
+ else if ((reverted_flags & MATERIAL_BASE_COLOR_TEX_DIRTY) && revert_mat.notNull())
{
- material->setBaseColorId(nodep->mSavedGLTFRenderMaterials[te]->mBaseColorId, true);
+ material->setBaseColorId(revert_mat->mBaseColorId, false);
}
if (changed_flags & MATERIAL_NORMAL_TEX_DIRTY)
{
material->setNormalId(mEditor->getNormalId(), true);
}
- else if ((reverted_flags & MATERIAL_NORMAL_TEX_DIRTY) && can_revert)
+ else if ((reverted_flags & MATERIAL_NORMAL_TEX_DIRTY) && revert_mat.notNull())
{
- material->setNormalId(nodep->mSavedGLTFRenderMaterials[te]->mNormalId, true);
+ material->setNormalId(revert_mat->mNormalId, false);
}
if (changed_flags & MATERIAL_METALLIC_ROUGHTNESS_TEX_DIRTY)
{
material->setMetallicRoughnessId(mEditor->getMetallicRoughnessId(), true);
}
- else if ((reverted_flags & MATERIAL_METALLIC_ROUGHTNESS_TEX_DIRTY) && can_revert)
+ else if ((reverted_flags & MATERIAL_METALLIC_ROUGHTNESS_TEX_DIRTY) && revert_mat.notNull())
{
- material->setMetallicRoughnessId(nodep->mSavedGLTFRenderMaterials[te]->mMetallicRoughnessId, true);
+ material->setMetallicRoughnessId(revert_mat->mMetallicRoughnessId, false);
}
if (changed_flags & MATERIAL_METALLIC_ROUGHTNESS_METALNESS_DIRTY)
{
material->setMetallicFactor(mEditor->getMetalnessFactor(), true);
}
- else if ((reverted_flags & MATERIAL_METALLIC_ROUGHTNESS_METALNESS_DIRTY) && can_revert)
+ else if ((reverted_flags & MATERIAL_METALLIC_ROUGHTNESS_METALNESS_DIRTY) && revert_mat.notNull())
{
- material->setMetallicFactor(nodep->mSavedGLTFRenderMaterials[te]->mMetallicFactor, true);
+ material->setMetallicFactor(revert_mat->mMetallicFactor, false);
}
if (changed_flags & MATERIAL_METALLIC_ROUGHTNESS_ROUGHNESS_DIRTY)
{
material->setRoughnessFactor(mEditor->getRoughnessFactor(), true);
}
- else if ((reverted_flags & MATERIAL_METALLIC_ROUGHTNESS_ROUGHNESS_DIRTY) && can_revert)
+ else if ((reverted_flags & MATERIAL_METALLIC_ROUGHTNESS_ROUGHNESS_DIRTY) && revert_mat.notNull())
{
- material->setRoughnessFactor(nodep->mSavedGLTFRenderMaterials[te]->mRoughnessFactor, true);
+ material->setRoughnessFactor(revert_mat->mRoughnessFactor, false);
}
if (changed_flags & MATERIAL_EMISIVE_COLOR_DIRTY)
{
material->setEmissiveColorFactor(LLColor3(mEditor->getEmissiveColor()), true);
}
- else if ((reverted_flags & MATERIAL_EMISIVE_COLOR_DIRTY) && can_revert)
+ else if ((reverted_flags & MATERIAL_EMISIVE_COLOR_DIRTY) && revert_mat.notNull())
{
- material->setEmissiveColorFactor(nodep->mSavedGLTFRenderMaterials[te]->mEmissiveColor, true);
+ material->setEmissiveColorFactor(revert_mat->mEmissiveColor, false);
}
if (changed_flags & MATERIAL_EMISIVE_TEX_DIRTY)
{
material->setEmissiveId(mEditor->getEmissiveId(), true);
}
- else if ((reverted_flags & MATERIAL_EMISIVE_TEX_DIRTY) && can_revert)
+ else if ((reverted_flags & MATERIAL_EMISIVE_TEX_DIRTY) && revert_mat.notNull())
{
- material->setEmissiveId(nodep->mSavedGLTFRenderMaterials[te]->mEmissiveId, true);
+ material->setEmissiveId(revert_mat->mEmissiveId, false);
}
if (changed_flags & MATERIAL_DOUBLE_SIDED_DIRTY)
{
material->setDoubleSided(mEditor->getDoubleSided(), true);
}
- else if ((reverted_flags & MATERIAL_DOUBLE_SIDED_DIRTY) && can_revert)
+ else if ((reverted_flags & MATERIAL_DOUBLE_SIDED_DIRTY) && revert_mat.notNull())
{
- material->setDoubleSided(nodep->mSavedGLTFRenderMaterials[te]->mDoubleSided, true);
+ material->setDoubleSided(revert_mat->mDoubleSided, false);
}
if (changed_flags & MATERIAL_ALPHA_MODE_DIRTY)
{
material->setAlphaMode(mEditor->getAlphaMode(), true);
}
- else if ((reverted_flags & MATERIAL_ALPHA_MODE_DIRTY) && can_revert)
+ else if ((reverted_flags & MATERIAL_ALPHA_MODE_DIRTY) && revert_mat.notNull())
{
- material->setAlphaMode(nodep->mSavedGLTFRenderMaterials[te]->mAlphaMode, true);
+ material->setAlphaMode(revert_mat->mAlphaMode, false);
}
if (changed_flags & MATERIAL_ALPHA_CUTOFF_DIRTY)
{
material->setAlphaCutoff(mEditor->getAlphaCutoff(), true);
}
- else if ((reverted_flags & MATERIAL_ALPHA_CUTOFF_DIRTY) && can_revert)
- {
- material->setAlphaCutoff(nodep->mSavedGLTFRenderMaterials[te]->mAlphaCutoff, true);
- }
-
-#if 1
- if (mObjectTE == te
- && mObjectId == objectp->getID())
+ else if ((reverted_flags & MATERIAL_ALPHA_CUTOFF_DIRTY) && revert_mat.notNull())
{
- mSuccess = true;
+ material->setAlphaCutoff(revert_mat->mAlphaCutoff, false);
}
- LLGLTFMaterialList::queueModifyMaterial(objectp->getID(), te, *material);
-#else
-
- std::string overrides_json = material->asJSON();
-
- LLSD overrides = llsd::map(
- "object_id", objectp->getID(),
- "side", te,
- "gltf_json", overrides_json
- );
- void(*done_callback)(bool) = nullptr;
if (mObjectTE == te
&& mObjectId == objectp->getID())
{
mSuccess = true;
- // We only want callback for face we are displayig material from
- // even if we are setting all of them
- done_callback = modifyCallback;
}
- LLCoros::instance().launch("modifyMaterialCoro", std::bind(&LLGLTFMaterialList::modifyMaterialCoro, mCapUrl, overrides, done_callback));
-#endif
+ LLGLTFMaterialList::queueModify(objectp->getID(), te, material);
}
return true;
}
@@ -2549,7 +2552,6 @@ public:
private:
LLMaterialEditor * mEditor;
- std::string mCapUrl;
LLUUID mObjectId;
S32 mObjectTE;
bool mSuccess;
@@ -2576,12 +2578,12 @@ void LLMaterialEditor::applyToSelection()
{
mOverrideInProgress = true;
LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection();
- LLRenderMaterialOverrideFunctor override_func(this, url, mOverrideObjectId, mOverrideObjectTE);
+ LLRenderMaterialOverrideFunctor override_func(this, mOverrideObjectId, mOverrideObjectTE);
selected_objects->applyToNodes(&override_func);
void(*done_callback)(bool) = LLRenderMaterialOverrideFunctor::modifyCallback;
- LLGLTFMaterialList::flushModifyMaterialQueue(done_callback);
+ LLGLTFMaterialList::flushUpdates(done_callback);
if (!override_func.getResult())
{
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 64b31a25f4..9d720b1523 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -975,9 +975,9 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
color_swatch->setOriginal(color);
color_swatch->set(color, force_set_values || (prev_color != color) || !editable);
- color_swatch->setValid(editable);
- color_swatch->setEnabled( editable );
- color_swatch->setCanApplyImmediately( editable );
+ color_swatch->setValid(editable && !has_pbr_material);
+ color_swatch->setEnabled( editable && !has_pbr_material);
+ color_swatch->setCanApplyImmediately( editable && !has_pbr_material);
}
// Color transparency
@@ -1434,7 +1434,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
LLSelectedTE::getFullbright(fullbright_flag,identical_fullbright);
getChild<LLUICtrl>("checkbox fullbright")->setValue((S32)(fullbright_flag != 0));
- getChildView("checkbox fullbright")->setEnabled(editable);
+ getChildView("checkbox fullbright")->setEnabled(editable && !has_pbr_material);
getChild<LLUICtrl>("checkbox fullbright")->setTentative(!identical_fullbright);
}
@@ -4232,6 +4232,8 @@ void LLPanelFace::onPasteTexture()
LLPanelFaceUpdateFunctor sendfunc(true, true);
selected_objects->applyToObjects(&sendfunc);
+ LLGLTFMaterialList::flushUpdates();
+
LLPanelFaceNavigateHomeFunctor navigate_home_func;
selected_objects->applyToTEs(&navigate_home_func);
}
@@ -4366,7 +4368,7 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te)
// PBR/GLTF
if (te_data["te"].has("pbr"))
{
- objectp->setRenderMaterialID(te, te_data["te"]["pbr"].asUUID(), false /*send in bulk later*/);
+ objectp->setRenderMaterialID(te, te_data["te"]["pbr"].asUUID(), false /*managing our own update*/);
tep->setGLTFRenderMaterial(nullptr);
tep->setGLTFMaterialOverride(nullptr);
@@ -4377,12 +4379,14 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te)
{
override_data["gltf_json"] = te_data["te"]["pbr_override"];
}
+ else
+ {
+ override_data["gltf_json"] = "";
+ }
+
+ override_data["asset_id"] = te_data["te"]["pbr"].asUUID();
- LLCoros::instance().launch("modifyMaterialCoro",
- std::bind(&LLGLTFMaterialList::modifyMaterialCoro,
- gAgent.getRegionCapability("ModifyMaterialParams"),
- override_data,
- nullptr));
+ LLGLTFMaterialList::queueUpdate(override_data);
}
else
{
@@ -4391,12 +4395,7 @@ void LLPanelFace::onPasteTexture(LLViewerObject* objectp, S32 te)
tep->setGLTFMaterialOverride(nullptr);
// blank out any override data on the server
- LLCoros::instance().launch("modifyMaterialCoro",
- std::bind(&LLGLTFMaterialList::modifyMaterialCoro,
- gAgent.getRegionCapability("ModifyMaterialParams"),
- llsd::map(
- "object_id", objectp->getID(),
- "side", te), nullptr));
+ LLGLTFMaterialList::queueApply(objectp->getID(), te, LLUUID::null);
}
// Texture map
diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp
index ef611966ed..f346531bfd 100644
--- a/indra/newview/llreflectionmap.cpp
+++ b/indra/newview/llreflectionmap.cpp
@@ -63,20 +63,7 @@ void LLReflectionMap::autoAdjustOrigin()
const LLVector4a* bounds = mGroup->getBounds();
auto* node = mGroup->getOctreeNode();
- if (mGroup->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_TERRAIN)
- {
- // for terrain, make probes float a couple meters above the highest point in the surface patch
- mOrigin = bounds[0];
- mOrigin.getF32ptr()[2] += bounds[1].getF32ptr()[2] + 3.f;
-
- // update radius to encompass bounding box
- LLVector4a d;
- d.setAdd(bounds[0], bounds[1]);
- d.sub(mOrigin);
- mRadius = d.getLength3().getF32();
- mPriority = 1;
- }
- else if (mGroup->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME)
+ if (mGroup->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME)
{
mPriority = 1;
// cast a ray towards 8 corners of bounding box
@@ -87,92 +74,71 @@ void LLReflectionMap::autoAdjustOrigin()
return;
}
- if (node->isLeaf() || node->getChildCount() > 1 || node->getElementCount() > 0)
- { // use center of object bounding box for leaf nodes or nodes with multiple child nodes
- mOrigin = bounds[0];
-
- LLVector4a start;
- LLVector4a end;
-
- LLVector4a size = bounds[1];
+ mOrigin = bounds[0];
- LLVector4a corners[] =
- {
- { 1, 1, 1 },
- { -1, 1, 1 },
- { 1, -1, 1 },
- { -1, -1, 1 },
- { 1, 1, -1 },
- { -1, 1, -1 },
- { 1, -1, -1 },
- { -1, -1, -1 }
- };
-
- for (int i = 0; i < 8; ++i)
- {
- corners[i].mul(size);
- corners[i].add(bounds[0]);
- }
+ LLVector4a size = bounds[1];
- LLVector4a extents[2];
- extents[0].setAdd(bounds[0], bounds[1]);
- extents[1].setSub(bounds[0], bounds[1]);
+ LLVector4a corners[] =
+ {
+ { 1, 1, 1 },
+ { -1, 1, 1 },
+ { 1, -1, 1 },
+ { -1, -1, 1 },
+ { 1, 1, -1 },
+ { -1, 1, -1 },
+ { 1, -1, -1 },
+ { -1, -1, -1 }
+ };
+
+ for (int i = 0; i < 8; ++i)
+ {
+ corners[i].mul(size);
+ corners[i].add(bounds[0]);
+ }
- bool hit = false;
- for (int i = 0; i < 8; ++i)
- {
- int face = -1;
- LLVector4a intersection;
- LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], true, false, true, &face, &intersection);
- if (drawable != nullptr)
- {
- hit = true;
- update_min_max(extents[0], extents[1], intersection);
- }
- else
- {
- update_min_max(extents[0], extents[1], corners[i]);
- }
- }
+ LLVector4a extents[2];
+ extents[0].setAdd(bounds[0], bounds[1]);
+ extents[1].setSub(bounds[0], bounds[1]);
- if (hit)
+ bool hit = false;
+ for (int i = 0; i < 8; ++i)
+ {
+ int face = -1;
+ LLVector4a intersection;
+ LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], true, false, true, &face, &intersection);
+ if (drawable != nullptr)
{
- mOrigin.setAdd(extents[0], extents[1]);
- mOrigin.mul(0.5f);
+ hit = true;
+ update_min_max(extents[0], extents[1], intersection);
}
-
- // make sure radius encompasses all objects
- LLSimdScalar r2 = 0.0;
- for (int i = 0; i < 8; ++i)
+ else
{
- LLVector4a v;
- v.setSub(corners[i], mOrigin);
-
- LLSimdScalar d = v.dot3(v);
-
- if (d > r2)
- {
- r2 = d;
- }
+ update_min_max(extents[0], extents[1], corners[i]);
}
-
- mRadius = llmax(sqrtf(r2.getF32()), 8.f);
}
- else
- {
- // user placed probe
- mPriority = 2;
- // use center of octree node volume for nodes that are just branches without data
- mOrigin = node->getCenter();
+ if (hit)
+ {
+ mOrigin.setAdd(extents[0], extents[1]);
+ mOrigin.mul(0.5f);
+ }
- // update radius to encompass entire octree node volume
- mRadius = node->getSize().getLength3().getF32();
+ // make sure radius encompasses all objects
+ LLSimdScalar r2 = 0.0;
+ for (int i = 0; i < 8; ++i)
+ {
+ LLVector4a v;
+ v.setSub(corners[i], mOrigin);
- //mOrigin = bounds[0];
- //mRadius = bounds[1].getLength3().getF32();
+ LLSimdScalar d = v.dot3(v);
+ if (d > r2)
+ {
+ r2 = d;
+ }
}
+
+ mRadius = llmax(sqrtf(r2.getF32()), 8.f);
}
}
else if (mViewerObject)
diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp
index 19f0a8d089..8282aa2507 100644
--- a/indra/newview/llreflectionmapmanager.cpp
+++ b/indra/newview/llreflectionmapmanager.cpp
@@ -88,7 +88,7 @@ void LLReflectionMapManager::update()
const bool use_depth_buffer = true;
const bool use_stencil_buffer = false;
U32 targetRes = LL_REFLECTION_PROBE_RESOLUTION * 2; // super sample
- mRenderTarget.allocate(targetRes, targetRes, color_fmt, use_depth_buffer, use_stencil_buffer, LLTexUnit::TT_RECT_TEXTURE);
+ mRenderTarget.allocate(targetRes, targetRes, color_fmt, use_depth_buffer, use_stencil_buffer, LLTexUnit::TT_TEXTURE);
}
if (mMipChain.empty())
@@ -99,7 +99,7 @@ void LLReflectionMapManager::update()
mMipChain.resize(count);
for (int i = 0; i < count; ++i)
{
- mMipChain[i].allocate(res, res, GL_RGBA16F, false, false, LLTexUnit::TT_RECT_TEXTURE);
+ mMipChain[i].allocate(res, res, GL_RGBA16F, false, false, LLTexUnit::TT_TEXTURE);
res /= 2;
}
}
@@ -437,8 +437,8 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face)
S32 mips = log2((F32)LL_REFLECTION_PROBE_RESOLUTION) + 0.5f;
- S32 diffuseChannel = gReflectionMipProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, LLTexUnit::TT_RECT_TEXTURE);
- S32 depthChannel = gReflectionMipProgram.enableTexture(LLShaderMgr::DEFERRED_DEPTH, LLTexUnit::TT_RECT_TEXTURE);
+ S32 diffuseChannel = gReflectionMipProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, LLTexUnit::TT_TEXTURE);
+ S32 depthChannel = gReflectionMipProgram.enableTexture(LLShaderMgr::DEFERRED_DEPTH, LLTexUnit::TT_TEXTURE);
LLRenderTarget* screen_rt = &gPipeline.mAuxillaryRT.screen;
LLRenderTarget* depth_rt = &gPipeline.mAuxillaryRT.deferredScreen;
@@ -472,13 +472,13 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face)
gGL.texCoord2f(0, 0);
gGL.vertex2f(-1, -1);
- gGL.texCoord2f(res, 0);
+ gGL.texCoord2f(1.f, 0);
gGL.vertex2f(1, -1);
- gGL.texCoord2f(res, res);
+ gGL.texCoord2f(1.f, 1.f);
gGL.vertex2f(1, 1);
- gGL.texCoord2f(0, res);
+ gGL.texCoord2f(0, 1.f);
gGL.vertex2f(-1, 1);
gGL.end();
gGL.flush();
@@ -506,8 +506,8 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face)
gGL.matrixMode(gGL.MM_MODELVIEW);
gGL.popMatrix();
- gGL.getTexUnit(diffuseChannel)->unbind(LLTexUnit::TT_RECT_TEXTURE);
- gGL.getTexUnit(depthChannel)->unbind(LLTexUnit::TT_RECT_TEXTURE);
+ gGL.getTexUnit(diffuseChannel)->unbind(LLTexUnit::TT_TEXTURE);
+ gGL.getTexUnit(depthChannel)->unbind(LLTexUnit::TT_TEXTURE);
gReflectionMipProgram.unbind();
}
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index ee10872a16..dbc3fe0ce5 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -1814,15 +1814,12 @@ void LLObjectSelection::applyNoCopyPbrMaterialToTEs(LLViewerInventoryItem* item)
object->setRenderMaterialID(te, asset_id, false /*will be sent later*/);
// blank out any override data on the server
- LLCoros::instance().launch("modifyMaterialCoro",
- std::bind(&LLGLTFMaterialList::modifyMaterialCoro,
- gAgent.getRegionCapability("ModifyMaterialParams"),
- llsd::map(
- "object_id", object->getID(),
- "side", te), nullptr));
+ LLGLTFMaterialList::queueApply(object->getID(), te, asset_id);
}
}
}
+
+ LLGLTFMaterialList::flushUpdates();
}
@@ -1959,12 +1956,7 @@ void LLSelectMgr::selectionSetGLTFMaterial(const LLUUID& mat_id)
objectp->setRenderMaterialID(te, asset_id, false /*prevent an update to prevent a race condition*/);
// blank out any override data on the server
- LLCoros::instance().launch("modifyMaterialCoro",
- std::bind(&LLGLTFMaterialList::modifyMaterialCoro,
- gAgent.getRegionCapability("ModifyMaterialParams"),
- llsd::map(
- "object_id", objectp->getID(),
- "side", te), nullptr));
+ LLGLTFMaterialList::queueApply(objectp->getID(), te, asset_id);
return true;
}
@@ -2026,6 +2018,8 @@ void LLSelectMgr::selectionSetGLTFMaterial(const LLUUID& mat_id)
}
} sendfunc(item);
getSelection()->applyToObjects(&sendfunc);
+
+ LLGLTFMaterialList::flushUpdates();
}
//-----------------------------------------------------------------------------
@@ -2225,25 +2219,27 @@ void LLSelectMgr::selectionRevertGLTFMaterials()
LLUUID asset_id = nodep->mSavedGLTFMaterialIds[te];
objectp->setRenderMaterialID(te, asset_id, false /*wait for bulk update*/);
- // Restore overrides
- LLSD overrides;
- overrides["object_id"] = objectp->getID();
- overrides["side"] = te;
// todo: make sure this does not cause race condition with setRenderMaterialID
// when we are reverting from null id to non null plus override
- if (te < (S32)nodep->mSavedGLTFRenderMaterials.size()
- && nodep->mSavedGLTFRenderMaterials[te].notNull()
+ if (te < (S32)nodep->mSavedGLTFOverrideMaterials.size()
+ && nodep->mSavedGLTFOverrideMaterials[te].notNull()
&& asset_id.notNull())
{
- overrides["gltf_json"] = nodep->mSavedGLTFRenderMaterials[te]->asJSON();
- } // else nothing to blank override out
-
- LLCoros::instance().launch("modifyMaterialCoro",
- std::bind(&LLGLTFMaterialList::modifyMaterialCoro,
- gAgent.getRegionCapability("ModifyMaterialParams"),
- overrides,
- nullptr));
+ // Restore overrides
+ LLSD overrides;
+ overrides["object_id"] = objectp->getID();
+ overrides["side"] = te;
+
+ overrides["gltf_json"] = nodep->mSavedGLTFOverrideMaterials[te]->asJSON();
+ LLGLTFMaterialList::queueUpdate(overrides);
+ }
+ else
+ {
+ //blank override out
+ LLGLTFMaterialList::queueApply(objectp->getID(), te, asset_id);
+ }
+
}
return true;
}
@@ -5888,10 +5884,10 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data
// reflected in a saved copy.
// Like changes from local material (reuses pointer) or
// from live editor (revert mechanics might modify this)
- LLGLTFMaterial* old_mat = node->getObject()->getTE(i)->getGLTFRenderMaterial();
- if (old_mat)
+ LLGLTFMaterial* old_override = node->getObject()->getTE(i)->getGLTFMaterialOverride();
+ if (old_override)
{
- LLPointer<LLGLTFMaterial> mat = new LLGLTFMaterial(*old_mat);
+ LLPointer<LLGLTFMaterial> mat = new LLGLTFMaterial(*old_override);
materials.push_back(mat);
}
else
@@ -5903,7 +5899,7 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data
// processObjectProperties does not include overrides so this
// might need to be moved to LLGLTFMaterialOverrideDispatchHandler
- node->saveGLTFRenderMaterials(materials);
+ node->saveGLTFOverrideMaterials(materials);
}
}
@@ -6657,7 +6653,7 @@ LLSelectNode::LLSelectNode(const LLSelectNode& nodep)
saveTextures(nodep.mSavedTextures);
saveGLTFMaterialIds(nodep.mSavedGLTFMaterialIds);
- saveGLTFRenderMaterials(nodep.mSavedGLTFRenderMaterials);
+ saveGLTFOverrideMaterials(nodep.mSavedGLTFOverrideMaterials);
}
LLSelectNode::~LLSelectNode()
@@ -6805,29 +6801,20 @@ void LLSelectNode::saveGLTFMaterialIds(const uuid_vec_t& materials)
}
}
-void LLSelectNode::saveGLTFRenderMaterials(const gltf_materials_vec_t& materials)
+void LLSelectNode::saveGLTFOverrideMaterials(const gltf_materials_vec_t& materials)
{
if (mObject.notNull())
{
- mSavedGLTFRenderMaterials.clear();
+ mSavedGLTFOverrideMaterials.clear();
for (gltf_materials_vec_t::const_iterator mat_it = materials.begin();
mat_it != materials.end(); ++mat_it)
{
- mSavedGLTFRenderMaterials.push_back(*mat_it);
+ mSavedGLTFOverrideMaterials.push_back(*mat_it);
}
}
}
-LLGLTFMaterial* LLSelectNode::getSavedGLTFRenderMaterial(S32 te)
-{
- if (mSavedGLTFRenderMaterials.size() > te)
- {
- return mSavedGLTFRenderMaterials[te].get();
- }
- return nullptr;
-}
-
void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query)
{
mTextureScaleRatios.clear();
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index 7e7c450767..64b87b7c86 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -198,8 +198,7 @@ public:
// Ids get applied and restored by tools floater,
// overrides get applied in live material editor
void saveGLTFMaterialIds(const uuid_vec_t& materials);
- void saveGLTFRenderMaterials(const gltf_materials_vec_t& materials);
- LLGLTFMaterial* getSavedGLTFRenderMaterial(S32 te);
+ void saveGLTFOverrideMaterials(const gltf_materials_vec_t& materials);
BOOL allowOperationOnNode(PermissionBit op, U64 group_proxy_power) const;
@@ -237,7 +236,7 @@ public:
std::vector<LLColor4> mSavedShinyColors;
uuid_vec_t mSavedTextures;
uuid_vec_t mSavedGLTFMaterialIds;
- gltf_materials_vec_t mSavedGLTFRenderMaterials;
+ gltf_materials_vec_t mSavedGLTFOverrideMaterials;
std::vector<LLVector3> mTextureScaleRatios;
std::vector<LLVector3> mSilhouetteVertices; // array of vertices to render silhouette of object
std::vector<LLVector3> mSilhouetteNormals; // array of normals to render silhouette of object
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index c2f9779a53..7709054d24 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -1562,6 +1562,15 @@ void render_ui_3d()
}
gViewerWindow->renderSelections(FALSE, FALSE, TRUE); // Non HUD call in render_hud_elements
+
+ if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
+ {
+ // Render debugging beacons.
+ gObjectList.renderObjectBeacons();
+ gObjectList.resetObjectBeacons();
+ gSky.addSunMoonBeacons();
+ }
+
stop_glerror();
}
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 1efc4ea3d5..47cb9e9732 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -7205,19 +7205,14 @@ void LLViewerObject::setRenderMaterialID(S32 te_in, const LLUUID& id, bool updat
if (update_server)
{
- // blank out any override data on the ser
+ // update via ModifyMaterialParams cap (server will echo back changes)
for (S32 te = start_idx; te < end_idx; ++te)
{
- LLCoros::instance().launch("modifyMaterialCoro",
- std::bind(&LLGLTFMaterialList::modifyMaterialCoro,
- gAgent.getRegionCapability("ModifyMaterialParams"),
- llsd::map(
- "object_id", getID(),
- "side", te), nullptr));
+ LLGLTFMaterialList::queueApply(getID(), te, id);
}
}
- // update and send LLRenderMaterialParams
+ // predictively update LLRenderMaterialParams (don't wait for server)
LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL);
if (!param_block && id.notNull())
{ // block doesn't exist, but it will need to
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 768b4f425b..955979e605 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -1812,12 +1812,15 @@ void LLViewerObjectList::renderObjectBounds(const LLVector3 &center)
{
}
+extern BOOL gCubeSnapshot;
+
void LLViewerObjectList::addDebugBeacon(const LLVector3 &pos_agent,
const std::string &string,
const LLColor4 &color,
const LLColor4 &text_color,
S32 line_width)
{
+ llassert(!gCubeSnapshot);
LLDebugBeacon beacon;
beacon.mPositionAgent = pos_agent;
beacon.mString = string;
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 36d8fffa7c..0e7fd63c7f 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -53,6 +53,7 @@
#include "llfloatergodtools.h"
#include "llfloaterreporter.h"
#include "llfloaterregioninfo.h"
+#include "llgltfmateriallist.h"
#include "llhttpnode.h"
#include "llregioninfomodel.h"
#include "llsdutil.h"
@@ -214,6 +215,7 @@ public:
LLVOCacheEntry::vocache_entry_set_t mVisibleEntries; //must-be-created visible entries wait for objects creation.
LLVOCacheEntry::vocache_entry_priority_list_t mWaitingList; //transient list storing sorted visible entries waiting for object creation.
std::set<U32> mNonCacheableCreatedList; //list of local ids of all non-cacheable objects
+ LLVOCacheEntry::vocache_extras_entry_map_t mCacheExtraJson; // for materials
// time?
// LRU info?
@@ -782,7 +784,10 @@ void LLViewerRegion::loadObjectCache()
if(LLVOCache::instanceExists())
{
- LLVOCache::getInstance()->readFromCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap) ;
+ LLVOCache & vocache = LLVOCache::instance();
+ vocache.readFromCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap) ;
+ vocache.readGenericExtrasFromCache(mHandle, mImpl->mCacheID, mImpl->mCacheExtraJson);
+
if (mImpl->mCacheMap.empty())
{
mCacheDirty = TRUE;
@@ -807,8 +812,10 @@ void LLViewerRegion::saveObjectCache()
{
const F32 start_time_threshold = 600.0f; //seconds
bool removal_enabled = sVOCacheCullingEnabled && (mRegionTimer.getElapsedTimeF32() > start_time_threshold); //allow to remove invalid objects from object cache file.
-
- LLVOCache::getInstance()->writeToCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap, mCacheDirty, removal_enabled) ;
+
+ LLVOCache & instance = LLVOCache::instance();
+ instance.writeToCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap, mCacheDirty, removal_enabled) ;
+ instance.writeGenericExtrasToCache(mHandle, mImpl->mCacheID, mImpl->mCacheExtraJson, mCacheDirty, removal_enabled);
mCacheDirty = FALSE;
}
@@ -1823,7 +1830,7 @@ LLViewerObject* LLViewerRegion::addNewObject(LLVOCacheEntry* entry)
LLViewerObject* obj = NULL;
if(!entry->getEntry()->hasDrawable()) //not added to the rendering pipeline yet
- {
+ {
//add the object
obj = gObjectList.processObjectUpdateFromCache(entry, this);
if(obj)
@@ -2598,7 +2605,7 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLDataPackerB
LL_DEBUGS("AnimatedObjects") << " got update for local_id " << local_id << LL_ENDL;
dumpStack("AnimatedObjectsStack");
- // Update the cache entry
+ // Update the cache entry
entry->updateEntry(crc, dp);
decodeBoundingInfo(entry);
@@ -2615,7 +2622,7 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLDataPackerB
// Create new entry and add to map
result = CACHE_UPDATE_ADDED;
entry = new LLVOCacheEntry(local_id, crc, dp);
- record(LLStatViewer::OBJECT_CACHE_HIT_RATE, LLUnits::Ratio::fromValue(0));
+ record(LLStatViewer::OBJECT_CACHE_HIT_RATE, LLUnits::Ratio::fromValue(0));
mImpl->mCacheMap[local_id] = entry;
@@ -2633,6 +2640,22 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObjec
return result;
}
+void LLViewerRegion::cacheFullUpdateExtras(LLSD const & extras, std::string const & extras_raw)
+{
+ LLUUID object_id = extras["object_id"].asUUID();
+ LLViewerObject * obj = gObjectList.findObject(object_id);
+ if (obj != nullptr)
+ {
+ U32 local_id = obj->getLocalID();
+
+ mImpl->mCacheExtraJson[local_id] = LLVOCacheEntry::ExtrasEntry{extras, extras_raw};
+ }
+ else
+ {
+ LL_WARNS() << "got material override for unknown object_id, cannot cache it" << LL_ENDL;
+ }
+}
+
LLVOCacheEntry* LLViewerRegion::getCacheEntryForOctree(U32 local_id)
{
if(!sVOCacheCullingEnabled)
@@ -2657,7 +2680,7 @@ LLVOCacheEntry* LLViewerRegion::getCacheEntry(U32 local_id, bool valid)
}
}
return NULL;
- }
+}
void LLViewerRegion::addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type)
{
@@ -2731,6 +2754,9 @@ bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss
entry->setValid();
decodeBoundingInfo(entry);
+
+ loadCacheMiscExtras(local_id, entry, crc);
+
return true;
}
else
@@ -3514,3 +3540,11 @@ std::string LLViewerRegion::getSimHostName()
return std::string("...");
}
+void LLViewerRegion::loadCacheMiscExtras(U32 local_id, LLVOCacheEntry * entry, U32 crc)
+{
+ auto iter = mImpl->mCacheExtraJson.find(local_id);
+ if (iter != mImpl->mCacheExtraJson.end())
+ {
+ LLGLTFMaterialList::loadCacheOverrides(iter->second.extras_raw);
+ }
+}
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 8b27004f1d..85f5b48b48 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -348,7 +348,9 @@ public:
// handle a full update message
eCacheUpdateResult cacheFullUpdate(LLDataPackerBinaryBuffer &dp, U32 flags);
- eCacheUpdateResult cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp, U32 flags);
+ eCacheUpdateResult cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp, U32 flags);
+ void cacheFullUpdateExtras(LLSD const & extras, std::string const & extras_raw);
+
LLVOCacheEntry* getCacheEntryForOctree(U32 local_id);
LLVOCacheEntry* getCacheEntry(U32 local_id, bool valid = true);
bool probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss_type);
@@ -419,6 +421,8 @@ private:
void decodeBoundingInfo(LLVOCacheEntry* entry);
bool isNonCacheableObjectCreated(U32 local_id);
+ void loadCacheMiscExtras(U32 local_id, LLVOCacheEntry * entry, U32 crc);
+
public:
struct CompareDistance
{
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index e1bf1b6e6d..9e2d28f29e 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -92,6 +92,7 @@ LLGLSLShader gDownsampleDepthProgram;
LLGLSLShader gDownsampleDepthRectProgram;
LLGLSLShader gAlphaMaskProgram;
LLGLSLShader gBenchmarkProgram;
+LLGLSLShader gScreenSpaceReflectionProgram;
//object shaders
@@ -178,7 +179,8 @@ LLGLSLShader gWLMoonProgram;
LLGLSLShader gGlowProgram;
LLGLSLShader gGlowExtractProgram;
LLGLSLShader gPostColorFilterProgram;
-LLGLSLShader gPostNightVisionProgram;
+LLGLSLShader gPostNightVisionProgram;
+LLGLSLShader gPostScreenSpaceReflectionProgram;
// Deferred rendering shaders
LLGLSLShader gDeferredImpostorProgram;
@@ -698,6 +700,7 @@ void LLViewerShaderMgr::unloadShaders()
gOneTextureFilterProgram.unload();
gOneTextureNoColorProgram.unload();
gSolidColorProgram.unload();
+ gScreenSpaceReflectionProgram.unload();
gObjectFullbrightNoColorProgram.unload();
gObjectFullbrightNoColorWaterProgram.unload();
@@ -770,6 +773,7 @@ void LLViewerShaderMgr::unloadShaders()
gPostColorFilterProgram.unload();
gPostNightVisionProgram.unload();
+ gPostScreenSpaceReflectionProgram.unload();
gDeferredDiffuseProgram.unload();
gDeferredDiffuseAlphaMaskProgram.unload();
@@ -912,6 +916,7 @@ std::string LLViewerShaderMgr::loadBasicShaders()
index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/shadowUtil.glsl", 1) );
index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/aoUtil.glsl", 1) );
index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/reflectionProbeF.glsl", has_reflection_probes ? 3 : 2) );
+ index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/screenSpaceReflUtil.glsl", 3) );
index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) );
index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightAlphaMaskNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) );
index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) );
@@ -2872,6 +2877,16 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
success = gDeferredGenBrdfLutProgram.createShader(NULL, NULL);
}
+ if (success) {
+ gPostScreenSpaceReflectionProgram.mName = "Screen Space Reflection Post";
+ gPostScreenSpaceReflectionProgram.mShaderFiles.clear();
+ gPostScreenSpaceReflectionProgram.mShaderFiles.push_back(make_pair("deferred/screenSpaceReflPostV.glsl", GL_VERTEX_SHADER));
+ gPostScreenSpaceReflectionProgram.mShaderFiles.push_back(make_pair("deferred/screenSpaceReflPostF.glsl", GL_FRAGMENT_SHADER));
+ gPostScreenSpaceReflectionProgram.mFeatures.hasScreenSpaceReflections = true;
+ gPostScreenSpaceReflectionProgram.mFeatures.isDeferred = true;
+ gPostScreenSpaceReflectionProgram.mShaderLevel = 3;
+ success = gPostScreenSpaceReflectionProgram.createShader(NULL, NULL);
+ }
return success;
}
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index a2ae984caa..4ed6b02728 100644
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -247,7 +247,7 @@ extern LLGLSLShader gWLMoonProgram;
// Post Process Shaders
extern LLGLSLShader gPostColorFilterProgram;
extern LLGLSLShader gPostNightVisionProgram;
-
+extern LLGLSLShader gPostScreenSpaceReflectionProgram;
// Deferred rendering shaders
extern LLGLSLShader gDeferredImpostorProgram;
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 5d936dfc90..0be9abadbb 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -139,6 +139,7 @@ SimMeasurement<LLUnit<F64, LLUnits::Percent> >
LLTrace::SampleStatHandle<> FPS_SAMPLE("fpssample"),
NUM_IMAGES("numimagesstat"),
NUM_RAW_IMAGES("numrawimagesstat"),
+ NUM_MATERIALS("nummaterials"),
NUM_OBJECTS("numobjectsstat"),
NUM_ACTIVE_OBJECTS("numactiveobjectsstat"),
ENABLE_VBO("enablevbo", "Vertex Buffers Enabled"),
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index c21c06256e..4f0f4f8813 100644
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -180,6 +180,7 @@ extern LLTrace::SampleStatHandle<> FPS_SAMPLE,
NUM_IMAGES,
NUM_RAW_IMAGES,
NUM_OBJECTS,
+ NUM_MATERIALS,
NUM_ACTIVE_OBJECTS,
ENABLE_VBO,
LIGHTING_DETAIL,
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 55fc663496..2b93460d25 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -170,7 +170,7 @@ LLVOCacheEntry::~LLVOCacheEntry()
}
void LLVOCacheEntry::updateEntry(U32 crc, LLDataPackerBinaryBuffer &dp)
-{
+{
if(mCRC != crc)
{
mCRC = crc;
@@ -1435,7 +1435,12 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca
return ;
}
-
+
+void LLVOCache::readGenericExtrasFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::vocache_extras_entry_map_t& cache_extras_entry_map)
+{
+ LL_DEBUGS() << "TODO" << LL_ENDL;
+}
+
void LLVOCache::purgeEntries(U32 size)
{
while(mHeaderEntryQueue.size() > size)
@@ -1572,3 +1577,7 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry:
return ;
}
+
+void LLVOCache::writeGenericExtrasToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_extras_entry_map_t& cache_extras_entry_map, BOOL dirty_cache, bool removal_enabled)
+{
+}
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 55a13d934d..33c1dfef8d 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -33,6 +33,8 @@
#include "llvieweroctree.h"
#include "llapr.h"
+#include <unordered_map>
+
//---------------------------------------------------------------------------
// Cache entries
class LLCamera;
@@ -79,6 +81,13 @@ public:
}
}
};
+
+ struct ExtrasEntry
+ {
+ LLSD extras;
+ std::string extras_raw;
+ };
+
protected:
~LLVOCacheEntry();
public:
@@ -142,7 +151,8 @@ private:
public:
typedef std::map<U32, LLPointer<LLVOCacheEntry> > vocache_entry_map_t;
typedef std::set<LLVOCacheEntry*> vocache_entry_set_t;
- typedef std::set<LLVOCacheEntry*, CompareVOCacheEntry> vocache_entry_priority_list_t;
+ typedef std::set<LLVOCacheEntry*, CompareVOCacheEntry> vocache_entry_priority_list_t;
+ typedef std::unordered_map<U32, ExtrasEntry> vocache_extras_entry_map_t;
S32 mLastCameraUpdated;
protected:
@@ -265,7 +275,10 @@ public:
void removeCache(ELLPath location, bool started = false) ;
void readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::vocache_entry_map_t& cache_entry_map) ;
+ void readGenericExtrasFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::vocache_extras_entry_map_t& cache_extras_entry_map);
+
void writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache, bool removal_enabled);
+ void writeGenericExtrasToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_extras_entry_map_t& cache_extras_entry_map, BOOL dirty_cache, bool removal_enabled);
void removeEntry(U64 handle) ;
U32 getCacheEntries() { return mNumEntries; }
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index aacf6fa73e..dff84bda0e 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -215,6 +215,7 @@ bool LLPipeline::CameraOffset;
F32 LLPipeline::CameraMaxCoF;
F32 LLPipeline::CameraDoFResScale;
F32 LLPipeline::RenderAutoHideSurfaceAreaLimit;
+bool LLPipeline::RenderScreenSpaceReflections;
LLTrace::EventStatHandle<S64> LLPipeline::sStatBatchSize("renderbatchsize");
const F32 BACKLIGHT_DAY_MAGNITUDE_OBJECT = 0.1f;
@@ -345,7 +346,7 @@ bool addDeferredAttachments(LLRenderTarget& target, bool for_impostor = false)
{
bool valid = true
&& target.addColorAttachment(GL_RGBA) // frag-data[1] specular OR PBR ORM
- && target.addColorAttachment(GL_RGB10_A2) // frag_data[2] normal+z+fogmask, See: class1\deferred\materialF.glsl & softenlight
+ && target.addColorAttachment(GL_RGBA16F) // frag_data[2] normal+z+fogmask, See: class1\deferred\materialF.glsl & softenlight
&& target.addColorAttachment(GL_RGBA); // frag_data[3] PBR emissive
return valid;
}
@@ -576,6 +577,7 @@ void LLPipeline::init()
connectRefreshCachedSettingsSafe("CameraMaxCoF");
connectRefreshCachedSettingsSafe("CameraDoFResScale");
connectRefreshCachedSettingsSafe("RenderAutoHideSurfaceAreaLimit");
+ connectRefreshCachedSettingsSafe("RenderScreenSpaceReflections");
gSavedSettings.getControl("RenderAutoHideSurfaceAreaLimit")->getCommitSignal()->connect(boost::bind(&LLPipeline::refreshCachedSettings));
}
@@ -731,7 +733,7 @@ void LLPipeline::allocatePhysicsBuffer()
if (mPhysicsDisplay.getWidth() != resX || mPhysicsDisplay.getHeight() != resY)
{
- mPhysicsDisplay.allocate(resX, resY, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE);
+ mPhysicsDisplay.allocate(resX, resY, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE);
}
}
@@ -825,7 +827,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
if (RenderUIBuffer)
{
- if (!mRT->uiScreen.allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE))
+ if (!mRT->uiScreen.allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE))
{
return false;
}
@@ -839,14 +841,14 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
const U32 occlusion_divisor = 3;
//allocate deferred rendering color buffers
- if (!mRT->deferredScreen.allocate(resX, resY, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false;
- //if (!mRT->deferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false;
- if (!mRT->occlusionDepth.allocate(resX/occlusion_divisor, resY/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false;
+ if (!mRT->deferredScreen.allocate(resX, resY, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false;
+ //if (!mRT->deferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false;
+ if (!mRT->occlusionDepth.allocate(resX/occlusion_divisor, resY/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false;
if (!addDeferredAttachments(mRT->deferredScreen)) return false;
GLuint screenFormat = GL_RGBA16;
- if (!mRT->screen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false;
+ if (!mRT->screen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false;
mRT->deferredScreen.shareDepthBuffer(mRT->screen);
@@ -861,7 +863,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
if (shadow_detail > 0 || ssao || RenderDepthOfField || samples > 0)
{ //only need mRT->deferredLight for shadows OR ssao OR dof OR fxaa
- if (!mRT->deferredLight.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
+ if (!mRT->deferredLight.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE)) return false;
}
else
{
@@ -889,7 +891,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
//mRT->deferredDepth.release();
mRT->occlusionDepth.release();
- if (!mRT->screen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
+ if (!mRT->screen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_TEXTURE, FALSE)) return false;
}
gGL.getTexUnit(0)->disable();
@@ -1077,6 +1079,7 @@ void LLPipeline::refreshCachedSettings()
CameraMaxCoF = gSavedSettings.getF32("CameraMaxCoF");
CameraDoFResScale = gSavedSettings.getF32("CameraDoFResScale");
RenderAutoHideSurfaceAreaLimit = gSavedSettings.getF32("RenderAutoHideSurfaceAreaLimit");
+ RenderScreenSpaceReflections = gSavedSettings.getBOOL("RenderScreenSpaceReflections");
RenderSpotLight = nullptr;
updateRenderDeferred();
@@ -2543,7 +2546,7 @@ void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& d
vert[1].set(-1,-3,0);
vert[2].set(3,1,0);
- if (source.getUsage() == LLTexUnit::TT_RECT_TEXTURE)
+ if (source.getUsage() == LLTexUnit::TT_TEXTURE)
{
shader = &gDownsampleDepthRectProgram;
shader->bind();
@@ -3918,7 +3921,7 @@ void LLPipeline::postSort(LLCamera& camera)
LL_PUSH_CALLSTACKS();
// only render if the flag is set. The flag is only set if we are in edit mode or the toggle is set in the menus
- if (LLFloaterReg::instanceVisible("beacons") && !sShadowRender)
+ if (LLFloaterReg::instanceVisible("beacons") && !sShadowRender && !gCubeSnapshot)
{
if (sRenderScriptedTouchBeacons)
{
@@ -3971,12 +3974,12 @@ void LLPipeline::postSort(LLCamera& camera)
}
LL_PUSH_CALLSTACKS();
// If managing your telehub, draw beacons at telehub and currently selected spawnpoint.
- if (LLFloaterTelehub::renderBeacons() && !sShadowRender)
+ if (LLFloaterTelehub::renderBeacons() && !sShadowRender && !gCubeSnapshot)
{
LLFloaterTelehub::addBeacons();
}
- if (!sShadowRender)
+ if (!sShadowRender && !gCubeSnapshot)
{
mSelectedFaces.clear();
@@ -7573,13 +7576,6 @@ void LLPipeline::renderFinalize()
enableLightsFullbright();
- gGL.matrixMode(LLRender::MM_PROJECTION);
- gGL.pushMatrix();
- gGL.loadIdentity();
- gGL.matrixMode(LLRender::MM_MODELVIEW);
- gGL.pushMatrix();
- gGL.loadIdentity();
-
LLGLDisable test(GL_ALPHA_TEST);
gGL.setColorMask(true, true);
@@ -7587,13 +7583,64 @@ void LLPipeline::renderFinalize()
if (!gCubeSnapshot)
{
+ if (RenderScreenSpaceReflections)
+ {
+ LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - screen space reflections");
+ LL_PROFILE_GPU_ZONE("screen space reflections");
+ LLStrider<LLVector3> vert;
+ mDeferredVB->getVertexStrider(vert);
+
+ vert[0].set(-1, 1, 0);
+ vert[1].set(-1, -3, 0);
+ vert[2].set(3, 1, 0);
+
+ // Make sure the deferred VB is a full screen triangle.
+ mDeferredVB->getVertexStrider(vert);
+
+ bindDeferredShader(gPostScreenSpaceReflectionProgram, NULL);
+ mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
+
+ // Provide our projection matrix.
+ auto camProj = LLViewerCamera::getInstance()->getProjection();
+ glh::matrix4f projection = get_current_projection();
+ projection.set_row(0, glh::vec4f(camProj.mMatrix[0][0], camProj.mMatrix[0][1], camProj.mMatrix[0][2], camProj.mMatrix[0][3]));
+ projection.set_row(0, glh::vec4f(camProj.mMatrix[1][0], camProj.mMatrix[1][1], camProj.mMatrix[1][2], camProj.mMatrix[1][3]));
+ projection.set_row(0, glh::vec4f(camProj.mMatrix[2][0], camProj.mMatrix[2][1], camProj.mMatrix[2][2], camProj.mMatrix[2][3]));
+ projection.set_row(0, glh::vec4f(camProj.mMatrix[3][0], camProj.mMatrix[3][1], camProj.mMatrix[3][2], camProj.mMatrix[3][3]));
+ gPostScreenSpaceReflectionProgram.uniformMatrix4fv(LLShaderMgr::PROJECTION_MATRIX, 1, FALSE, projection.m);
+
+ // We need linear depth.
+ static LLStaticHashedString zfar("zFar");
+ static LLStaticHashedString znear("zNear");
+ float nearClip = LLViewerCamera::getInstance()->getNear();
+ float farClip = LLViewerCamera::getInstance()->getFar();
+ gPostScreenSpaceReflectionProgram.uniform1f(zfar, farClip);
+ gPostScreenSpaceReflectionProgram.uniform1f(znear, nearClip);
+
+ LLRenderTarget *screen_target = &mRT->screen;
+
+ screen_target->bindTarget();
+ S32 channel = gPostScreenSpaceReflectionProgram.enableTexture(LLShaderMgr::DIFFUSE_MAP, mRT->fxaaBuffer.getUsage());
+ if (channel > -1)
+ {
+ screen_target->bindTexture(0, channel, LLTexUnit::TFO_POINT);
+
+ }
+
+ {
+ LLGLDisable blend(GL_BLEND);
+ LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
+ stop_glerror();
+ mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3);
+ stop_glerror();
+ }
+
+ unbindDeferredShader(gPostScreenSpaceReflectionProgram);
+
+ screen_target->flush();
+ }
+
// gamma correct lighting
- gGL.matrixMode(LLRender::MM_PROJECTION);
- gGL.pushMatrix();
- gGL.loadIdentity();
- gGL.matrixMode(LLRender::MM_MODELVIEW);
- gGL.pushMatrix();
- gGL.loadIdentity();
{
LL_PROFILE_GPU_ZONE("gamma correct");
@@ -7639,20 +7686,7 @@ void LLPipeline::renderFinalize()
screen_target->flush();
}
- gGL.matrixMode(LLRender::MM_PROJECTION);
- gGL.popMatrix();
- gGL.matrixMode(LLRender::MM_MODELVIEW);
- gGL.popMatrix();
-
LLVertexBuffer::unbind();
-
- if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
- {
- // Render debugging beacons.
- gObjectList.renderObjectBeacons();
- gObjectList.resetObjectBeacons();
- gSky.addSunMoonBeacons();
- }
}
if (sRenderGlow)
@@ -7996,8 +8030,8 @@ void LLPipeline::renderFinalize()
shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF);
shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale);
- shader->uniform1f(LLShaderMgr::DOF_WIDTH, dof_width - 1);
- shader->uniform1f(LLShaderMgr::DOF_HEIGHT, dof_height - 1);
+ shader->uniform1f(LLShaderMgr::DOF_WIDTH, (dof_width - 1) / (F32)mRT->screen.getWidth());
+ shader->uniform1f(LLShaderMgr::DOF_HEIGHT, (dof_height - 1) / (F32)mRT->screen.getHeight());
gGL.begin(LLRender::TRIANGLE_STRIP);
gGL.texCoord2f(tc1.mV[0], tc1.mV[1]);
@@ -8208,11 +8242,6 @@ void LLPipeline::renderFinalize()
GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
}*/
- gGL.matrixMode(LLRender::MM_PROJECTION);
- gGL.popMatrix();
- gGL.matrixMode(LLRender::MM_MODELVIEW);
- gGL.popMatrix();
-
LLVertexBuffer::unbind();
LLGLState::checkStates();
@@ -8233,24 +8262,28 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_
if (channel > -1)
{
deferred_target->bindTexture(0,channel, LLTexUnit::TFO_POINT); // frag_data[0]
+ gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
}
channel = shader.enableTexture(LLShaderMgr::DEFERRED_SPECULAR, deferred_target->getUsage());
if (channel > -1)
{
deferred_target->bindTexture(1, channel, LLTexUnit::TFO_POINT); // frag_data[1]
+ gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
}
channel = shader.enableTexture(LLShaderMgr::DEFERRED_NORMAL, deferred_target->getUsage());
if (channel > -1)
{
deferred_target->bindTexture(2, channel, LLTexUnit::TFO_POINT); // frag_data[2]
+ gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
}
channel = shader.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE, deferred_target->getUsage());
if (channel > -1)
{
deferred_target->bindTexture(3, channel, LLTexUnit::TFO_POINT); // frag_data[3]
+ gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
}
channel = shader.enableTexture(LLShaderMgr::DEFERRED_BRDF_LUT, LLTexUnit::TT_TEXTURE);
@@ -8275,14 +8308,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_
stop_glerror();
}
#endif
-
- glh::matrix4f projection = get_current_projection();
- glh::matrix4f inv_proj = projection.inverse();
-
- if (shader.getUniformLocation(LLShaderMgr::INVERSE_PROJECTION_MATRIX) != -1)
- {
- shader.uniformMatrix4fv(LLShaderMgr::INVERSE_PROJECTION_MATRIX, 1, FALSE, inv_proj.m);
- }
if (shader.getUniformLocation(LLShaderMgr::VIEWPORT) != -1)
{
@@ -8515,6 +8540,8 @@ LLVector4 pow4fsrgb(LLVector4 v, F32 f)
void LLPipeline::renderDeferredLighting()
{
+
+
LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE;
LL_PROFILE_GPU_ZONE("renderDeferredLighting");
if (!sCull)
@@ -8587,12 +8614,6 @@ void LLPipeline::renderDeferredLighting()
mat.mult_matrix_vec(tc_moon);
mTransformedMoonDir.set(tc_moon.v);
- gGL.pushMatrix();
- gGL.loadIdentity();
- gGL.matrixMode(LLRender::MM_PROJECTION);
- gGL.pushMatrix();
- gGL.loadIdentity();
-
if (RenderDeferredSSAO || RenderShadowDetail > 0)
{
LL_PROFILE_GPU_ZONE("sun program");
@@ -8675,15 +8696,17 @@ void LLPipeline::renderDeferredLighting()
LLVector3 gauss[32]; // xweight, yweight, offset
+ F32 screenPixelSize = 1.f / screen_target->getWidth();
+
for (U32 i = 0; i < kern_length; i++)
{
gauss[i].mV[0] = llgaussian(x, go.mV[0]);
gauss[i].mV[1] = llgaussian(x, go.mV[1]);
gauss[i].mV[2] = x;
- x += 1.f;
+ x += screenPixelSize;
}
- gDeferredBlurLightProgram.uniform2f(sDelta, 1.f, 0.f);
+ gDeferredBlurLightProgram.uniform2f(sDelta, screenPixelSize, 0.f);
gDeferredBlurLightProgram.uniform1f(sDistFactor, dist_factor);
gDeferredBlurLightProgram.uniform3fv(sKern, kern_length, gauss[0].mV);
gDeferredBlurLightProgram.uniform1f(sKernScale, blur_size * (kern_length / 2.f - 0.5f));
@@ -8718,14 +8741,6 @@ void LLPipeline::renderDeferredLighting()
}
}
- stop_glerror();
- gGL.popMatrix();
- stop_glerror();
- gGL.matrixMode(LLRender::MM_MODELVIEW);
- stop_glerror();
- gGL.popMatrix();
- stop_glerror();
-
screen_target->bindTarget();
// clear color buffer here - zeroing alpha (glow) is important or it will accumulate against sky
glClearColor(0, 0, 0, 0);
@@ -8760,19 +8775,11 @@ void LLPipeline::renderDeferredLighting()
LLGLDisable test(GL_ALPHA_TEST);
// full screen blit
- gGL.pushMatrix();
- gGL.loadIdentity();
- gGL.matrixMode(LLRender::MM_PROJECTION);
- gGL.pushMatrix();
- gGL.loadIdentity();
mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3);
- gGL.popMatrix();
- gGL.matrixMode(LLRender::MM_MODELVIEW);
- gGL.popMatrix();
}
unbindDeferredShader(LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram);
@@ -8974,12 +8981,6 @@ void LLPipeline::renderDeferredLighting()
LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - fullscreen lights");
LLGLDepthTest depth(GL_FALSE);
LL_PROFILE_GPU_ZONE("fullscreen lights");
- // full screen blit
- gGL.pushMatrix();
- gGL.loadIdentity();
- gGL.matrixMode(LLRender::MM_PROJECTION);
- gGL.pushMatrix();
- gGL.loadIdentity();
U32 count = 0;
@@ -9048,13 +9049,10 @@ void LLPipeline::renderDeferredLighting()
gDeferredMultiSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION);
unbindDeferredShader(gDeferredMultiSpotLightProgram);
-
- gGL.popMatrix();
- gGL.matrixMode(LLRender::MM_MODELVIEW);
- gGL.popMatrix();
}
}
+
gGL.setColorMask(true, true);
}
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 7bad1cbe87..c61fbd8404 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -1026,6 +1026,7 @@ public:
static F32 CameraMaxCoF;
static F32 CameraDoFResScale;
static F32 RenderAutoHideSurfaceAreaLimit;
+ static bool RenderScreenSpaceReflections;
};
void render_bbox(const LLVector3 &min, const LLVector3 &max);
diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml
index b9ca0108b6..9ee161e611 100644
--- a/indra/newview/skins/default/xui/en/floater_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_stats.xml
@@ -133,6 +133,12 @@
label="Bound Mem"
stat="glboundmemstat"/>
</stat_view>
+ <stat_view name="material"
+ label="Material">
+ <stat_bar name="nummaterials"
+ label="Count"
+ stat="nummaterials"/>
+ </stat_view>
<stat_view name="memory"
label="Memory Usage">
<stat_bar name="LLTrace"