diff options
Diffstat (limited to 'indra')
26 files changed, 326 insertions, 719 deletions
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 4e32e2bd25..59e8e86fbb 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -86,7 +86,6 @@ LLShaderFeatures::LLShaderFeatures() , calculatesAtmospherics(false) , hasLighting(false) , isAlphaLighting(false) - , isFullbright(false) , isSpecular(false) , hasWaterFog(false) , hasTransport(false) diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 2b709cc6b4..b0d5f308f3 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -39,7 +39,6 @@ public: bool calculatesAtmospherics; bool hasLighting; // implies no transport (it's possible to have neither though) bool isAlphaLighting; // indicates lighting shaders need not be linked in (lighting performed directly in alpha shader to match deferred lighting functions) - bool isFullbright; // implies no lighting bool isSpecular; bool hasWaterFog; // implies no gamma bool hasTransport; // implies no lighting (it's possible to have neither though) diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 54dbb0d025..7a7c5beb38 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -380,82 +380,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } } - // NOTE order of shader object attaching is VERY IMPORTANT!!! - else if (features->isFullbright) - { - if (features->hasWaterFog) - { - if (features->disableTextureIndex) - { - if (features->hasAlphaMask) - { - if (!shader->attachFragmentObject("lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl")) - { - return FALSE; - } - } - else if (!shader->attachFragmentObject("lighting/lightFullbrightWaterNonIndexedF.glsl")) - { - return FALSE; - } - } - else - { - if (features->hasAlphaMask) - { - if (!shader->attachFragmentObject("lighting/lightFullbrightWaterAlphaMaskF.glsl")) - { - return FALSE; - } - } - else if (!shader->attachFragmentObject("lighting/lightFullbrightWaterF.glsl")) - { - return FALSE; - } - shader->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels-1, 1); - } - } - else - { - if (features->disableTextureIndex) - { - - if (features->hasAlphaMask) - { - if (!shader->attachFragmentObject("lighting/lightFullbrightNonIndexedAlphaMaskF.glsl")) - { - return FALSE; - } - } - else - { - if (!shader->attachFragmentObject("lighting/lightFullbrightNonIndexedF.glsl")) - { - return FALSE; - } - } - } - else - { - if (features->hasAlphaMask) - { - if (!shader->attachFragmentObject("lighting/lightFullbrightAlphaMaskF.glsl")) - { - return FALSE; - } - } - else - { - if (!shader->attachFragmentObject("lighting/lightFullbrightF.glsl")) - { - return FALSE; - } - } - shader->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels-1, 1); - } - } - } if (features->mIndexedTextureChannels <= 1) { if (!shader->attachVertexObject("objects/nonindexedTextureV.glsl")) diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl index a2ad1b70fb..597ab22f42 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl @@ -23,10 +23,10 @@ * $/LicenseInfo$ */ -#define DIFFUSE_ALPHA_MODE_IGNORE 0 -#define DIFFUSE_ALPHA_MODE_BLEND 1 -#define DIFFUSE_ALPHA_MODE_MASK 2 -#define DIFFUSE_ALPHA_MODE_EMISSIVE 3 + +#ifndef IS_HUD + +// default alpha implementation #ifdef HAS_SKIN uniform mat4 modelview_matrix; @@ -38,13 +38,12 @@ uniform mat4 modelview_projection_matrix; #endif uniform mat4 texture_matrix0; -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - #if !defined(HAS_SKIN) - uniform mat4 modelview_matrix; - #endif - VARYING vec3 vary_position; +#if !defined(HAS_SKIN) +uniform mat4 modelview_matrix; #endif +out vec3 vary_position; + uniform mat3 texture_basecolor_matrix; uniform mat3 texture_normal_matrix; uniform mat3 texture_metallic_roughness_matrix; @@ -79,9 +78,7 @@ void main() mat4 mat = getObjectSkinnedTransform(); mat = modelview_matrix * mat; vec3 pos = (mat*vec4(position.xyz,1.0)).xyz; -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) vary_position = pos; -#endif vec4 vert = projection_matrix * vec4(pos,1.0); #else //transform vertex @@ -112,9 +109,45 @@ void main() vertex_color = diffuse_color; -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - #if !defined(HAS_SKIN) +#if !defined(HAS_SKIN) vary_position = (modelview_matrix*vec4(position.xyz, 1.0)).xyz; - #endif #endif } + +#else + +// fullbright HUD alpha implementation + +uniform mat4 modelview_projection_matrix; + +uniform mat4 texture_matrix0; + +uniform mat4 modelview_matrix; + +out vec3 vary_position; + +uniform mat3 texture_basecolor_matrix; +uniform mat3 texture_emissive_matrix; + +in vec3 position; +in vec4 diffuse_color; +in vec2 texcoord0; + +out vec2 basecolor_texcoord; +out vec2 emissive_texcoord; + +out vec4 vertex_color; + +void main() +{ + //transform vertex + vec4 vert = modelview_projection_matrix * vec4(position.xyz, 1.0); + gl_Position = vert; + + basecolor_texcoord = (texture_matrix0 * vec4(texture_basecolor_matrix * vec3(texcoord0,1), 1)).xy; + emissive_texcoord = (texture_matrix0 * vec4(texture_emissive_matrix * vec3(texcoord0,1), 1)).xy; + + vertex_color = diffuse_color; +} + +#endif diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl index 39419e9d78..483ce4c3d0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl @@ -25,6 +25,11 @@ /*[EXTRA_CODE_HERE]*/ + +#ifndef IS_HUD + +// deferred opaque implementation + uniform sampler2D diffuseMap; //always in sRGB space uniform float metallicFactor; @@ -101,3 +106,47 @@ void main() frag_data[2] = vec4(encode_normal(tnorm), vertex_color.a, GBUFFER_FLAG_HAS_PBR); // normal, environment intensity, flags frag_data[3] = vec4(emissive,0); // PBR sRGB Emissive } + +#else + +// forward fullbright implementation for HUDs + +uniform sampler2D diffuseMap; //always in sRGB space + +uniform vec3 emissiveColor; +uniform sampler2D emissiveMap; + +out vec4 frag_color; + +in vec3 vary_position; +in vec4 vertex_color; + +in vec2 basecolor_texcoord; +in vec2 emissive_texcoord; + +uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlphaCutoff() + +vec3 linear_to_srgb(vec3 c); +vec3 srgb_to_linear(vec3 c); + +void main() +{ + vec4 basecolor = texture2D(diffuseMap, basecolor_texcoord.xy).rgba; + if (basecolor.a < minimum_alpha) + { + discard; + } + + vec3 col = vertex_color.rgb * srgb_to_linear(basecolor.rgb); + + vec3 emissive = emissiveColor; + emissive *= srgb_to_linear(texture2D(emissiveMap, emissive_texcoord.xy).rgb); + + col += emissive; + + // HUDs are rendered after gamma correction, output in sRGB space + frag_color.rgb = linear_to_srgb(col); + frag_color.a = 0.0; +} + +#endif
\ No newline at end of file diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl index 5a69da641a..8320640e42 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl @@ -23,10 +23,10 @@ * $/LicenseInfo$ */ -#define DIFFUSE_ALPHA_MODE_IGNORE 0 -#define DIFFUSE_ALPHA_MODE_BLEND 1 -#define DIFFUSE_ALPHA_MODE_MASK 2 -#define DIFFUSE_ALPHA_MODE_EMISSIVE 3 + +#ifndef IS_HUD + +//deferred opaque implementation #ifdef HAS_SKIN uniform mat4 modelview_matrix; @@ -95,3 +95,40 @@ void main() vertex_color = diffuse_color; } + +#else + +// fullbright HUD implementation + +uniform mat4 modelview_projection_matrix; + +uniform mat4 texture_matrix0; + +uniform mat3 texture_basecolor_matrix; +uniform mat3 texture_normal_matrix; +uniform mat3 texture_metallic_roughness_matrix; +uniform mat3 texture_emissive_matrix; + +in vec3 position; +in vec4 diffuse_color; +in vec2 texcoord0; + +out vec2 basecolor_texcoord; +out vec2 emissive_texcoord; + +out vec4 vertex_color; + +void main() +{ + //transform vertex + gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + + basecolor_texcoord = (texture_matrix0 * vec4(texture_basecolor_matrix * vec3(texcoord0,1), 1)).xy; + emissive_texcoord = (texture_matrix0 * vec4(texture_emissive_matrix * vec3(texcoord0,1), 1)).xy; + + vertex_color = diffuse_color; +} + +#endif + + diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl deleted file mode 100644 index 00749213db..0000000000 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightAlphaMaskF.glsl +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @file class1\lighting\lightFullbrightAlphaMaskF.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, 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 float minimum_alpha; -uniform float texture_gamma; // either 1.0 or 2.2; see: "::TEXTURE_GAMMA" - -vec3 fullbrightAtmosTransport(vec3 light); -vec3 fullbrightScaleSoftClip(vec3 light); - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -void fullbright_lighting() -{ - vec4 color = diffuseLookup(vary_texcoord0.xy); - - if (color.a < minimum_alpha) - { - discard; - } - - color *= vertex_color; - - color.rgb = pow(color.rgb, vec3(texture_gamma)); - - color.rgb = fullbrightAtmosTransport(color.rgb); - color.rgb = fullbrightScaleSoftClip(color.rgb); - - frag_color = color; -} - diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl deleted file mode 100644 index b9dc332043..0000000000 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @file class1\lighting\lightFullbrightF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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 - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -uniform float texture_gamma; - -vec3 fullbrightAtmosTransport(vec3 light); -vec3 fullbrightScaleSoftClip(vec3 light); - -void fullbright_lighting() -{ - vec4 color = diffuseLookup(vary_texcoord0.xy) * vertex_color; - - color.rgb = pow(color.rgb, vec3(texture_gamma)); - - color.rgb = fullbrightAtmosTransport(color.rgb); - color.rgb = fullbrightScaleSoftClip(color.rgb); - - color.rgb = pow(color.rgb, vec3(1.0/texture_gamma)); - - frag_color = color; - -} - diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl deleted file mode 100644 index e8e71beb44..0000000000 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedAlphaMaskF.glsl +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @file class1\lighting\lightFullbrightNonIndexedAlphaMaskF.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, 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 float minimum_alpha; -uniform float texture_gamma; - -vec3 fullbrightAtmosTransport(vec3 light); -vec3 fullbrightScaleSoftClip(vec3 light); - -uniform sampler2D diffuseMap; - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -void fullbright_lighting() -{ - vec4 color = texture2D(diffuseMap,vary_texcoord0.xy); - - if (color.a < minimum_alpha) - { - discard; - } - - color.rgb *= vertex_color.rgb; - - color.rgb = pow(color.rgb, vec3(texture_gamma)); - color.rgb = fullbrightAtmosTransport(color.rgb); - - color.rgb = fullbrightScaleSoftClip(color.rgb); - - color.rgb = pow(color.rgb, vec3(1.0/texture_gamma)); - - frag_color = color; -} - diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedF.glsl deleted file mode 100644 index 11a0919086..0000000000 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightNonIndexedF.glsl +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @file class1\lighting\lightFullbrightF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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 - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -vec3 fullbrightAtmosTransport(vec3 light); -vec3 fullbrightScaleSoftClip(vec3 light); - -uniform sampler2D diffuseMap; - -void fullbright_lighting() -{ - vec4 color = texture2D(diffuseMap,vary_texcoord0.xy) * vertex_color; - - color.rgb = fullbrightAtmosTransport(color.rgb); - - color.rgb = fullbrightScaleSoftClip(color.rgb); - - frag_color = color; -} - diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl deleted file mode 100644 index 37cac5f437..0000000000 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @file class1\lighting\lightFullbrightWaterAlphaMaskF.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, 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 float minimum_alpha; - -/* vec4 diffuseLookup(vec2 texcoord); */ - -vec3 fullbrightAtmosTransport(vec3 light); -vec4 applyWaterFog(vec4 color); - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -void fullbright_lighting_water() -{ - vec4 color = diffuseLookup(vary_texcoord0.xy); - - if (color.a < minimum_alpha) - { - discard; - } - - color.rgb *= vertex_color.rgb; - - color.rgb = fullbrightAtmosTransport(color.rgb); - - frag_color = applyWaterFog(color); -} - diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl deleted file mode 100644 index 27880b720c..0000000000 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @file class1\lighting\lightFullbrightWaterF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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 - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -/* vec4 diffuseLookup(vec2 texcoord); */ - -vec3 fullbrightAtmosTransport(vec3 light); -vec4 applyWaterFog(vec4 color); - -void fullbright_lighting_water() -{ - vec4 color = diffuseLookup(vary_texcoord0.xy) * vertex_color; - - color.rgb = fullbrightAtmosTransport(color.rgb); - - frag_color = applyWaterFog(color); -} - diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl deleted file mode 100644 index c98db4795c..0000000000 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @file class1\lighting\lightFullbrightWaterNonIndexedAlphaMaskF.glsl - * - * $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2011, 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 float minimum_alpha; - -uniform sampler2D diffuseMap; - -vec3 fullbrightAtmosTransport(vec3 light); -vec4 applyWaterFog(vec4 color); - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -void fullbright_lighting_water() -{ - vec4 color = texture2D(diffuseMap, vary_texcoord0.xy); - - if (color.a < minimum_alpha) - { - discard; - } - - color.rgb *= vertex_color.rgb; - - color.rgb = fullbrightAtmosTransport(color.rgb); - - frag_color = applyWaterFog(color); -} - diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedF.glsl deleted file mode 100644 index e9fd8ac820..0000000000 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedF.glsl +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @file class1\lighting\lightFullbrightWaterF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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 - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -uniform sampler2D diffuseMap; - -vec3 fullbrightAtmosTransport(vec3 light); -vec4 applyWaterFog(vec4 color); - -void fullbright_lighting_water() -{ - vec4 color = texture2D(diffuseMap, vary_texcoord0.xy) * vertex_color; - - color.rgb = fullbrightAtmosTransport(color.rgb); - - frag_color = applyWaterFog(color); -} - diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl deleted file mode 100644 index 31a262f1db..0000000000 --- a/indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file objects/fullbrightF.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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$F - */ - - - -void fullbright_lighting(); - -void main() -{ - fullbright_lighting(); -} diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl deleted file mode 100644 index 5af42f1fcf..0000000000 --- a/indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @file fullbrightV.glsl - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2007, 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 texture_matrix0; -uniform mat4 modelview_matrix; -uniform mat4 modelview_projection_matrix; - -ATTRIBUTE vec3 position; -void passTextureIndex(); -ATTRIBUTE vec2 texcoord0; -ATTRIBUTE vec3 normal; -ATTRIBUTE vec4 diffuse_color; - -void calcAtmospherics(vec3 inPositionEye); - -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; - -#ifdef HAS_SKIN -mat4 getObjectSkinnedTransform(); -uniform mat4 projection_matrix; -#endif - -void main() -{ - //transform vertex - vec4 vert = vec4(position.xyz,1.0); - passTextureIndex(); -#ifdef HAS_SKIN - mat4 mat = getObjectSkinnedTransform(); - mat = modelview_matrix * mat; - vec4 pos = mat * vert; - gl_Position = projection_matrix * pos; -#else - vec4 pos = (modelview_matrix * vert); - gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0); -#endif - vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; - - calcAtmospherics(pos.xyz); - - vertex_color = diffuse_color; -} diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl index 35e22ef3a2..35ccc65a8e 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl @@ -25,6 +25,8 @@ /*[EXTRA_CODE_HERE]*/ +#ifndef IS_HUD + uniform sampler2D diffuseMap; //always in sRGB space uniform sampler2D bumpMap; uniform sampler2D emissiveMap; @@ -249,3 +251,59 @@ void main() a += f; frag_color = vec4(color.rgb,a); } + +#else + +uniform sampler2D diffuseMap; //always in sRGB space +uniform sampler2D emissiveMap; + +uniform vec3 emissiveColor; + +out vec4 frag_color; + +in vec3 vary_position; + +in vec2 basecolor_texcoord; +in vec2 emissive_texcoord; + +in vec4 vertex_color; + +#ifdef HAS_ALPHA_MASK +uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlphaCutoff() +#endif + +vec3 srgb_to_linear(vec3 c); +vec3 linear_to_srgb(vec3 c); + + +void main() +{ + vec3 color = vec3(0,0,0); + + vec3 pos = vary_position; + + vec4 basecolor = texture(diffuseMap, basecolor_texcoord.xy).rgba; + basecolor.rgb = srgb_to_linear(basecolor.rgb); +#ifdef HAS_ALPHA_MASK + if (basecolor.a < minimum_alpha) + { + discard; + } +#endif + + color = vertex_color.rgb * basecolor.rgb; + + // emissiveColor is the emissive color factor from GLTF and is already in linear space + vec3 colorEmissive = emissiveColor; + // emissiveMap here is a vanilla RGB texture encoded as sRGB, manually convert to linear + colorEmissive *= srgb_to_linear(texture2D(emissiveMap, emissive_texcoord.xy).rgb); + + + float a = basecolor.a*vertex_color.a; + a = 1.0; + color += colorEmissive; + color = linear_to_srgb(color); + frag_color = vec4(color.rgb,a); +} + +#endif diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index a7ce1a9f87..3dda24595e 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -199,7 +199,9 @@ void LLDrawPoolAlpha::renderPostDeferred(S32 pass) prepare_alpha_shader(&materialShader[i], false, true, water_sign); } - prepare_alpha_shader(&gDeferredPBRAlphaProgram, false, true, water_sign); + pbr_shader = LLPipeline::sRenderingHUDs ? &gHUDPBRAlphaProgram : &gDeferredPBRAlphaProgram; + + prepare_alpha_shader(pbr_shader, false, true, water_sign); if (!LLPipeline::sRenderingHUDs) { @@ -211,10 +213,10 @@ void LLDrawPoolAlpha::renderPostDeferred(S32 pass) forwardRender(); // final pass, render to depth for depth of field effects - if (!LLPipeline::sImpostorRender && gSavedSettings.getBOOL("RenderDepthOfField") && !gCubeSnapshot) + if (!LLPipeline::sImpostorRender && gSavedSettings.getBOOL("RenderDepthOfField") && !gCubeSnapshot && !LLPipeline::sRenderingHUDs) { //update depth buffer sampler - simple_shader = fullbright_shader = &gObjectFullbrightAlphaMaskProgram; + simple_shader = fullbright_shader = &gDeferredFullbrightAlphaMaskProgram; simple_shader->bind(); simple_shader->setMinimumAlpha(0.33f); @@ -630,7 +632,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) if (gltf_mat && gltf_mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_BLEND) { - target_shader = &gDeferredPBRAlphaProgram; + target_shader = pbr_shader; if (params.mAvatar != nullptr) { target_shader = target_shader->mRiggedVariant; diff --git a/indra/newview/lldrawpoolalpha.h b/indra/newview/lldrawpoolalpha.h index b6cf54a7dd..1e10bb5566 100644 --- a/indra/newview/lldrawpoolalpha.h +++ b/indra/newview/lldrawpoolalpha.h @@ -77,6 +77,7 @@ private: LLGLSLShader* simple_shader = nullptr; LLGLSLShader* fullbright_shader = nullptr; LLGLSLShader* emissive_shader = nullptr; + LLGLSLShader* pbr_shader = nullptr; void drawEmissive(U32 mask, LLDrawInfo* draw); void renderEmissives(U32 mask, std::vector<LLDrawInfo*>& emissives); diff --git a/indra/newview/lldrawpoolpbropaque.cpp b/indra/newview/lldrawpoolpbropaque.cpp index 9dd1bc0ba2..c5413a068a 100644 --- a/indra/newview/lldrawpoolpbropaque.cpp +++ b/indra/newview/lldrawpoolpbropaque.cpp @@ -31,22 +31,46 @@ #include "llviewershadermgr.h" #include "pipeline.h" +static const U32 gltf_render_types[] = { LLPipeline::RENDER_TYPE_PASS_GLTF_PBR, LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK }; + LLDrawPoolGLTFPBR::LLDrawPoolGLTFPBR() : LLRenderPass(POOL_GLTF_PBR) { } +S32 LLDrawPoolGLTFPBR::getNumDeferredPasses() +{ + return 1; +} + void LLDrawPoolGLTFPBR::renderDeferred(S32 pass) { - const U32 types[] = { LLPipeline::RENDER_TYPE_PASS_GLTF_PBR, LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK }; + llassert(!LLPipeline::sRenderingHUDs); - for (U32 type : types) + for (U32 type : gltf_render_types) { gDeferredPBROpaqueProgram.bind(); pushGLTFBatches(type); - + gDeferredPBROpaqueProgram.bind(true); - pushRiggedGLTFBatches(type+1); + pushRiggedGLTFBatches(type + 1); + } +} + +S32 LLDrawPoolGLTFPBR::getNumPostDeferredPasses() +{ + return LLPipeline::sRenderingHUDs ? 1 : 0; +} + +void LLDrawPoolGLTFPBR::renderPostDeferred(S32 pass) +{ + // only HUD rendering should execute this pass + llassert(LLPipeline::sRenderingHUDs); + + gHUDPBROpaqueProgram.bind(); + for (U32 type : gltf_render_types) + { + pushGLTFBatches(type); } } diff --git a/indra/newview/lldrawpoolpbropaque.h b/indra/newview/lldrawpoolpbropaque.h index 2fe0695c69..69e063b322 100644 --- a/indra/newview/lldrawpoolpbropaque.h +++ b/indra/newview/lldrawpoolpbropaque.h @@ -48,8 +48,11 @@ public: LLDrawPoolGLTFPBR(); - S32 getNumDeferredPasses() override { return 1; } + S32 getNumDeferredPasses() override; void renderDeferred(S32 pass) override; + + S32 getNumPostDeferredPasses() override; + void renderPostDeferred(S32 pass) override; }; #endif // LL_LLDRAWPOOLPBROPAQUE_H diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 2e20d61b15..62144b2d31 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1161,6 +1161,7 @@ void render_hud_attachments() gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_ALPHA_MASK); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_FULLBRIGHT_ALPHA_MASK); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_FULLBRIGHT); + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_GLTF_PBR); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_ALPHA); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_ALPHA_MASK); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_BUMP); @@ -1171,6 +1172,8 @@ void render_hud_attachments() gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_SHINY); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_INVISIBLE); gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_INVISI_SHINY); + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_GLTF_PBR); + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK); gPipeline.stateSort(hud_cam, result); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 23cb32357c..ccb2a86128 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -205,8 +205,10 @@ LLGLSLShader gDeferredGenBrdfLutProgram; // Deferred materials shaders LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT*2]; LLGLSLShader gDeferredMaterialWaterProgram[LLMaterial::SHADER_COUNT*2]; +LLGLSLShader gHUDPBROpaqueProgram; LLGLSLShader gDeferredPBROpaqueProgram; LLGLSLShader gDeferredSkinnedPBROpaqueProgram; +LLGLSLShader gHUDPBRAlphaProgram; LLGLSLShader gDeferredPBRAlphaProgram; LLGLSLShader gDeferredSkinnedPBRAlphaProgram; @@ -284,6 +286,7 @@ LLViewerShaderMgr::LLViewerShaderMgr() : mShaderList.push_back(&gDeferredWLMoonProgram); mShaderList.push_back(&gDeferredWLSunProgram); mShaderList.push_back(&gDeferredPBRAlphaProgram); + mShaderList.push_back(&gHUDPBRAlphaProgram); mShaderList.push_back(&gDeferredSkinnedPBRAlphaProgram); } @@ -555,7 +558,6 @@ void LLViewerShaderMgr::unloadShaders() gImpostorProgram.unload(); gObjectBumpProgram.unload(); gSkinnedObjectBumpProgram.unload(); - gObjectFullbrightAlphaMaskProgram.unload(); gSkinnedObjectFullbrightAlphaMaskProgram.unload(); gObjectAlphaMaskNoColorProgram.unload(); @@ -738,21 +740,13 @@ std::string LLViewerShaderMgr::loadBasicShaders() index_channels.push_back(-1); shaders.push_back( make_pair( "deferred/screenSpaceReflUtil.glsl", ssr ? 3 : 1) ); index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightAlphaMaskNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightNonIndexedAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightWaterNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightWaterAlphaMaskNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightWaterNonIndexedF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightWaterF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightWaterAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightWaterF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightWaterAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - + for (U32 i = 0; i < shaders.size(); i++) { // Note usage of GL_FRAGMENT_SHADER @@ -1021,6 +1015,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredMaterialWaterProgram[i].unload(); } + gHUDPBROpaqueProgram.unload(); gDeferredPBROpaqueProgram.unload(); gDeferredSkinnedPBROpaqueProgram.unload(); gDeferredPBRAlphaProgram.unload(); @@ -1321,11 +1316,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredPBROpaqueProgram.mShaderFiles.push_back(make_pair("deferred/pbropaqueV.glsl", GL_VERTEX_SHADER)); gDeferredPBROpaqueProgram.mShaderFiles.push_back(make_pair("deferred/pbropaqueF.glsl", GL_FRAGMENT_SHADER)); gDeferredPBROpaqueProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; - gDeferredPBROpaqueProgram.addPermutation("HAS_NORMAL_MAP", "1"); - gDeferredPBROpaqueProgram.addPermutation("HAS_SPECULAR_MAP", "1"); - gDeferredPBROpaqueProgram.addPermutation("HAS_EMISSIVE_MAP", "1"); - gDeferredPBROpaqueProgram.addPermutation("DIFFUSE_ALPHA_MODE", "0"); - + success = make_rigged_variant(gDeferredPBROpaqueProgram, gDeferredSkinnedPBROpaqueProgram); if (success) { @@ -1334,6 +1325,22 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() llassert(success); } + if (success) + { + gHUDPBROpaqueProgram.mName = "HUD PBR Opaque Shader"; + gHUDPBROpaqueProgram.mFeatures.hasSrgb = true; + gHUDPBROpaqueProgram.mShaderFiles.clear(); + gHUDPBROpaqueProgram.mShaderFiles.push_back(make_pair("deferred/pbropaqueV.glsl", GL_VERTEX_SHADER)); + gHUDPBROpaqueProgram.mShaderFiles.push_back(make_pair("deferred/pbropaqueF.glsl", GL_FRAGMENT_SHADER)); + gHUDPBROpaqueProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + gHUDPBROpaqueProgram.clearPermutations(); + gHUDPBROpaqueProgram.addPermutation("IS_HUD", "1"); + + success = gHUDPBROpaqueProgram.createShader(NULL, NULL); + + llassert(success); + } + if (success) { LLGLSLShader* shader = &gDeferredPBRAlphaProgram; @@ -1370,21 +1377,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() shader->addPermutation("HAS_SUN_SHADOW", "1"); } - if (ambient_kill) - { - shader->addPermutation("AMBIENT_KILL", "1"); - } - - if (sunlight_kill) - { - shader->addPermutation("SUNLIGHT_KILL", "1"); - } - - if (local_light_kill) - { - shader->addPermutation("LOCAL_LIGHT_KILL", "1"); - } - shader->mShaderLevel = mShaderLevel[SHADER_DEFERRED]; success = make_rigged_variant(*shader, gDeferredSkinnedPBRAlphaProgram); if (success) @@ -1402,6 +1394,25 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() shader->mRiggedVariant->mFeatures.hasLighting = true; } + if (success) + { + LLGLSLShader* shader = &gHUDPBRAlphaProgram; + shader->mName = "HUD PBR Alpha Shader"; + + shader->mFeatures.hasSrgb = true; + + shader->mShaderFiles.clear(); + shader->mShaderFiles.push_back(make_pair("deferred/pbralphaV.glsl", GL_VERTEX_SHADER)); + shader->mShaderFiles.push_back(make_pair("deferred/pbralphaF.glsl", GL_FRAGMENT_SHADER)); + + shader->clearPermutations(); + + shader->addPermutation("IS_HUD", "1"); + + shader->mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = shader->createShader(NULL, NULL); + llassert(success); + } if (success) { @@ -2593,7 +2604,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLSunProgram.mFeatures.hasTransport = true; gDeferredWLSunProgram.mFeatures.hasGamma = true; gDeferredWLSunProgram.mFeatures.hasAtmospherics = true; - gDeferredWLSunProgram.mFeatures.isFullbright = true; gDeferredWLSunProgram.mFeatures.disableTextureIndex = true; gDeferredWLSunProgram.mFeatures.hasSrgb = true; gDeferredWLSunProgram.mShaderFiles.clear(); @@ -2613,7 +2623,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLMoonProgram.mFeatures.hasGamma = true; gDeferredWLMoonProgram.mFeatures.hasAtmospherics = true; gDeferredWLMoonProgram.mFeatures.hasSrgb = true; - gDeferredWLMoonProgram.mFeatures.isFullbright = true; gDeferredWLMoonProgram.mFeatures.disableTextureIndex = true; gDeferredWLMoonProgram.mShaderFiles.clear(); @@ -2785,24 +2794,6 @@ BOOL LLViewerShaderMgr::loadShadersObject() gPhysicsPreviewProgram.mFeatures.hasLighting = false; } - if (success) - { - gObjectFullbrightAlphaMaskProgram.mName = "Fullbright Alpha Mask Shader"; - gObjectFullbrightAlphaMaskProgram.mFeatures.calculatesAtmospherics = true; - gObjectFullbrightAlphaMaskProgram.mFeatures.hasGamma = true; - gObjectFullbrightAlphaMaskProgram.mFeatures.hasTransport = true; - gObjectFullbrightAlphaMaskProgram.mFeatures.isFullbright = true; - gObjectFullbrightAlphaMaskProgram.mFeatures.hasAlphaMask = true; - gObjectFullbrightAlphaMaskProgram.mFeatures.hasSrgb = true; - gObjectFullbrightAlphaMaskProgram.mFeatures.mIndexedTextureChannels = 0; - gObjectFullbrightAlphaMaskProgram.mShaderFiles.clear(); - gObjectFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/fullbrightV.glsl", GL_VERTEX_SHADER)); - gObjectFullbrightAlphaMaskProgram.mShaderFiles.push_back(make_pair("objects/fullbrightF.glsl", GL_FRAGMENT_SHADER)); - gObjectFullbrightAlphaMaskProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT]; - success = make_rigged_variant(gObjectFullbrightAlphaMaskProgram, gSkinnedObjectFullbrightAlphaMaskProgram); - success = success && gObjectFullbrightAlphaMaskProgram.createShader(NULL, NULL); - } - if (!success) { mShaderLevel[SHADER_OBJECT] = 0; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index d5a7a4d359..027dea6f8d 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -170,7 +170,6 @@ extern LLGLSLShader gOneTextureFilterProgram; //object shaders extern LLGLSLShader gObjectPreviewProgram; extern LLGLSLShader gPhysicsPreviewProgram; -extern LLGLSLShader gObjectFullbrightAlphaMaskProgram; extern LLGLSLShader gSkinnedObjectFullbrightAlphaMaskProgram; extern LLGLSLShader gObjectBumpProgram; extern LLGLSLShader gSkinnedObjectBumpProgram; @@ -268,6 +267,8 @@ extern LLGLSLShader gDeferredGenBrdfLutProgram; extern LLGLSLShader gDeferredMaterialProgram[LLMaterial::SHADER_COUNT*2]; extern LLGLSLShader gDeferredMaterialWaterProgram[LLMaterial::SHADER_COUNT*2]; +extern LLGLSLShader gHUDPBROpaqueProgram; extern LLGLSLShader gDeferredPBROpaqueProgram; extern LLGLSLShader gDeferredPBRAlphaProgram; +extern LLGLSLShader gHUDPBRAlphaProgram; #endif diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 865c3df1e4..0c5aac4d0f 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5306,33 +5306,35 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, } } - if (idx >= 0 && - draw_vec[idx]->mVertexBuffer == facep->getVertexBuffer() && - draw_vec[idx]->mEnd == facep->getGeomIndex()-1 && + LLDrawInfo* info = idx >= 0 ? draw_vec[idx] : nullptr; + + if (info && + info->mVertexBuffer == facep->getVertexBuffer() && + info->mEnd == facep->getGeomIndex()-1 && (LLPipeline::sTextureBindTest || draw_vec[idx]->mTexture == tex || batchable) && #if LL_DARWIN - draw_vec[idx]->mEnd - draw_vec[idx]->mStart + facep->getGeomCount() <= (U32) gGLManager.mGLMaxVertexRange && - draw_vec[idx]->mCount + facep->getIndicesCount() <= (U32) gGLManager.mGLMaxIndexRange && + info->mEnd - draw_vec[idx]->mStart + facep->getGeomCount() <= (U32) gGLManager.mGLMaxVertexRange && + info->mCount + facep->getIndicesCount() <= (U32) gGLManager.mGLMaxIndexRange && #endif - draw_vec[idx]->mMaterialID == mat_id && - draw_vec[idx]->mFullbright == fullbright && - draw_vec[idx]->mBump == bump && - (!mat || (draw_vec[idx]->mShiny == shiny)) && // need to break batches when a material is shared, but legacy settings are different - draw_vec[idx]->mTextureMatrix == tex_mat && - draw_vec[idx]->mModelMatrix == model_mat && - draw_vec[idx]->mShaderMask == shader_mask && - draw_vec[idx]->mAvatar == facep->mAvatar && - draw_vec[idx]->getSkinHash() == facep->getSkinHash()) + info->mMaterialID == mat_id && + info->mFullbright == fullbright && + info->mBump == bump && + (!mat || (info->mShiny == shiny)) && // need to break batches when a material is shared, but legacy settings are different + info->mTextureMatrix == tex_mat && + info->mModelMatrix == model_mat && + info->mShaderMask == shader_mask && + info->mAvatar == facep->mAvatar && + info->getSkinHash() == facep->getSkinHash()) { - draw_vec[idx]->mCount += facep->getIndicesCount(); - draw_vec[idx]->mEnd += facep->getGeomCount(); + info->mCount += facep->getIndicesCount(); + info->mEnd += facep->getGeomCount(); - if (index < FACE_DO_NOT_BATCH_TEXTURES && index >= draw_vec[idx]->mTextureList.size()) + if (index < FACE_DO_NOT_BATCH_TEXTURES && index >= info->mTextureList.size()) { - draw_vec[idx]->mTextureList.resize(index+1); - draw_vec[idx]->mTextureList[index] = tex; + info->mTextureList.resize(index+1); + info->mTextureList[index] = tex; } - draw_vec[idx]->validate(); + info->validate(); } else { @@ -5342,6 +5344,9 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, U32 count = facep->getIndicesCount(); LLPointer<LLDrawInfo> draw_info = new LLDrawInfo(start,end,count,offset, tex, facep->getVertexBuffer(), fullbright, bump); + + info = draw_info; + draw_vec.push_back(draw_info); draw_info->mTextureMatrix = tex_mat; draw_info->mModelMatrix = model_mat; @@ -5417,6 +5422,13 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, } draw_info->validate(); } + + llassert(type != LLPipeline::RENDER_TYPE_PASS_GLTF_PBR || info->mGLTFMaterial != nullptr); + llassert(type != LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_RIGGED || info->mGLTFMaterial != nullptr); + llassert(type != LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK || info->mGLTFMaterial != nullptr); + llassert(type != LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK_RIGGED || info->mGLTFMaterial != nullptr); + + llassert(type != LLRenderPass::PASS_NORMSPEC || info->mNormalMap.notNull()); } void LLVolumeGeometryManager::getGeometry(LLSpatialGroup* group) @@ -5790,7 +5802,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) } facep->setPoolType(type); - if (vobj->isHUDAttachment()) + if (vobj->isHUDAttachment() && !is_pbr) { facep->setState(LLFace::FULLBRIGHT); } @@ -6487,17 +6499,17 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace fullbright = TRUE; } - if (hud_group) + const LLTextureEntry* te = facep->getTextureEntry(); + LLGLTFMaterial* gltf_mat = te->getGLTFRenderMaterial(); + + if (hud_group && gltf_mat == nullptr) { //all hud attachments are fullbright fullbright = TRUE; } - - const LLTextureEntry* te = facep->getTextureEntry(); + tex = facep->getTexture(); BOOL is_alpha = (facep->getPoolType() == LLDrawPool::POOL_ALPHA) ? TRUE : FALSE; - - LLGLTFMaterial* gltf_mat = te->getGLTFRenderMaterial(); LLMaterial* mat = nullptr; bool can_be_shiny = false; @@ -6523,7 +6535,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace is_alpha = (is_alpha || transparent) ? TRUE : FALSE; - if ((gltf_mat || mat) && LLPipeline::sRenderDeferred && !hud_group) + if (gltf_mat || (mat && !hud_group)) { bool material_pass = false; @@ -6692,7 +6704,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace registerFace(group, facep, LLRenderPass::PASS_INVISI_SHINY); registerFace(group, facep, LLRenderPass::PASS_INVISIBLE); } - else if (LLPipeline::sRenderDeferred && !hud_group) + else if (!hud_group) { //deferred rendering if (te->getFullbright()) { //register in post deferred fullbright shiny pass @@ -6737,7 +6749,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace { registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT); } - if (LLPipeline::sRenderDeferred && !hud_group && LLPipeline::sRenderBump && use_legacy_bump) + if (!hud_group && LLPipeline::sRenderBump && use_legacy_bump) { //if this is the deferred render and a bump map is present, register in post deferred bump registerFace(group, facep, LLRenderPass::PASS_POST_BUMP); } @@ -6773,7 +6785,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace } //not sure why this is here, and looks like it might cause bump mapped objects to get rendered redundantly -- davep 5/11/2010 - if (!is_alpha && (hud_group || !LLPipeline::sRenderDeferred)) + if (!is_alpha && hud_group) { llassert((mask & LLVertexBuffer::MAP_NORMAL) || fullbright); facep->setPoolType((fullbright) ? LLDrawPool::POOL_FULLBRIGHT : LLDrawPool::POOL_SIMPLE); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 6905450e26..039ad9cf8f 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3934,6 +3934,8 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; //LL_RECORD_BLOCK_TIME(FTM_RENDER_GEOMETRY); LL_PROFILE_GPU_ZONE("renderGeomDeferred"); + llassert(!sRenderingHUDs); + if (gUseWireframe) { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); @@ -7998,6 +8000,8 @@ void LLPipeline::renderDeferredLighting() return; } + llassert(!sRenderingHUDs); + static LLCachedControl<F32> ambiance_scale(gSavedSettings, "RenderReflectionProbeAmbianceScale", 8.f); F32 light_scale = 1.f; |