From d64c881d12461d8600fedf76c783df4a4e7d6b95 Mon Sep 17 00:00:00 2001 From: fo76utils <87907510+fo76utils@users.noreply.github.com> Date: Sun, 16 Jun 2024 22:55:34 +0200 Subject: [PATCH] Starfield rendering fixes: clamp opacity, sRGB emissive tint --- res/shaders/stf_default.frag | 4 ++-- src/gl/renderer.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/res/shaders/stf_default.frag b/res/shaders/stf_default.frag index dc455110..6cd43b59 100644 --- a/res/shaders/stf_default.frag +++ b/res/shaders/stf_default.frag @@ -545,10 +545,10 @@ void main() baseMap.a = mix( baseMap.a, a, layerMask ); break; case 1: - baseMap.a += a * layerMask; + baseMap.a = min( baseMap.a + a * layerMask, 1.0 ); break; case 2: - baseMap.a -= a * layerMask; + baseMap.a = max( baseMap.a - a * layerMask, 0.0 ); break; case 3: baseMap.a *= a * layerMask; diff --git a/src/gl/renderer.cpp b/src/gl/renderer.cpp index c1c32f15..47975212 100644 --- a/src/gl/renderer.cpp +++ b/src/gl/renderer.cpp @@ -918,15 +918,15 @@ bool Renderer::setupProgramSF( Program * prog, Shape * mesh ) const CE2Material::LayeredEmissiveSettings * sp = mat->layeredEmissiveSettings; prog->uni1b_l( prog->uniLocation("lm.layeredEmissivity.isEnabled"), sp->isEnabled ); prog->uni1i_l( prog->uniLocation("lm.layeredEmissivity.firstLayerIndex"), sp->layer1Index ); - prog->uni4c_l( prog->uniLocation("lm.layeredEmissivity.firstLayerTint"), sp->layer1Tint ); + prog->uni4c_l( prog->uniLocation("lm.layeredEmissivity.firstLayerTint"), sp->layer1Tint, true ); prog->uni1i_l( prog->uniLocation("lm.layeredEmissivity.firstLayerMaskIndex"), sp->layer1MaskIndex ); prog->uni1i_l( prog->uniLocation("lm.layeredEmissivity.secondLayerIndex"), ( sp->layer2Active ? int(sp->layer2Index) : -1 ) ); - prog->uni4c_l( prog->uniLocation("lm.layeredEmissivity.secondLayerTint"), sp->layer2Tint ); + prog->uni4c_l( prog->uniLocation("lm.layeredEmissivity.secondLayerTint"), sp->layer2Tint, true ); prog->uni1i_l( prog->uniLocation("lm.layeredEmissivity.secondLayerMaskIndex"), sp->layer2MaskIndex ); prog->uni1i_l( prog->uniLocation("lm.layeredEmissivity.firstBlenderIndex"), sp->blender1Index ); prog->uni1i_l( prog->uniLocation("lm.layeredEmissivity.firstBlenderMode"), sp->blender1Mode ); prog->uni1i_l( prog->uniLocation("lm.layeredEmissivity.thirdLayerIndex"), ( sp->layer3Active ? int(sp->layer3Index) : -1 ) ); - prog->uni4c_l( prog->uniLocation("lm.layeredEmissivity.thirdLayerTint"), sp->layer3Tint ); + prog->uni4c_l( prog->uniLocation("lm.layeredEmissivity.thirdLayerTint"), sp->layer3Tint, true ); prog->uni1i_l( prog->uniLocation("lm.layeredEmissivity.thirdLayerMaskIndex"), sp->layer3MaskIndex ); prog->uni1i_l( prog->uniLocation("lm.layeredEmissivity.secondBlenderIndex"), sp->blender2Index ); prog->uni1i_l( prog->uniLocation("lm.layeredEmissivity.secondBlenderMode"), sp->blender2Mode ); @@ -944,7 +944,7 @@ bool Renderer::setupProgramSF( Program * prog, Shape * mesh ) const CE2Material::EmissiveSettings * sp = mat->emissiveSettings; prog->uni1b_l( prog->uniLocation("lm.emissiveSettings.isEnabled"), sp->isEnabled ); prog->uni1i_l( prog->uniLocation("lm.emissiveSettings.emissiveSourceLayer"), sp->sourceLayer ); - prog->uni4f_l( prog->uniLocation("lm.emissiveSettings.emissiveTint"), sp->emissiveTint ); + prog->uni4srgb_l( prog->uniLocation("lm.emissiveSettings.emissiveTint"), sp->emissiveTint ); prog->uni1i_l( prog->uniLocation("lm.emissiveSettings.emissiveMaskSourceBlender"), sp->maskSourceBlender ); prog->uni1f_l( prog->uniLocation("lm.emissiveSettings.emissiveClipThreshold"), sp->clipThreshold ); prog->uni1b_l( prog->uniLocation("lm.emissiveSettings.adaptiveEmittance"), sp->adaptiveEmittance );