summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorPtolemy <ptolemy@lindenlab.com>2022-08-31 10:16:24 -0700
committerPtolemy <ptolemy@lindenlab.com>2022-08-31 10:16:24 -0700
commit71115a7a2727301dbf8ba62a082cc9fa1d310a8d (patch)
tree1fff229e1dd5365945bd850ab1e84c8ca693846d /indra
parent5c0e201cd61cf7b29b8871864c8fc7f90c82b5cd (diff)
parent8eaee1f033d9dac892e749cc65416e149021d8f6 (diff)
SL-17703: Fix merge
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl26
-rw-r--r--indra/newview/llviewertexture.cpp2
-rw-r--r--indra/newview/llviewertexture.h1
-rw-r--r--indra/newview/llviewertexturelist.cpp5
-rw-r--r--indra/newview/pipeline.cpp5
-rw-r--r--indra/newview/skins/default/textures/default_irradiance.pngbin0 -> 48853 bytes
6 files changed, 38 insertions, 1 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 34ebb67c3c..fe829edb88 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -27,6 +27,10 @@
#define PBR_USE_IBL 1
#define PBR_USE_SUN 1
+#define PBR_USE_LINEAR_ALBEDO 1
+#define PBR_USE_DEFAULT_IRRADIANCE 0 // PBR: irradiance, skins/default/textures/default_irradiance.png
+#define PBR_USE_IRRADIANCE_HACK 1
+
#define DEBUG_PBR_LIGHT_TYPE 0 // Output no global light to make it easier to see pointLight and spotLight
#define DEBUG_PBR_PACKORM0 0 // Rough=0, Metal=0
#define DEBUG_PBR_PACKORM1 0 // Rough=1, Metal=1
@@ -135,6 +139,9 @@ uniform sampler2DRect diffuseRect;
uniform sampler2DRect specularRect;
uniform sampler2DRect normalMap;
uniform sampler2DRect emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
+uniform sampler2D altDiffuseMap; // PBR: irradiance, skins/default/textures/default_irradiance.png
+
+const float M_PI = 3.14159265;
#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO)
uniform sampler2DRect lightMap;
@@ -295,7 +302,11 @@ void main()
float bv = clamp(dot(b,v),0,1);
// Reference: getMetallicRoughnessInfo
+#if PBR_USE_LINEAR_ALBEDO
+ vec3 base = diffuse.rgb;
+#else
vec3 base = linear_to_srgb(diffuse.rgb);
+#endif
float perceptualRough = packedORM.g; // NOTE: do NOT clamp here to be consistent with Blender, Blender is wrong and Substance is right
vec3 c_diff, reflect0, reflect90;
float alphaRough, specWeight;
@@ -321,7 +332,14 @@ void main()
#if DEBUG_PBR_IRRADIANCE_RAW
vec3 debug_irradiance = irradiance;
#endif
+
+#if PBR_USE_DEFAULT_IRRADIANCE
+ vec2 iruv = vec2(0.5f + 0.5f * atan(reflectVN.z, reflectVN.x) / M_PI, 1.f - acos(reflectVN.y) / M_PI);
+ irradiance = texture2D(altDiffuseMap, iruv).rgb * ambocc;
+#endif
+#if PBR_USE_IRRADIANCE_HACK
irradiance = max(amblit,irradiance) * ambocc;
+#endif
specLight = srgb_to_linear(specLight);
#if DEBUG_PBR_SPECLIGHT051
specLight = vec3(0,0.5,1.0);
@@ -365,8 +383,13 @@ void main()
#endif
// scol = sun shadow
vec3 intensity = ambocc * sunColor * nl * scol;
+#if PBR_USE_LINEAR_ALBEDO
+ vec3 sunDiffuse = intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh);
+ vec3 sunSpec = intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh);
+#else
vec3 sunDiffuse = base * intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh);
vec3 sunSpec = intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh);
+#endif
bloom = dot(sunSpec, sunSpec) / (scale * scale * scale);
#if DEBUG_PBR_SUN_SPEC_FRESNEL
@@ -577,9 +600,11 @@ void main()
#endif
#if DEBUG_PBR_IRRADIANCE_RAW
color.rgb = debug_irradiance;
+ bloom = 0;
#endif
#if DEBUG_PBR_IRRADIANCE
color.rgb = irradiance;
+ bloom = 0;
#endif
#if DEBUG_PBR_KSPEC
color.rgb = kSpec;
@@ -633,6 +658,7 @@ void main()
#if DEBUG_PBR_LIGHT_TYPE
color.rgb = vec3(0);
#endif
+
frag_color.rgb = color.rgb; // PBR is done in linear
}
else
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 1a0471186f..52294ec487 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -76,6 +76,7 @@ LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sWhiteImagep = NULL;
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultImagep = NULL;
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sSmokeImagep = NULL;
LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sFlatNormalImagep = NULL;
+LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultIrradiancePBRp;
LLViewerMediaTexture::media_map_t LLViewerMediaTexture::sMediaMap;
LLTexturePipelineTester* LLViewerTextureManager::sTesterp = NULL;
F32 LLViewerFetchedTexture::sMaxVirtualSize = 8192.f*8192.f;
@@ -457,6 +458,7 @@ void LLViewerTextureManager::cleanup()
LLViewerFetchedTexture::sWhiteImagep = NULL;
LLViewerFetchedTexture::sFlatNormalImagep = NULL;
+ LLViewerFetchedTexture::sDefaultIrradiancePBRp = NULL;
LLViewerMediaTexture::cleanUpClass();
}
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index a57886ff6f..312e2ca365 100644
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -530,6 +530,7 @@ public:
static LLPointer<LLViewerFetchedTexture> sDefaultImagep; // "Default" texture for error cases, the only case of fetched texture which is generated in local.
static LLPointer<LLViewerFetchedTexture> sSmokeImagep; // Old "Default" translucent texture
static LLPointer<LLViewerFetchedTexture> sFlatNormalImagep; // Flat normal map denoting no bumpiness on a surface
+ static LLPointer<LLViewerFetchedTexture> sDefaultIrradiancePBRp; // PBR: irradiance
};
//
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index f2d0f837ba..9cbbf1c276 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -120,7 +120,10 @@ void LLViewerTextureList::doPreloadImages()
// Set the default flat normal map
LLViewerFetchedTexture::sFlatNormalImagep = LLViewerTextureManager::getFetchedTextureFromFile("flatnormal.tga", FTT_LOCAL_FILE, MIPMAP_NO, LLViewerFetchedTexture::BOOST_BUMP);
-
+
+ // PBR: irradiance
+ LLViewerFetchedTexture::sDefaultIrradiancePBRp = LLViewerTextureManager::getFetchedTextureFromFile("default_irradiance.png", FTT_LOCAL_FILE, MIPMAP_YES, LLViewerFetchedTexture::BOOST_UI);
+
image_list->initFromFile();
// turn off clamping and bilinear filtering for uv picking images
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 91d276c8df..67f0ea68c1 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -8643,6 +8643,11 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target)
soften_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0);
soften_shader.uniform4fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV);
+ if (!LLPipeline::sUnderWaterRender && LLPipeline::sRenderPBR)
+ {
+ soften_shader.bindTexture(LLShaderMgr::ALTERNATE_DIFFUSE_MAP, LLViewerFetchedTexture::sDefaultIrradiancePBRp); // PBR: irradiance
+ }
+
if(LLPipeline::sRenderPBR)
{
LLVector3 cameraAtAxis = LLViewerCamera::getInstance()->getAtAxis();
diff --git a/indra/newview/skins/default/textures/default_irradiance.png b/indra/newview/skins/default/textures/default_irradiance.png
new file mode 100644
index 0000000000..899e0ddf2a
--- /dev/null
+++ b/indra/newview/skins/default/textures/default_irradiance.png
Binary files differ