Skip to content

Commit

Permalink
Add Contrast Adaptive Sharpening post process effect(secondlife#2399)
Browse files Browse the repository at this point in the history
  • Loading branch information
RyeMutt committed Aug 24, 2024
1 parent 45b2d69 commit 0325f67
Show file tree
Hide file tree
Showing 8 changed files with 2,716 additions and 4 deletions.
46 changes: 46 additions & 0 deletions indra/llrender/llglslshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,34 @@ void LLGLSLShader::uniform4fv(U32 index, U32 count, const GLfloat* v)
}
}

void LLGLSLShader::uniform4uiv(U32 index, U32 count, const GLuint* v)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
llassert(sCurBoundShaderPtr == this);

if (mProgramObject)
{
if (mUniform.size() <= index)
{
LL_WARNS_ONCE("Shader") << "Uniform index out of bounds. Size: " << (S32)mUniform.size() << " index: " << index << LL_ENDL;
llassert(false);
return;
}

if (mUniform[index] >= 0)
{
const auto& iter = mValue.find(mUniform[index]);
LLVector4 vec((F32)v[0], (F32)v[1], (F32)v[2], (F32)v[3]);
if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
glUniform4uiv(mUniform[index], count, v);
mValue[mUniform[index]] = vec;
}
}
}
}

void LLGLSLShader::uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, const GLfloat* v)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
Expand Down Expand Up @@ -1886,6 +1914,24 @@ void LLGLSLShader::uniform4fv(const LLStaticHashedString& uniform, U32 count, co
}
}

void LLGLSLShader::uniform4uiv(const LLStaticHashedString& uniform, U32 count, const GLuint* v)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
GLint location = getUniformLocation(uniform);

if (location >= 0)
{
LLVector4 vec((F32)v[0], (F32)v[1], (F32)v[2], (F32)v[3]);
const auto& iter = mValue.find(location);
if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
glUniform4uiv(location, count, v);
mValue[location] = vec;
}
}
}

void LLGLSLShader::uniformMatrix4fv(const LLStaticHashedString& uniform, U32 count, GLboolean transpose, const GLfloat* v)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
Expand Down
2 changes: 2 additions & 0 deletions indra/llrender/llglslshader.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ class LLGLSLShader
void uniform2fv(U32 index, U32 count, const GLfloat* v);
void uniform3fv(U32 index, U32 count, const GLfloat* v);
void uniform4fv(U32 index, U32 count, const GLfloat* v);
void uniform4uiv(U32 index, U32 count, const GLuint* v);
void uniform2i(const LLStaticHashedString& uniform, GLint i, GLint j);
void uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, const GLfloat* v);
void uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, const GLfloat* v);
Expand All @@ -223,6 +224,7 @@ class LLGLSLShader
void uniform2fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v);
void uniform3fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v);
void uniform4fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v);
void uniform4uiv(const LLStaticHashedString& uniform, U32 count, const GLuint* v);
void uniformMatrix4fv(const LLStaticHashedString& uniform, U32 count, GLboolean transpose, const GLfloat* v);

void setMinimumAlpha(F32 minimum);
Expand Down
22 changes: 22 additions & 0 deletions indra/newview/app_settings/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9810,6 +9810,28 @@
<key>Value</key>
<string>00000000-0000-0000-0000-000000000000</string>
</map>
<key>RenderCAS</key>
<map>
<key>Comment</key>
<string>Whether to enable Contrast Adaptive Sharpening or not</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>1</integer>
</map>
<key>RenderCASSharpness</key>
<map>
<key>Comment</key>
<string>Level of sharpening to apply via Contrast Adaptive Sharpening (0.0 - 1.0)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>0.4</real>
</map>
<key>ReplaySession</key>
<map>
<key>Comment</key>
Expand Down
Loading

0 comments on commit 0325f67

Please sign in to comment.