From 01e5caade3d85eb618c1d7f16eb2e3972d1f65f9 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 12 Apr 2021 16:58:18 -0700 Subject: SL-14113 Fix moon haze --- .../shaders/class1/deferred/cloudsF.glsl | 2 +- .../shaders/class1/deferred/moonF.glsl | 6 +++ .../shaders/class1/deferred/starsF.glsl | 7 ++- .../shaders/class1/environment/moonF.glsl | 51 ++++++++++++++++++++++ .../shaders/class1/environment/moonV.glsl | 38 ++++++++++++++++ .../shaders/class1/environment/starsF.glsl | 51 ++++++++++++++++++++++ .../shaders/class1/environment/starsV.glsl | 41 +++++++++++++++++ .../shaders/class1/windlight/moonF.glsl | 7 +++ .../shaders/class2/windlight/cloudsF.glsl | 6 +++ indra/newview/lldrawpoolsky.cpp | 19 ++++++++ indra/newview/lldrawpoolwlsky.cpp | 13 +++--- indra/newview/llviewershadermgr.cpp | 33 +++++++++++++- indra/newview/llviewershadermgr.h | 2 + 13 files changed, 267 insertions(+), 9 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class1/environment/moonF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/environment/moonV.glsl create mode 100644 indra/newview/app_settings/shaders/class1/environment/starsF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/environment/starsV.glsl (limited to 'indra/newview') diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index ae1ac5de7f..187fed72e1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -126,6 +126,6 @@ void main() frag_data[1] = vec4(0.0,0.0,0.0,0.0); frag_data[2] = vec4(0,0,0,1); - gl_FragDepth = 0.99995f; + gl_FragDepth = 0.999985; // SL-14113 Stars and Clouds need same depth } diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index 35068899ee..5906194437 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -55,6 +55,12 @@ void main() fade = clamp( moon_dir.z*moon_dir.z*4.0, 0.0, 1.0 ); vec4 c = texture2D(diffuseMap, vary_texcoord0.xy); + + // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible + // Moon texture has transparent pixels <0x55,0x55,0x55,0x00> + if (c.a <= 2./255.) // 0.00784 + discard; + // c.rgb = srgb_to_linear(c.rgb); c.rgb *= moonlight_color.rgb; c.rgb *= moon_brightness; diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl index bac79a9fdc..50f10ad0fa 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -46,8 +46,13 @@ float twinkle(){ return abs(d); } +// See: +// ALM off: class1/environment/starsF.glsl +// ALM on : class1/deferred/starsF.glsl void main() { + // camera above water: class1\deferred\starsF.glsl + // camera below water: starsF.glsl vec4 col_a = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col_b = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col = mix(col_b, col_a, blend_factor); @@ -62,6 +67,6 @@ void main() frag_data[1] = vec4(0.0f); frag_data[2] = vec4(0.0, 1.0, 0.0, 1.0); - gl_FragDepth = 0.99995f; + gl_FragDepth = 0.999995f; // SL-14113 Moon Haze -- Stars need to depth test behind the moon } diff --git a/indra/newview/app_settings/shaders/class1/environment/moonF.glsl b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl new file mode 100644 index 0000000000..e1592c19fb --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl @@ -0,0 +1,51 @@ +/** + * @file class1/environment/moonF.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, 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$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2D tex0; + +VARYING vec2 vary_texcoord0; + +// See: +// AS off: class1/environment/moonF.glsl +// ALM off: class1/windlight/moonF.glsl +// ALM on : class1/deferred/moonF.glsl +void main() +{ + vec4 color = texture2D(tex0, vary_texcoord0.xy); + + // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible + // Moon texture has transparent pixels <0x55,0x55,0x55,0x00> + if (color.a <= 2./255.) // 0.00784 + discard; + + frag_color = color; + gl_FragDepth = 0.999985f; // SL-14113 Moon is infront of stars +} diff --git a/indra/newview/app_settings/shaders/class1/environment/moonV.glsl b/indra/newview/app_settings/shaders/class1/environment/moonV.glsl new file mode 100644 index 0000000000..1fc421a295 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/moonV.glsl @@ -0,0 +1,38 @@ +/** + * @file class1\environment\moonV.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, 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 modelview_projection_matrix; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec2 texcoord0; + +VARYING vec2 vary_texcoord0; + +void main() +{ + gl_Position = modelview_projection_matrix * vec4(position, 1); + vary_texcoord0 = texcoord0; +} + diff --git a/indra/newview/app_settings/shaders/class1/environment/starsF.glsl b/indra/newview/app_settings/shaders/class1/environment/starsF.glsl new file mode 100644 index 0000000000..95ab4cbf8b --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/starsF.glsl @@ -0,0 +1,51 @@ +/** + * @file class1/environment/starsF.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, 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$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2D diffuseMap; + +uniform float custom_alpha; + +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +// See: +// ALM off: class1/environment/starsF.glsl +// ALM on : class1/deferred/starsF.glsl +void main() +{ + vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); + color.rgb = pow(color.rgb, vec3(0.45)); + color.rgb *= vertex_color.rgb; + color.a *= max(custom_alpha, vertex_color.a); + + frag_color = color; + gl_FragDepth = 0.999995f; // SL-14113 Moon Haze -- Stars need to depth test behind the moon +} diff --git a/indra/newview/app_settings/shaders/class1/environment/starsV.glsl b/indra/newview/app_settings/shaders/class1/environment/starsV.glsl new file mode 100644 index 0000000000..6fcfec6b6a --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/starsV.glsl @@ -0,0 +1,41 @@ +/** + * @file class1/environment/starsV.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, 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 modelview_projection_matrix; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec4 diffuse_color; +ATTRIBUTE vec2 texcoord0; + +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +void main() +{ + gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + vary_texcoord0 = texcoord0; + vertex_color = diffuse_color; +} + diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl index 2425a2ad04..327accbd3b 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl @@ -52,6 +52,12 @@ void main() fade = clamp( moon_dir.z*moon_dir.z*4.0, 0.0, 1.0 ); vec4 c = texture2D(diffuseMap, vary_texcoord0.xy); + + // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible + // Moon texture has transparent pixels <0x55,0x55,0x55,0x00> + if (c.a <= 2./255.) // 0.00784 + discard; + // c.rgb = pow(c.rgb, vec3(0.7f)); // can't use "srgb_to_linear(color.rgb)" as that is a deferred only function c.rgb *= moonlight_color.rgb; c.rgb *= moon_brightness; @@ -62,5 +68,6 @@ void main() c.rgb = scaleSoftClip(c.rgb); frag_color = vec4(c.rgb, c.a); + gl_FragDepth = 0.999985f; // SL-14113 } diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index fa928d993e..d89cc69d71 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -127,5 +127,11 @@ void main() /// Gamma correct for WL (soft clip effect). frag_color = vec4(color.rgb, alpha1); + + // SL-14113 Moon Haze -- When the camera is underwater fix clouds clipping into moon + // camera above water: class1\defered\cloudsF.glsl + // camera below water: class2\windlight\coudsV.glsl + // See: starsV.glsl, cloudsV.glsl, moonF.glsl + gl_FragDepth = 0.999985; } diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index b6f55e800a..96b4a91b0f 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -130,13 +130,32 @@ void LLDrawPoolSky::renderSkyFace(U8 index) face->renderIndexed(); } + else // Moon + if (index == LLVOSky::FACE_MOON) + { + LLGLSPipelineDepthTestSkyBox gls_skybox(true, true); // SL-14113 Write depth for moon so stars can test if behind it + + LLGLEnable blend(GL_BLEND); + + // if (LLGLSLShader::sNoFixedFunction) // TODO: Necessary? is this always true? We already bailed on gPipeline.canUseWindLightShaders ... above + LLViewerTexture* tex = face->getTexture(LLRender::DIFFUSE_MAP); + if (tex) + { + gMoonProgram.bind(); // SL-14113 was gOneTextureNoColorProgram + gGL.getTexUnit(0)->bind(tex, true); + face->renderIndexed(); + } + } else // heavenly body faces, no interp... { + LLGLSPipelineDepthTestSkyBox gls_skybox(true, false); // reset to previous + LLGLEnable blend(GL_BLEND); LLViewerTexture* tex = face->getTexture(LLRender::DIFFUSE_MAP); if (tex) { + gOneTextureNoColorProgram.bind(); gGL.getTexUnit(0)->bind(tex, true); face->renderIndexed(); } diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 0c3d8f3098..f788a20e3c 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -270,8 +270,8 @@ void LLDrawPoolWLSky::renderStars(const LLVector3& camPosLocal) const gGL.rotatef(gFrameTimeSeconds*0.01f, 0.f, 0.f, 1.f); if (LLGLSLShader::sNoFixedFunction) { - gCustomAlphaProgram.bind(); - gCustomAlphaProgram.uniform1f(sCustomAlpha, star_alpha.mV[3]); + gStarsProgram.bind(); + gStarsProgram.uniform1f(sCustomAlpha, star_alpha.mV[3]); } else { @@ -288,7 +288,7 @@ void LLDrawPoolWLSky::renderStars(const LLVector3& camPosLocal) const if (LLGLSLShader::sNoFixedFunction) { - gCustomAlphaProgram.unbind(); + gStarsProgram.unbind(); // SL-14113 was gCustomAlphaProgram } else { @@ -476,7 +476,8 @@ void LLDrawPoolWLSky::renderSkyClouds(const LLVector3& camPosLocal, F32 camHeigh void LLDrawPoolWLSky::renderHeavenlyBodies() { - LLGLSPipelineBlendSkyBox gls_skybox(true, false); + //LLGLSPipelineBlendSkyBox gls_skybox(true, false); + LLGLSPipelineBlendSkyBox gls_skybox(true, true); // SL-14113 we need moon to write to depth to clip stars behind LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); gGL.pushMatrix(); @@ -606,8 +607,8 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass) if (gPipeline.canUseWindLightShaders()) { renderSkyHazeDeferred(origin, camHeightLocal); - renderStarsDeferred(origin); renderHeavenlyBodies(); + renderStarsDeferred(origin); renderSkyCloudsDeferred(origin, camHeightLocal, cloud_shader); } gGL.setColorMask(true, true); @@ -625,8 +626,8 @@ void LLDrawPoolWLSky::render(S32 pass) LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); renderSkyHaze(origin, camHeightLocal); + renderHeavenlyBodies(); renderStars(origin); - renderHeavenlyBodies(); renderSkyClouds(origin, camHeightLocal, cloud_shader); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index be5c22e7c3..8eb57799c9 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -78,7 +78,7 @@ LLGLSLShader gTransformTangentProgram; //utility shaders LLGLSLShader gOcclusionProgram; LLGLSLShader gOcclusionCubeProgram; -LLGLSLShader gCustomAlphaProgram; +LLGLSLShader gCustomAlphaProgram; // SL-14113 This used to be used for the stars with Atmospheric Shaders: OFF LLGLSLShader gGlowCombineProgram; LLGLSLShader gSplatTextureRectProgram; LLGLSLShader gGlowCombineFXAAProgram; @@ -148,6 +148,8 @@ LLGLSLShader gSkinnedObjectFullbrightShinyWaterProgram; LLGLSLShader gSkinnedObjectShinySimpleWaterProgram; //environment shaders +LLGLSLShader gMoonProgram; +LLGLSLShader gStarsProgram; LLGLSLShader gTerrainProgram; LLGLSLShader gTerrainWaterProgram; LLGLSLShader gWaterProgram; @@ -819,6 +821,9 @@ void LLViewerShaderMgr::unloadShaders() gWaterProgram.unload(); gWaterEdgeProgram.unload(); gUnderWaterProgram.unload(); + + gMoonProgram.unload(); + gStarsProgram.unload(); gTerrainProgram.unload(); gTerrainWaterProgram.unload(); gGlowProgram.unload(); @@ -1051,6 +1056,32 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() llassert(success); } + if (success) + { + gStarsProgram.mName = "Environment Stars Shader"; + gStarsProgram.mShaderFiles.clear(); + gStarsProgram.mShaderFiles.push_back(make_pair("environment/starsV.glsl", GL_VERTEX_SHADER_ARB)); + gStarsProgram.mShaderFiles.push_back(make_pair("environment/starsF.glsl", GL_FRAGMENT_SHADER_ARB)); + gStarsProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; + success = gStarsProgram.createShader(NULL, NULL); + llassert(success); + } + + if (success) + { + gMoonProgram.mName = "Environment Moon Shader"; + gMoonProgram.mShaderFiles.clear(); + gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonV.glsl", GL_VERTEX_SHADER_ARB)); + gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); + gMoonProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; + success = gMoonProgram.createShader(NULL, NULL); + if (success) + { + gMoonProgram.bind(); + gMoonProgram.uniform1i(sTex0, 0); + } + } + if (!success) { mShaderLevel[SHADER_ENVIRONMENT] = 0; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 081221f15b..5122558a01 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -234,6 +234,8 @@ extern LLGLSLShader gSkinnedObjectFullbrightShinyWaterProgram; extern LLGLSLShader gSkinnedObjectShinySimpleWaterProgram; //environment shaders +extern LLGLSLShader gMoonProgram; +extern LLGLSLShader gStarsProgram; extern LLGLSLShader gTerrainProgram; extern LLGLSLShader gTerrainWaterProgram; extern LLGLSLShader gWaterProgram; -- cgit v1.2.3 From d3cf486ea9eb5b3e7b51141a364a088dbba5054a Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 13 Apr 2021 10:54:02 -0700 Subject: SL-14113 Cleanup typo and cross reference --- indra/newview/app_settings/shaders/class1/deferred/starsF.glsl | 2 +- indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl index 50f10ad0fa..b028c40ed9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -52,7 +52,7 @@ float twinkle(){ void main() { // camera above water: class1\deferred\starsF.glsl - // camera below water: starsF.glsl + // camera below water: class1\environment\starsF.glsl vec4 col_a = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col_b = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col = mix(col_b, col_a, blend_factor); diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index d89cc69d71..1c592402d4 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -129,7 +129,7 @@ void main() frag_color = vec4(color.rgb, alpha1); // SL-14113 Moon Haze -- When the camera is underwater fix clouds clipping into moon - // camera above water: class1\defered\cloudsF.glsl + // camera above water: class1\deferred\cloudsF.glsl // camera below water: class2\windlight\coudsV.glsl // See: starsV.glsl, cloudsV.glsl, moonF.glsl gl_FragDepth = 0.999985; -- cgit v1.2.3 From 41473f7c506d8b9bb719d11ecac13c2ac516ef60 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 13 Apr 2021 11:35:36 -0700 Subject: SL-14113 Cleanup face magic number --- indra/newview/lldrawpoolsky.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index 96b4a91b0f..77b8a1fc32 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -123,7 +123,7 @@ void LLDrawPoolSky::renderSkyFace(U8 index) return; } - if (index < 6) // sky tex...interp + if (index < LLVOSky::FACE_SUN) // sky tex...interp { llassert(mSkyTex); mSkyTex[index].bindTexture(true); // bind the current tex -- cgit v1.2.3 From 9ff19f4d50ed163c4b0ad4255ca618f27f98a3a3 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 13 Apr 2021 11:36:33 -0700 Subject: SL-14113 Cleanup indentation --- indra/newview/lldrawpoolsky.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index 77b8a1fc32..178564b0d4 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -116,17 +116,17 @@ void LLDrawPoolSky::render(S32 pass) void LLDrawPoolSky::renderSkyFace(U8 index) { - LLFace* face = mDrawFace[index]; + LLFace* face = mDrawFace[index]; - if (!face || !face->getGeomCount()) - { - return; - } + if (!face || !face->getGeomCount()) + { + return; + } if (index < LLVOSky::FACE_SUN) // sky tex...interp { llassert(mSkyTex); - mSkyTex[index].bindTexture(true); // bind the current tex + mSkyTex[index].bindTexture(true); // bind the current tex face->renderIndexed(); } -- cgit v1.2.3 From 70527ee66ca869184aba14db73e3ab3f1bd5e1c3 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Mon, 12 Apr 2021 16:58:18 -0700 Subject: SL-14113 Fix moon haze --- .../shaders/class1/deferred/cloudsF.glsl | 2 +- .../shaders/class1/deferred/moonF.glsl | 6 +++ .../shaders/class1/deferred/starsF.glsl | 7 ++- .../shaders/class1/environment/moonF.glsl | 51 ++++++++++++++++++++++ .../shaders/class1/environment/moonV.glsl | 38 ++++++++++++++++ .../shaders/class1/environment/starsF.glsl | 51 ++++++++++++++++++++++ .../shaders/class1/environment/starsV.glsl | 41 +++++++++++++++++ .../shaders/class1/windlight/moonF.glsl | 7 +++ .../shaders/class2/windlight/cloudsF.glsl | 6 +++ indra/newview/lldrawpoolsky.cpp | 19 ++++++++ indra/newview/lldrawpoolwlsky.cpp | 13 +++--- indra/newview/llviewershadermgr.cpp | 33 +++++++++++++- indra/newview/llviewershadermgr.h | 2 + 13 files changed, 267 insertions(+), 9 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class1/environment/moonF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/environment/moonV.glsl create mode 100644 indra/newview/app_settings/shaders/class1/environment/starsF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/environment/starsV.glsl (limited to 'indra/newview') diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index ae1ac5de7f..187fed72e1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -126,6 +126,6 @@ void main() frag_data[1] = vec4(0.0,0.0,0.0,0.0); frag_data[2] = vec4(0,0,0,1); - gl_FragDepth = 0.99995f; + gl_FragDepth = 0.999985; // SL-14113 Stars and Clouds need same depth } diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index 35068899ee..5906194437 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -55,6 +55,12 @@ void main() fade = clamp( moon_dir.z*moon_dir.z*4.0, 0.0, 1.0 ); vec4 c = texture2D(diffuseMap, vary_texcoord0.xy); + + // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible + // Moon texture has transparent pixels <0x55,0x55,0x55,0x00> + if (c.a <= 2./255.) // 0.00784 + discard; + // c.rgb = srgb_to_linear(c.rgb); c.rgb *= moonlight_color.rgb; c.rgb *= moon_brightness; diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl index bac79a9fdc..50f10ad0fa 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -46,8 +46,13 @@ float twinkle(){ return abs(d); } +// See: +// ALM off: class1/environment/starsF.glsl +// ALM on : class1/deferred/starsF.glsl void main() { + // camera above water: class1\deferred\starsF.glsl + // camera below water: starsF.glsl vec4 col_a = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col_b = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col = mix(col_b, col_a, blend_factor); @@ -62,6 +67,6 @@ void main() frag_data[1] = vec4(0.0f); frag_data[2] = vec4(0.0, 1.0, 0.0, 1.0); - gl_FragDepth = 0.99995f; + gl_FragDepth = 0.999995f; // SL-14113 Moon Haze -- Stars need to depth test behind the moon } diff --git a/indra/newview/app_settings/shaders/class1/environment/moonF.glsl b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl new file mode 100644 index 0000000000..e1592c19fb --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl @@ -0,0 +1,51 @@ +/** + * @file class1/environment/moonF.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, 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$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2D tex0; + +VARYING vec2 vary_texcoord0; + +// See: +// AS off: class1/environment/moonF.glsl +// ALM off: class1/windlight/moonF.glsl +// ALM on : class1/deferred/moonF.glsl +void main() +{ + vec4 color = texture2D(tex0, vary_texcoord0.xy); + + // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible + // Moon texture has transparent pixels <0x55,0x55,0x55,0x00> + if (color.a <= 2./255.) // 0.00784 + discard; + + frag_color = color; + gl_FragDepth = 0.999985f; // SL-14113 Moon is infront of stars +} diff --git a/indra/newview/app_settings/shaders/class1/environment/moonV.glsl b/indra/newview/app_settings/shaders/class1/environment/moonV.glsl new file mode 100644 index 0000000000..1fc421a295 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/moonV.glsl @@ -0,0 +1,38 @@ +/** + * @file class1\environment\moonV.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, 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 modelview_projection_matrix; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec2 texcoord0; + +VARYING vec2 vary_texcoord0; + +void main() +{ + gl_Position = modelview_projection_matrix * vec4(position, 1); + vary_texcoord0 = texcoord0; +} + diff --git a/indra/newview/app_settings/shaders/class1/environment/starsF.glsl b/indra/newview/app_settings/shaders/class1/environment/starsF.glsl new file mode 100644 index 0000000000..95ab4cbf8b --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/starsF.glsl @@ -0,0 +1,51 @@ +/** + * @file class1/environment/starsF.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, 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$ + */ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2D diffuseMap; + +uniform float custom_alpha; + +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +// See: +// ALM off: class1/environment/starsF.glsl +// ALM on : class1/deferred/starsF.glsl +void main() +{ + vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); + color.rgb = pow(color.rgb, vec3(0.45)); + color.rgb *= vertex_color.rgb; + color.a *= max(custom_alpha, vertex_color.a); + + frag_color = color; + gl_FragDepth = 0.999995f; // SL-14113 Moon Haze -- Stars need to depth test behind the moon +} diff --git a/indra/newview/app_settings/shaders/class1/environment/starsV.glsl b/indra/newview/app_settings/shaders/class1/environment/starsV.glsl new file mode 100644 index 0000000000..6fcfec6b6a --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/starsV.glsl @@ -0,0 +1,41 @@ +/** + * @file class1/environment/starsV.glsl + * + * $LicenseInfo:firstyear=2021&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2021, 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 modelview_projection_matrix; + +ATTRIBUTE vec3 position; +ATTRIBUTE vec4 diffuse_color; +ATTRIBUTE vec2 texcoord0; + +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; + +void main() +{ + gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + vary_texcoord0 = texcoord0; + vertex_color = diffuse_color; +} + diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl index 2425a2ad04..327accbd3b 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl @@ -52,6 +52,12 @@ void main() fade = clamp( moon_dir.z*moon_dir.z*4.0, 0.0, 1.0 ); vec4 c = texture2D(diffuseMap, vary_texcoord0.xy); + + // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible + // Moon texture has transparent pixels <0x55,0x55,0x55,0x00> + if (c.a <= 2./255.) // 0.00784 + discard; + // c.rgb = pow(c.rgb, vec3(0.7f)); // can't use "srgb_to_linear(color.rgb)" as that is a deferred only function c.rgb *= moonlight_color.rgb; c.rgb *= moon_brightness; @@ -62,5 +68,6 @@ void main() c.rgb = scaleSoftClip(c.rgb); frag_color = vec4(c.rgb, c.a); + gl_FragDepth = 0.999985f; // SL-14113 } diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index fa928d993e..d89cc69d71 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -127,5 +127,11 @@ void main() /// Gamma correct for WL (soft clip effect). frag_color = vec4(color.rgb, alpha1); + + // SL-14113 Moon Haze -- When the camera is underwater fix clouds clipping into moon + // camera above water: class1\defered\cloudsF.glsl + // camera below water: class2\windlight\coudsV.glsl + // See: starsV.glsl, cloudsV.glsl, moonF.glsl + gl_FragDepth = 0.999985; } diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index b6f55e800a..96b4a91b0f 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -130,13 +130,32 @@ void LLDrawPoolSky::renderSkyFace(U8 index) face->renderIndexed(); } + else // Moon + if (index == LLVOSky::FACE_MOON) + { + LLGLSPipelineDepthTestSkyBox gls_skybox(true, true); // SL-14113 Write depth for moon so stars can test if behind it + + LLGLEnable blend(GL_BLEND); + + // if (LLGLSLShader::sNoFixedFunction) // TODO: Necessary? is this always true? We already bailed on gPipeline.canUseWindLightShaders ... above + LLViewerTexture* tex = face->getTexture(LLRender::DIFFUSE_MAP); + if (tex) + { + gMoonProgram.bind(); // SL-14113 was gOneTextureNoColorProgram + gGL.getTexUnit(0)->bind(tex, true); + face->renderIndexed(); + } + } else // heavenly body faces, no interp... { + LLGLSPipelineDepthTestSkyBox gls_skybox(true, false); // reset to previous + LLGLEnable blend(GL_BLEND); LLViewerTexture* tex = face->getTexture(LLRender::DIFFUSE_MAP); if (tex) { + gOneTextureNoColorProgram.bind(); gGL.getTexUnit(0)->bind(tex, true); face->renderIndexed(); } diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index c66aa905f5..436ecabd83 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -270,8 +270,8 @@ void LLDrawPoolWLSky::renderStars(const LLVector3& camPosLocal) const gGL.rotatef(gFrameTimeSeconds*0.01f, 0.f, 0.f, 1.f); if (LLGLSLShader::sNoFixedFunction) { - gCustomAlphaProgram.bind(); - gCustomAlphaProgram.uniform1f(sCustomAlpha, star_alpha.mV[3]); + gStarsProgram.bind(); + gStarsProgram.uniform1f(sCustomAlpha, star_alpha.mV[3]); } else { @@ -288,7 +288,7 @@ void LLDrawPoolWLSky::renderStars(const LLVector3& camPosLocal) const if (LLGLSLShader::sNoFixedFunction) { - gCustomAlphaProgram.unbind(); + gStarsProgram.unbind(); // SL-14113 was gCustomAlphaProgram } else { @@ -477,7 +477,8 @@ void LLDrawPoolWLSky::renderSkyClouds(const LLVector3& camPosLocal, F32 camHeigh void LLDrawPoolWLSky::renderHeavenlyBodies() { - LLGLSPipelineBlendSkyBox gls_skybox(true, false); + //LLGLSPipelineBlendSkyBox gls_skybox(true, false); + LLGLSPipelineBlendSkyBox gls_skybox(true, true); // SL-14113 we need moon to write to depth to clip stars behind LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); gGL.pushMatrix(); @@ -607,8 +608,8 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass) if (gPipeline.canUseWindLightShaders()) { renderSkyHazeDeferred(origin, camHeightLocal); - renderStarsDeferred(origin); renderHeavenlyBodies(); + renderStarsDeferred(origin); renderSkyCloudsDeferred(origin, camHeightLocal, cloud_shader); } gGL.setColorMask(true, true); @@ -626,8 +627,8 @@ void LLDrawPoolWLSky::render(S32 pass) LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); renderSkyHaze(origin, camHeightLocal); + renderHeavenlyBodies(); renderStars(origin); - renderHeavenlyBodies(); renderSkyClouds(origin, camHeightLocal, cloud_shader); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index be5c22e7c3..8eb57799c9 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -78,7 +78,7 @@ LLGLSLShader gTransformTangentProgram; //utility shaders LLGLSLShader gOcclusionProgram; LLGLSLShader gOcclusionCubeProgram; -LLGLSLShader gCustomAlphaProgram; +LLGLSLShader gCustomAlphaProgram; // SL-14113 This used to be used for the stars with Atmospheric Shaders: OFF LLGLSLShader gGlowCombineProgram; LLGLSLShader gSplatTextureRectProgram; LLGLSLShader gGlowCombineFXAAProgram; @@ -148,6 +148,8 @@ LLGLSLShader gSkinnedObjectFullbrightShinyWaterProgram; LLGLSLShader gSkinnedObjectShinySimpleWaterProgram; //environment shaders +LLGLSLShader gMoonProgram; +LLGLSLShader gStarsProgram; LLGLSLShader gTerrainProgram; LLGLSLShader gTerrainWaterProgram; LLGLSLShader gWaterProgram; @@ -819,6 +821,9 @@ void LLViewerShaderMgr::unloadShaders() gWaterProgram.unload(); gWaterEdgeProgram.unload(); gUnderWaterProgram.unload(); + + gMoonProgram.unload(); + gStarsProgram.unload(); gTerrainProgram.unload(); gTerrainWaterProgram.unload(); gGlowProgram.unload(); @@ -1051,6 +1056,32 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() llassert(success); } + if (success) + { + gStarsProgram.mName = "Environment Stars Shader"; + gStarsProgram.mShaderFiles.clear(); + gStarsProgram.mShaderFiles.push_back(make_pair("environment/starsV.glsl", GL_VERTEX_SHADER_ARB)); + gStarsProgram.mShaderFiles.push_back(make_pair("environment/starsF.glsl", GL_FRAGMENT_SHADER_ARB)); + gStarsProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; + success = gStarsProgram.createShader(NULL, NULL); + llassert(success); + } + + if (success) + { + gMoonProgram.mName = "Environment Moon Shader"; + gMoonProgram.mShaderFiles.clear(); + gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonV.glsl", GL_VERTEX_SHADER_ARB)); + gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); + gMoonProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; + success = gMoonProgram.createShader(NULL, NULL); + if (success) + { + gMoonProgram.bind(); + gMoonProgram.uniform1i(sTex0, 0); + } + } + if (!success) { mShaderLevel[SHADER_ENVIRONMENT] = 0; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 081221f15b..5122558a01 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -234,6 +234,8 @@ extern LLGLSLShader gSkinnedObjectFullbrightShinyWaterProgram; extern LLGLSLShader gSkinnedObjectShinySimpleWaterProgram; //environment shaders +extern LLGLSLShader gMoonProgram; +extern LLGLSLShader gStarsProgram; extern LLGLSLShader gTerrainProgram; extern LLGLSLShader gTerrainWaterProgram; extern LLGLSLShader gWaterProgram; -- cgit v1.2.3 From bd9a6edbb53711e4a8ec2a178b4375db266844d3 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 13 Apr 2021 10:54:02 -0700 Subject: SL-14113 Cleanup typo and cross reference --- indra/newview/app_settings/shaders/class1/deferred/starsF.glsl | 2 +- indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl index 50f10ad0fa..b028c40ed9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -52,7 +52,7 @@ float twinkle(){ void main() { // camera above water: class1\deferred\starsF.glsl - // camera below water: starsF.glsl + // camera below water: class1\environment\starsF.glsl vec4 col_a = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col_b = texture2D(diffuseMap, vary_texcoord0.xy); vec4 col = mix(col_b, col_a, blend_factor); diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index d89cc69d71..1c592402d4 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -129,7 +129,7 @@ void main() frag_color = vec4(color.rgb, alpha1); // SL-14113 Moon Haze -- When the camera is underwater fix clouds clipping into moon - // camera above water: class1\defered\cloudsF.glsl + // camera above water: class1\deferred\cloudsF.glsl // camera below water: class2\windlight\coudsV.glsl // See: starsV.glsl, cloudsV.glsl, moonF.glsl gl_FragDepth = 0.999985; -- cgit v1.2.3 From 63027bacf9b96202532a2dd47126ff8430723059 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 13 Apr 2021 11:35:36 -0700 Subject: SL-14113 Cleanup face magic number --- indra/newview/lldrawpoolsky.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index 96b4a91b0f..77b8a1fc32 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -123,7 +123,7 @@ void LLDrawPoolSky::renderSkyFace(U8 index) return; } - if (index < 6) // sky tex...interp + if (index < LLVOSky::FACE_SUN) // sky tex...interp { llassert(mSkyTex); mSkyTex[index].bindTexture(true); // bind the current tex -- cgit v1.2.3 From 26f3c078363e3a8bd0ee284c7cd54e9f2b979e7b Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 13 Apr 2021 11:36:33 -0700 Subject: SL-14113 Cleanup indentation --- indra/newview/lldrawpoolsky.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index 77b8a1fc32..178564b0d4 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -116,17 +116,17 @@ void LLDrawPoolSky::render(S32 pass) void LLDrawPoolSky::renderSkyFace(U8 index) { - LLFace* face = mDrawFace[index]; + LLFace* face = mDrawFace[index]; - if (!face || !face->getGeomCount()) - { - return; - } + if (!face || !face->getGeomCount()) + { + return; + } if (index < LLVOSky::FACE_SUN) // sky tex...interp { llassert(mSkyTex); - mSkyTex[index].bindTexture(true); // bind the current tex + mSkyTex[index].bindTexture(true); // bind the current tex face->renderIndexed(); } -- cgit v1.2.3 From 7c3a511935a16e0e99b8a5a57edd69a9290465a2 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 29 Apr 2021 08:41:50 -0700 Subject: SL-14113: Remove magic numbers. Take advantage of existing shader #defines injection by extending shader loading to make use of addConstant() instead of hard-coding magic number constants in each GLSL file. --- indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl | 2 +- indra/newview/app_settings/shaders/class1/deferred/moonF.glsl | 2 +- indra/newview/app_settings/shaders/class1/deferred/starsF.glsl | 2 +- indra/newview/app_settings/shaders/class1/environment/moonF.glsl | 2 +- indra/newview/app_settings/shaders/class1/environment/starsF.glsl | 2 +- indra/newview/app_settings/shaders/class1/windlight/moonF.glsl | 2 +- indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl | 2 +- indra/newview/llviewershadermgr.cpp | 8 ++++++++ 8 files changed, 15 insertions(+), 7 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index 187fed72e1..ad8ab771b8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -126,6 +126,6 @@ void main() frag_data[1] = vec4(0.0,0.0,0.0,0.0); frag_data[2] = vec4(0,0,0,1); - gl_FragDepth = 0.999985; // SL-14113 Stars and Clouds need same depth + gl_FragDepth = LL_SHADER_CONST_CLOUD_DEPTH; // SL-14113 Stars and Clouds need same depth } diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index 5906194437..ffeaf2b600 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -74,6 +74,6 @@ void main() frag_data[1] = vec4(0.0); frag_data[2] = vec4(0.0f); - gl_FragDepth = 0.999985f; + gl_FragDepth = LL_SHADER_CONST_MOON_DEPTH; // SL-14113 } diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl index b028c40ed9..8d9c7e3507 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -67,6 +67,6 @@ void main() frag_data[1] = vec4(0.0f); frag_data[2] = vec4(0.0, 1.0, 0.0, 1.0); - gl_FragDepth = 0.999995f; // SL-14113 Moon Haze -- Stars need to depth test behind the moon + gl_FragDepth = LL_SHADER_CONST_STAR_DEPTH; // SL-14113 Moon Haze -- Stars need to depth test behind the moon } diff --git a/indra/newview/app_settings/shaders/class1/environment/moonF.glsl b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl index e1592c19fb..983cd17979 100644 --- a/indra/newview/app_settings/shaders/class1/environment/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl @@ -47,5 +47,5 @@ void main() discard; frag_color = color; - gl_FragDepth = 0.999985f; // SL-14113 Moon is infront of stars + gl_FragDepth = LL_SHADER_CONST_MOON_DEPTH; // SL-14113 Moon is infront of stars } diff --git a/indra/newview/app_settings/shaders/class1/environment/starsF.glsl b/indra/newview/app_settings/shaders/class1/environment/starsF.glsl index 95ab4cbf8b..e1a9cc6387 100644 --- a/indra/newview/app_settings/shaders/class1/environment/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/starsF.glsl @@ -47,5 +47,5 @@ void main() color.a *= max(custom_alpha, vertex_color.a); frag_color = color; - gl_FragDepth = 0.999995f; // SL-14113 Moon Haze -- Stars need to depth test behind the moon + gl_FragDepth = LL_SHADER_CONST_STAR_DEPTH; // SL-14113 Moon Haze -- Stars need to depth test behind the moon } diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl index 327accbd3b..293e09620f 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl @@ -68,6 +68,6 @@ void main() c.rgb = scaleSoftClip(c.rgb); frag_color = vec4(c.rgb, c.a); - gl_FragDepth = 0.999985f; // SL-14113 + gl_FragDepth = LL_SHADER_CONST_MOON_DEPTH; // SL-14113 } diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index 1c592402d4..ec53ae75f9 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -132,6 +132,6 @@ void main() // camera above water: class1\deferred\cloudsF.glsl // camera below water: class2\windlight\coudsV.glsl // See: starsV.glsl, cloudsV.glsl, moonF.glsl - gl_FragDepth = 0.999985; + gl_FragDepth = LL_SHADER_CONST_CLOUD_DEPTH; } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 8eb57799c9..1dcd9289ef 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1063,6 +1063,7 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() gStarsProgram.mShaderFiles.push_back(make_pair("environment/starsV.glsl", GL_VERTEX_SHADER_ARB)); gStarsProgram.mShaderFiles.push_back(make_pair("environment/starsF.glsl", GL_FRAGMENT_SHADER_ARB)); gStarsProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; + gStarsProgram.addConstant( LLGLSLShader::SHADER_CONST_STAR_DEPTH ); // SL-14113 success = gStarsProgram.createShader(NULL, NULL); llassert(success); } @@ -1074,8 +1075,10 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonV.glsl", GL_VERTEX_SHADER_ARB)); gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); gMoonProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; + gMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_MOON_DEPTH ); // SL-14113 success = gMoonProgram.createShader(NULL, NULL); if (success) + { gMoonProgram.bind(); gMoonProgram.uniform1i(sTex0, 0); @@ -2750,6 +2753,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; + gDeferredWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_DEPTH ); // SL-14113 success = gDeferredWLCloudProgram.createShader(NULL, NULL); llassert(success); } @@ -2789,6 +2793,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLMoonProgram.mShaderFiles.push_back(make_pair("deferred/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredWLMoonProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY; + gDeferredWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_MOON_DEPTH ); // SL-14113 success = gDeferredWLMoonProgram.createShader(NULL, NULL); llassert(success); } @@ -2801,6 +2806,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredStarProgram.mShaderFiles.push_back(make_pair("deferred/starsF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredStarProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredStarProgram.mShaderGroup = LLGLSLShader::SG_SKY; + gDeferredStarProgram.addConstant( LLGLSLShader::SHADER_CONST_STAR_DEPTH ); // SL-14113 success = gDeferredStarProgram.createShader(NULL, NULL); llassert(success); } @@ -4157,6 +4163,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() gWLCloudProgram.mShaderFiles.push_back(make_pair("windlight/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); gWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; gWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; + gWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_DEPTH ); // SL-14113 success = gWLCloudProgram.createShader(NULL, NULL); } @@ -4193,6 +4200,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() gWLMoonProgram.mShaderFiles.push_back(make_pair("windlight/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); gWLMoonProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; gWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY; + gWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_MOON_DEPTH ); // SL-14113 success = gWLMoonProgram.createShader(NULL, NULL); } -- cgit v1.2.3 From 2908f99510ae91c7099b544693ae7628905d8244 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 29 Apr 2021 10:27:09 -0700 Subject: SL-14113: Merge duplicate shader constant for clarity. --- .../newview/app_settings/shaders/class1/deferred/cloudsF.glsl | 2 +- indra/newview/app_settings/shaders/class1/deferred/moonF.glsl | 2 +- .../newview/app_settings/shaders/class1/environment/moonF.glsl | 2 +- indra/newview/app_settings/shaders/class1/windlight/moonF.glsl | 2 +- .../newview/app_settings/shaders/class2/windlight/cloudsF.glsl | 2 +- indra/newview/llviewershadermgr.cpp | 10 +++++----- 6 files changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index ad8ab771b8..f1187fef9a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -126,6 +126,6 @@ void main() frag_data[1] = vec4(0.0,0.0,0.0,0.0); frag_data[2] = vec4(0,0,0,1); - gl_FragDepth = LL_SHADER_CONST_CLOUD_DEPTH; // SL-14113 Stars and Clouds need same depth + gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; // SL-14113 Stars and Clouds need same depth } diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index ffeaf2b600..e709d73bfa 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -74,6 +74,6 @@ void main() frag_data[1] = vec4(0.0); frag_data[2] = vec4(0.0f); - gl_FragDepth = LL_SHADER_CONST_MOON_DEPTH; // SL-14113 + gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; // SL-14113 } diff --git a/indra/newview/app_settings/shaders/class1/environment/moonF.glsl b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl index 983cd17979..a220971f06 100644 --- a/indra/newview/app_settings/shaders/class1/environment/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/moonF.glsl @@ -47,5 +47,5 @@ void main() discard; frag_color = color; - gl_FragDepth = LL_SHADER_CONST_MOON_DEPTH; // SL-14113 Moon is infront of stars + gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; // SL-14113 Moon is infront of stars } diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl index 293e09620f..2e0932343b 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl @@ -68,6 +68,6 @@ void main() c.rgb = scaleSoftClip(c.rgb); frag_color = vec4(c.rgb, c.a); - gl_FragDepth = LL_SHADER_CONST_MOON_DEPTH; // SL-14113 + gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; // SL-14113 } diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index ec53ae75f9..490fde7cf6 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -132,6 +132,6 @@ void main() // camera above water: class1\deferred\cloudsF.glsl // camera below water: class2\windlight\coudsV.glsl // See: starsV.glsl, cloudsV.glsl, moonF.glsl - gl_FragDepth = LL_SHADER_CONST_CLOUD_DEPTH; + gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 32329dfde8..43e9a2333e 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1075,7 +1075,7 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment() gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonV.glsl", GL_VERTEX_SHADER_ARB)); gMoonProgram.mShaderFiles.push_back(make_pair("environment/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); gMoonProgram.mShaderLevel = mShaderLevel[SHADER_ENVIRONMENT]; - gMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_MOON_DEPTH ); // SL-14113 + gMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113 success = gMoonProgram.createShader(NULL, NULL); if (success) { @@ -2752,7 +2752,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; - gDeferredWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_DEPTH ); // SL-14113 + gDeferredWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113 success = gDeferredWLCloudProgram.createShader(NULL, NULL); llassert(success); } @@ -2792,7 +2792,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLMoonProgram.mShaderFiles.push_back(make_pair("deferred/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredWLMoonProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY; - gDeferredWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_MOON_DEPTH ); // SL-14113 + gDeferredWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113 success = gDeferredWLMoonProgram.createShader(NULL, NULL); llassert(success); } @@ -4162,7 +4162,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() gWLCloudProgram.mShaderFiles.push_back(make_pair("windlight/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); gWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; gWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; - gWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_DEPTH ); // SL-14113 + gWLCloudProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113 success = gWLCloudProgram.createShader(NULL, NULL); } @@ -4199,7 +4199,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() gWLMoonProgram.mShaderFiles.push_back(make_pair("windlight/moonF.glsl", GL_FRAGMENT_SHADER_ARB)); gWLMoonProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; gWLMoonProgram.mShaderGroup = LLGLSLShader::SG_SKY; - gWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_MOON_DEPTH ); // SL-14113 + gWLMoonProgram.addConstant( LLGLSLShader::SHADER_CONST_CLOUD_MOON_DEPTH ); // SL-14113 success = gWLMoonProgram.createShader(NULL, NULL); } -- cgit v1.2.3