From 6846600e3ef1eec7fade19f61d2d45614ae1a8b0 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 2 Feb 2024 13:49:06 -0600 Subject: #677 Fix terrain clipping and tweak hero probe mixing with radiance --- .../shaders/class1/deferred/terrainV.glsl | 3 +- .../shaders/class3/deferred/softenLightF.glsl | 34 +++++++++++++++++++--- indra/newview/llviewershadermgr.cpp | 1 + 3 files changed, 33 insertions(+), 5 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl index 33a78fd26d..8e1e4b54d5 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl @@ -25,6 +25,7 @@ uniform mat3 normal_matrix; uniform mat4 texture_matrix0; +uniform mat4 modelview_matrix; uniform mat4 modelview_projection_matrix; in vec3 position; @@ -59,7 +60,7 @@ void main() vec4 t_pos = modelview_projection_matrix * pre_pos; gl_Position = t_pos; - pos = t_pos.xyz; + pos = (modelview_matrix*pre_pos).xyz; vary_normal = normalize(normal_matrix * normal); diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index b49c3386db..be180b877f 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -60,6 +60,7 @@ uniform float ssao_irradiance_max; #endif // Inputs +uniform vec4 clipPlane; uniform mat3 env_mat; uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; @@ -189,6 +190,19 @@ void main() sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, norm.xyz, gloss, false, amblit_linear); + #ifdef HERO_PROBES + float clipDist = dot(pos.xyz, clipPlane.xyz) + clipPlane.w; + if (clipDist > 0.0 && clipDist < 0.1 && perceptualRoughness < 0.2) + { + vec3 refnormpersp = reflect(pos.xyz, norm.xyz); + if (dot(refnormpersp.xyz, clipPlane.xyz) > 0.0) + { + radiance = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), perceptualRoughness*11).xyz; + } + } + #endif + + adjustIrradiance(irradiance, ambocc); vec3 diffuseColor; @@ -198,11 +212,11 @@ void main() vec3 v = -normalize(pos.xyz); color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten); - #ifdef HERO_PROBES + /*#ifdef HERO_PROBES vec3 refnormpersp = reflect(pos.xyz, norm.xyz); color = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0 - gloss) * 11).xyz * specularColor; - #endif + #endif*/ } else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS)) { @@ -226,6 +240,18 @@ void main() sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, norm.xyz, spec.a, envIntensity, false, amblit_linear); + #ifdef HERO_PROBES + float clipDist = dot(pos.xyz, clipPlane.xyz) + clipPlane.w; + if (clipDist > 0.0 && clipDist < 0.1 && spec.a > 0.8) + { + vec3 refnormpersp = reflect(pos.xyz, norm.xyz); + if (dot(refnormpersp.xyz, clipPlane.xyz) > 0.0) + { + radiance = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0-spec.a)*11).xyz; + } + } + #endif + adjustIrradiance(irradiance, ambocc); // apply lambertian IBL only (see pbrIbl) @@ -261,9 +287,9 @@ void main() // add radiance map applyGlossEnv(color, glossenv, spec, pos.xyz, norm.xyz); - #ifdef HERO_PROBES + /*#ifdef HERO_PROBES color = textureLod(heroProbes, vec4(env_mat * refnormpersp, 0), (1.0 - spec.a) * 11).xyz * spec.rgb; - #endif + #endif*/ } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index d0a54d8cfc..0aa0e13270 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -298,6 +298,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gDeferredPBROpaqueProgram); mShaderList.push_back(&gDeferredPBRAlphaProgram); mShaderList.push_back(&gDeferredAvatarProgram); + mShaderList.push_back(&gDeferredTerrainProgram); } LLViewerShaderMgr::~LLViewerShaderMgr() -- cgit v1.2.3