diff options
author | Graham Linden <graham@lindenlab.com> | 2018-11-01 20:28:47 +0100 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2018-11-01 20:28:47 +0100 |
commit | 4f267a5723e7da2de36b9f2295e4942a4c8bf6c5 (patch) | |
tree | c186a8888794732f32bba406b7bb66b4cafd4d11 /indra/newview/app_settings | |
parent | a67cf385d763325119f4d2a37beb96c9c6a80282 (diff) |
SL-9994
Make shaders use consistent naming and parameter order for transport and atmospheric helpers.
Share transport and gamma correction code where possible.
Add lots of asserts and other validation for when things don't go as planned.
Engage dumpShaderSource to get more source output with shader compilation fail.
Diffstat (limited to 'indra/newview/app_settings')
16 files changed, 129 insertions, 137 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 7f2c5add16..1cfc19267c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -88,7 +88,7 @@ vec3 linear_to_srgb(vec3 cl); vec2 encode_normal (vec3 n); vec3 decode_normal (vec2 enc); -vec3 scaleFragSoftClip(vec3 l); +vec3 scaleSoftClipFrag(vec3 l); vec3 atmosFragAmbient(vec3 light, vec3 sunlit); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); vec3 atmosFragAffectDirectionalLight(float light, vec3 sunlit); @@ -312,7 +312,7 @@ void main() //color.rgb = mix(diff.rgb, color.rgb, final_alpha); color.rgb = atmosFragLighting(color.rgb, additive, atten); - color.rgb = scaleFragSoftClip(color.rgb); + color.rgb = scaleSoftClipFrag(color.rgb); vec4 light = vec4(0,0,0,0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 6e06453a5b..c001ff9ac8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -42,8 +42,8 @@ vec3 linear_to_srgb(vec3 cl); vec3 atmosFragAmbient(vec3 l, vec3 ambient); vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); -vec3 scaleFragSoftClip(vec3 l); -vec3 atmosFragAffectDirectionalLight(float intensity, vec3 sunlit); +vec3 scaleSoftClipFrag(vec3 l); + void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) @@ -406,7 +406,7 @@ void main() col.rgb *= ambient; - col.rgb = col.rgb + atmosFragAffectDirectionalLight(final_da, sunlit); + col.rgb = col.rgb + (final_da * sunlit); col.rgb *= gamma_diff.rgb; @@ -455,7 +455,7 @@ void main() //col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); col = atmosFragLighting(col, additive, atten); - col = scaleFragSoftClip(col); + col = scaleSoftClipFrag(col); //convert to linear space before adding local lights col = srgb_to_linear(col); diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index c3827e3a56..5627275df6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -69,13 +69,7 @@ vec3 srgb_to_linear(vec3 cs); vec3 linear_to_srgb(vec3 cl); vec3 decode_normal (vec2 enc); -vec3 atmosFragAmbient(vec3 l, vec3 ambient); vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); -vec3 scaleFragSoftClip(vec3 l); -vec3 atmosFragAffectDirectionalLight(float intensity, vec3 sunlit); -vec3 fullbrightFragAtmosTransport(vec3 l, vec3 additive, vec3 atten); -vec3 fullbrightScaleSoftClipFrag(vec3 l, vec3 atten); - void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); vec4 getPosition_d(vec2 pos_screen, float depth) @@ -123,22 +117,20 @@ void main() vec3 col; float bloom = 0.0; { - vec3 sunlit; - vec3 amblit; - vec3 additive; - vec3 atten; + vec3 sunlit; + vec3 amblit; + vec3 additive; + vec3 atten; calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); - col = atmosFragAmbient(vec3(0), amblit); float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); ambient *= 0.5; ambient *= ambient; - ambient = (1.0-ambient); - - col.rgb *= ambient; + ambient = (1.0 - ambient); - col += atmosFragAffectDirectionalLight(final_da, sunlit); - + col = amblit; + col += (final_da * sunlit); + col *= ambient; col *= diffuse.rgb; vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); @@ -174,9 +166,7 @@ void main() if (norm.w < 0.5) { - vec3 add = additive; - col = mix(atmosFragLighting(col, add, atten), fullbrightFragAtmosTransport(col, atten, add), diffuse.a); - col = mix(scaleFragSoftClip(col), fullbrightScaleSoftClipFrag(col, atten), diffuse.a); + col = atmosFragLighting(col, additive, atten); } #ifdef WATER_FOG @@ -187,7 +177,6 @@ void main() col = srgb_to_linear(col); - //col = vec3(1,0,1); //col.g = envIntensity; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl b/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl index 587f3d5a94..00ba0e8fad 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl @@ -23,6 +23,24 @@ * $/LicenseInfo$ */ +vec3 rgb2hsv(vec3 c) +{ + vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); + vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); + + float d = q.x - min(q.w, q.y); + float e = 1.0e-10; + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); +} + +vec3 hsv2rgb(vec3 c) +{ + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); +} + vec3 srgb_to_linear(vec3 cs) { vec3 low_range = cs / vec3(12.92); diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index a29acb3e7d..73f6d9fec3 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl @@ -73,6 +73,7 @@ VARYING vec4 vary_position; vec3 srgb_to_linear(vec3 cs); vec2 encode_normal(vec3 n); +vec3 scaleSoftClipFrag(vec3 l); vec3 BlendNormal(vec3 bump1, vec3 bump2) { @@ -175,7 +176,7 @@ void main() color.rgb += spec * specular; color.rgb = atmosTransport(color.rgb); - color.rgb = scaleSoftClip(color.rgb); + color.rgb = scaleSoftClipFrag(color.rgb); color.a = spec * sunAngle2; vec3 screenspacewavef = normalize((norm_mat*vec4(wavef, 1.0)).xyz); diff --git a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl index 835662732a..f98b3a5edf 100644 --- a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl @@ -60,3 +60,7 @@ vec3 linear_to_srgb(vec3 cl) } +vec3 ColorFromRadiance(vec3 radiance) +{ + return vec3(1.0) - exp(-radiance * 0.0001); +} diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl index 668a710c04..46bde7f308 100644 --- a/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl @@ -59,8 +59,10 @@ void main() vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal ); /// Add WL Components - outColor.rgb = atmosLighting(outColor.rgb * vertex_color.rgb); + //outColor.rgb = atmosLighting(outColor.rgb * vertex_color.rgb); + outColor.rgb = atmosLighting(outColor.rgb); + frag_color = vec4(scaleSoftClip(outColor.rgb), 1.0); } diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl index d09c5f9247..5ffe464172 100644 --- a/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl @@ -71,7 +71,7 @@ void main() /// Potentially better without it for water. pos /= pos.w; - vec4 color = calcLighting(pos.xyz, norm, vec4(1,1,1,1), vec4(0)); + vec4 color = calcLighting(pos.xyz, norm, vec4(0), vec4(1)); vertex_color = color; diff --git a/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl b/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl index b7f117fc5f..768d93f005 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl @@ -26,7 +26,7 @@ uniform int no_atmo; uniform vec4 gamma; -vec3 scaleFragSoftClip(vec3 light) +vec3 scaleSoftClipFrag(vec3 light) { // For compatibility with lower cards. Do nothing. return light; @@ -35,16 +35,19 @@ vec3 scaleFragSoftClip(vec3 light) /// Soft clips the light with a gamma correction vec3 scaleSoftClip(vec3 light) { - // For compatibility with lower cards. Do nothing. - return scaleFragSoftClip(light); + // For compatibility with lower cards. Do nothing + return light; } -vec3 fullbrightScaleSoftClipFrag(vec3 light, vec3 atten) +vec3 fullbrightScaleSoftClipFrag(vec3 light) { - return (no_atmo == 1) ? light : mix(scaleFragSoftClip(light.rgb), light.rgb, atten); + // For compatibility with lower cards. Do nothing + return light; } -vec3 fullbrightScaleSoftClip(vec3 light) { - return fullbrightScaleSoftClipFrag(light, vec3(1)); +vec3 fullbrightScaleSoftClip(vec3 light) +{ + // For compatibility with lower cards. Do nothing + return light; } diff --git a/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl index c3c8329017..ebce9ea91d 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl @@ -25,37 +25,19 @@ uniform int no_atmo; -vec3 atmosFragTransport(vec3 light, vec3 atten, vec3 additive) -{ - /* stub function for fallback compatibility on class1 hardware */ - return light; -} - -vec3 fullbrightFragAtmosTransport(vec3 light, vec3 atten, vec3 additive) -{ - /* stub function for fallback compatibility on class1 hardware */ - return light; -} - -vec3 fullbrightFragShinyAtmosTransport(vec3 light, vec3 atten, vec3 additive) -{ - /* stub function for fallback compatibility on class1 hardware */ - return light; -} - vec3 atmosTransport(vec3 light) { /* stub function for fallback compatibility on class1 hardware */ - return atmosFragTransport(light, vec3(1), vec3(0)); + return light; } vec3 fullbrightAtmosTransport(vec3 light) { - return fullbrightFragAtmosTransport(light, vec3(1), vec3(0)); + return light; } vec3 fullbrightShinyAtmosTransport(vec3 light) { - return fullbrightFragShinyAtmosTransport(light, vec3(1), vec3(0)); + return light; } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index af199fd78c..fa81317f3f 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -1,5 +1,5 @@ /** - * @file softenLightF.glsl + * @file class2/deferred/softenLightF.glsl * * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code @@ -72,17 +72,43 @@ VARYING vec2 vary_fragcoord; uniform mat4 inv_proj; uniform vec2 screen_res; +uniform int no_atmo; + vec3 srgb_to_linear(vec3 cs); vec3 linear_to_srgb(vec3 cl); vec3 decode_normal (vec2 enc); -vec3 atmosFragAmbient(vec3 l, vec3 ambient); -vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); -vec3 scaleFragSoftClip(vec3 l); -vec3 atmosFragAffectDirectionalLight(float intensity, vec3 sunlit); void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); -vec3 fullbrightFragAtmosTransport(vec3 l, vec3 additive, vec3 atten); -vec3 fullbrightScaleSoftClipFrag(vec3 l, vec3 atten); +vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); +vec3 fullbrightScaleSoftClipFrag(vec3 l); +vec3 scaleSoftClipFrag(vec3 l); + +vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten) { + if (no_atmo == 0) + { + light *= atten.r; + light += additive * 2.0; + } + return light; +} + +vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) { + if (no_atmo == 1) + { + return light; + } + float brightness = dot(light.rgb, vec3(0.33333)); + return mix(atmosTransportFrag(light.rgb, additive, atten), light.rgb + additive.rgb, brightness * brightness); +} + +vec3 fullbrightShinyAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) { + if (no_atmo == 1) + { + return light; + } + float brightness = dot(light.rgb, vec3(0.33333)); + return mix(atmosTransportFrag(light.rgb, additive, atten), (light.rgb + additive.rgb) * (2.0 - brightness), brightness * brightness); +} vec4 getPosition_d(vec2 pos_screen, float depth) { @@ -121,7 +147,6 @@ void main() float light_gamma = 1.0/1.3; da = pow(da, light_gamma); - vec4 diffuse = texture2DRect(diffuseRect, tc); //convert to gamma space @@ -136,27 +161,23 @@ void main() scol_ambocc = pow(scol_ambocc, vec2(light_gamma)); float scol = max(scol_ambocc.r, diffuse.a); - - - float ambocc = scol_ambocc.g; - vec3 sunlit; - vec3 amblit; - vec3 additive; - vec3 atten; + vec3 sunlit; + vec3 amblit; + vec3 additive; + vec3 atten; calcFragAtmospherics(pos.xyz, ambocc, sunlit, amblit, additive, atten); - - col = atmosFragAmbient(vec3(0), amblit); + float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); ambient *= 0.5; ambient *= ambient; ambient = (1.0-ambient); - col.rgb *= ambient; + col.rgb = ambient * amblit; - col += atmosFragAffectDirectionalLight(max(min(da, scol), 0.0), sunlit); + col += sunlit * max(min(da, scol), 0.0); col *= diffuse.rgb; @@ -173,7 +194,6 @@ void main() bloom = dot(spec_contrib, spec_contrib) / 6; col += spec_contrib; } - col = mix(col, diffuse.rgb, diffuse.a); @@ -186,13 +206,12 @@ void main() if (norm.w < 0.5) { - vec3 add = additive; - col = mix(atmosFragLighting(col, add, atten), fullbrightFragAtmosTransport(col, atten, add), diffuse.a); - col = mix(scaleFragSoftClip(col), fullbrightScaleSoftClipFrag(col, atten), diffuse.a); + col = mix(atmosFragLighting(col, additive, atten), fullbrightAtmosTransportFrag(col, additive, atten), diffuse.a); + col = mix(scaleSoftClipFrag(col), fullbrightScaleSoftClipFrag(col), diffuse.a); } #ifdef WATER_FOG - vec4 fogged = applyWaterFogView(pos,vec4(col, bloom)); + vec4 fogged = applyWaterFogView(pos.xyz,vec4(col, bloom)); col = fogged.rgb; bloom = fogged.a; #endif diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl index 20c4d82ded..89bdbfc0e6 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl @@ -43,17 +43,7 @@ uniform float scene_light_strength; uniform mat3 ssao_effect_mat; uniform int no_atmo; -vec3 scaleFragSoftClip(vec3 light) -{ - if (no_atmo == 1) - { - return light; - } - //soft clip effect: - light = 1. - clamp(light, vec3(0.), vec3(1.)); - light = 1. - pow(light, gamma.xxx); - return light; -} +vec3 scaleSoftClipFrag(vec3 light); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten) { diff --git a/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl b/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl index f2764b72c3..187876acf7 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl @@ -30,8 +30,8 @@ uniform int no_atmo; vec3 getAtmosAttenuation(); -/// Soft clips the light with a gamma correction -vec3 scaleSoftClip(vec3 light) { +vec3 scaleSoftClipFrag(vec3 light) +{ if (no_atmo == 1) { return light; @@ -39,16 +39,21 @@ vec3 scaleSoftClip(vec3 light) { //soft clip effect: light = 1. - clamp(light, vec3(0.), vec3(1.)); light = 1. - pow(light, gamma.xxx); - return light; } -vec3 fullbrightScaleSoftClipFrag(vec3 light, vec3 atten) +vec3 scaleSoftClip(vec3 light) +{ + return scaleSoftClipFrag(light); +} + +vec3 fullbrightScaleSoftClipFrag(vec3 light) { - return (no_atmo == 1) ? light : mix(scaleSoftClip(light.rgb), light.rgb, atten); + return scaleSoftClipFrag(light.rgb); } -vec3 fullbrightScaleSoftClip(vec3 light) { - return (no_atmo == 1) ? light : fullbrightScaleSoftClipFrag(light.rgb, getAtmosAttenuation()); +vec3 fullbrightScaleSoftClip(vec3 light) +{ + return fullbrightScaleSoftClipFrag(light.rgb); } diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index d2fd70c9e2..2615400e52 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -115,7 +115,6 @@ void main() float light_gamma = 1.0/1.3; da = pow(da, light_gamma); - vec4 diffuse = texture2DRect(diffuseRect, tc); //convert to gamma space @@ -133,14 +132,6 @@ void main() float ambocc = scol_ambocc.g; - vec3 sunlit; - vec3 amblit; - vec3 additive; - vec3 atten; - - //calcFragAtmospherics(pos.xyz, ambocc, sunlit, amblit, additive, atten); - //col += atmosFragAffectDirectionalLight(max(min(da, scol), 0.0), sunlit); - col *= diffuse.rgb; vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); @@ -158,8 +149,7 @@ void main() bloom = dot(spec_contrib, spec_contrib) / 6; col += spec_contrib; } - - + col = mix(col, diffuse.rgb, diffuse.a); if (envIntensity > 0.0) @@ -169,12 +159,6 @@ void main() col = mix(col.rgb, refcol, envintensity); } - if (norm.w < 0.5) - { - //col = mix(atmosFragLighting(col, additive, atten), fullbrightFragAtmosTransport(col, atten, additive), diffuse.a); - //col = mix(scaleFragSoftClip(col), fullbrightScaleSoftClipFrag(col, atten), diffuse.a); - } - #ifdef WATER_FOG vec4 fogged = applyWaterFogView(pos,vec4(col, bloom)); col = fogged.rgb; diff --git a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl index c809a41a0f..a1b67fc31e 100644 --- a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsF.glsl @@ -42,13 +42,7 @@ uniform vec4 glow; uniform float scene_light_strength; uniform mat3 ssao_effect_mat; -vec3 scaleFragSoftClip(vec3 light) -{ - //soft clip effect: - light = 1. - clamp(light, vec3(0.), vec3(1.)); - light = 1. - pow(light, gamma.xxx); - return light; -} +vec3 scaleSoftClipFrag(vec3 light); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten) { diff --git a/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl index c2f4c43101..5c93af386b 100644 --- a/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl +++ b/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl @@ -32,41 +32,42 @@ vec3 getAtmosAttenuation(); uniform int no_atmo; -vec3 atmosFragTransport(vec3 light, vec3 atten, vec3 additive) { - if (no_atmo == 0) +vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten) { + if (no_atmo == 1) { - light *= atten.r; - light += additive * 2.0; + return light; } + light *= atten.r; + light += additive * 2.0; return light; } -vec3 fullbrightFragAtmosTransport(vec3 light, vec3 atten, vec3 additive) { - if (no_atmo) +vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) { + if (no_atmo == 1) { return light; } - loat brightness = dot(light.rgb, vec3(0.33333)); - return mix(atmosFragTransport(light.rgb, atten, additive), light.rgb + additive.rgb, brightness * brightness); + float brightness = dot(light.rgb, vec3(0.33333)); + return mix(atmosTransportFrag(light.rgb, additive,a tten), light.rgb + additive.rgb, brightness * brightness); } -vec3 fullbrightFragShinyAtmosTransport(vec3 light, vec3 atten, vec3 additive) { - if (no_atmo) +vec3 fullbrightShinyAtmosTransportFrag(vec3 light, vec3 atten, vec3 additive) { + if (no_atmo == 1) { return light; } float brightness = dot(light.rgb, vec3(0.33333)); - return mix(atmosFragTransport(light.rgb, atten, additive), (light.rgb + additive.rgb) * (2.0 - brightness), brightness * brightness); + return mix(atmosTransportFrag(light.rgb, additive, atten), (light.rgb + additive.rgb) * (2.0 - brightness), brightness * brightness); } vec3 atmosTransport(vec3 light) { - return no_atmo ? light : atmosFragTransport(light, getAtmosAttenuation(), getAdditiveColor()); + return (no_atmo == 1) ? light : atmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation()); } vec3 fullbrightAtmosTransport(vec3 light) { - return no_atmo ? light : fullbrightFragAtmosTransport(light, getAtmosAttenuation(), getAdditiveColor()); + return (no_atmo == 1) ? light : fullbrightAtmosTransportFrag(light, GetAdditiveColor(), getAtmosAttenuation()); } vec3 fullbrightShinyAtmosTransport(vec3 light) { - return no_atmo ? light : fullbrightFragShinyAtmosTransport(light, getAtmosAttenuation(), getAdditiveColor()); + return (no_atmo == 1) ? light : fullbrightShinyAtmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation()); } |