summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class3
diff options
context:
space:
mode:
authorJonathan "Geenz" Goodman <geenz@lindenlab.com>2024-11-25 20:56:03 -0500
committerGitHub <noreply@github.com>2024-11-25 20:56:03 -0500
commitd65fb7cec8ce36ce7f6ff082f8d04bdd8bc0208c (patch)
tree0005e8ec095fb31dcd4f8b079af585e3333c365f /indra/newview/app_settings/shaders/class3
parent7ef6e8fce763eb529ed160ea4ff11e6125e32ed5 (diff)
Drop emissive on old Intel GPUs (#3110)
* #3103 Add the ability to disable the emissive buffer for older GPUs with low memory bandwidth. * #3135 Add a "vintage" mode for slower GPUs * #2719 Fix for skies being overbrightened * #2632 Do not apply tonemapping on legacy skies
Diffstat (limited to 'indra/newview/app_settings/shaders/class3')
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/materialF.glsl9
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl31
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl33
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl81
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl36
-rw-r--r--indra/newview/app_settings/shaders/class3/environment/waterF.glsl36
8 files changed, 139 insertions, 91 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl
index 7b82aa1a0d..487db0a6ae 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl
@@ -64,8 +64,6 @@ void main()
calcAtmosphericVarsLinear(pos.xyz, norm.xyz, light_dir, sunlit, amblit, additive, atten);
- vec3 sunlit_linear = srgb_to_linear(sunlit);
-
// mask off atmospherics below water (when camera is under water)
bool do_atmospherics = false;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
index 3c13144299..e62f401817 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
@@ -51,7 +51,7 @@ uniform mat3 normal_matrix;
in vec3 vary_position;
void mirrorClip(vec3 pos);
-vec4 encodeNormal(vec3 norm, float gbuffer_flag);
+vec4 encodeNormal(vec3 n, float env, float gbuffer_flag);
#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)
@@ -415,8 +415,11 @@ void main()
frag_data[0] = max(vec4(diffcol.rgb, emissive), vec4(0)); // gbuffer is sRGB for legacy materials
frag_data[1] = max(vec4(spec.rgb, glossiness), vec4(0)); // XYZ = Specular color. W = Specular exponent.
- frag_data[2] = encodeNormal(norm, flag); // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog)
- frag_data[3] = vec4(env, 0, 0, 0);
+ frag_data[2] = encodeNormal(norm, env, flag); // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog)
+
+#if defined(HAS_EMISSIVE)
+ frag_data[3] = vec4(0, 0, 0, 0);
+#endif
#endif
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
index 4ed778371f..8db3bcd363 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
@@ -27,9 +27,6 @@
out vec4 frag_color;
-uniform sampler2D diffuseRect;
-uniform sampler2D specularRect;
-uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
uniform sampler2D lightFunc;
uniform vec3 env_mat[3];
@@ -55,13 +52,17 @@ vec3 srgb_to_linear(vec3 c);
// Util
vec3 hue_to_rgb(float hue);
-vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
+void pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
float metallic,
vec3 n, // normal
vec3 v, // surface point to camera
- vec3 l); //surface point to light
+ vec3 l, // surface point to light
+ out float nl,
+ out vec3 diff,
+ out vec3 spec);
+GBufferInfo getGBuffer(vec2 screenpos);
void main()
{
@@ -73,18 +74,19 @@ void main()
discard;
}
- vec4 norm = getNorm(tc); // need `norm.w` for GET_GBUFFER_FLAG()
- vec3 n = norm.xyz;
+ GBufferInfo gb = getGBuffer(tc);
- vec4 spec = texture(specularRect, tc);
- vec3 diffuse = texture(diffuseRect, tc).rgb;
+ vec3 n = gb.normal;
+
+ vec4 spec = gb.specular;
+ vec3 diffuse = gb.albedo.rgb;
vec3 h, l, v = -normalize(pos);
float nh, nv, vh, lightDist;
- if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
+ if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_HAS_PBR))
{
- vec3 colorEmissive = texture(emissiveRect, tc).rgb;
+ vec3 colorEmissive = gb.emissive.rgb;
vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
@@ -113,8 +115,11 @@ void main()
float dist_atten = calcLegacyDistanceAttenuation(dist, falloff);
vec3 intensity = dist_atten * lightColor * 3.25;
-
- final_color += intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv);
+ float nl = 0;
+ vec3 diff = vec3(0);
+ vec3 specPunc = vec3(0);
+ pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv, nl, diff, specPunc);
+ final_color += intensity * clamp(nl * (diff + specPunc), vec3(0), vec3(10));
}
}
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
index 6c13757149..987089fcc9 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
@@ -27,9 +27,6 @@
out vec4 frag_color;
-uniform sampler2D diffuseRect;
-uniform sampler2D specularRect;
-uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
uniform sampler2D lightFunc;
uniform vec3 env_mat[3];
@@ -57,24 +54,29 @@ vec2 getScreenCoord(vec4 clip);
vec3 srgb_to_linear(vec3 c);
float getDepth(vec2 tc);
-vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
+void pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
float metallic,
vec3 n, // normal
vec3 v, // surface point to camera
- vec3 l); //surface point to light
+ vec3 l, // surface point to light
+ out float nl,
+ out vec3 diff,
+ out vec3 spec);
+
+GBufferInfo getGBuffer(vec2 screenpos);
void main()
{
vec3 final_color = vec3(0);
vec2 tc = getScreenCoord(vary_fragcoord);
vec3 pos = getPosition(tc).xyz;
+ GBufferInfo gb = getGBuffer(tc);
- vec4 norm = getNorm(tc); // need `norm.w` for GET_GBUFFER_FLAG()
- vec3 n = norm.xyz;
+ vec3 n = gb.normal;
- vec3 diffuse = texture(diffuseRect, tc).rgb;
- vec4 spec = texture(specularRect, tc);
+ vec3 diffuse = gb.albedo.rgb;
+ vec4 spec = gb.specular;
// Common half vectors calcs
vec3 lv = trans_center.xyz-pos;
@@ -89,9 +91,9 @@ void main()
float dist = lightDist / size;
float dist_atten = calcLegacyDistanceAttenuation(dist, falloff);
- if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
+ if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_HAS_PBR))
{
- vec3 colorEmissive = texture(emissiveRect, tc).rgb;
+ vec3 colorEmissive = gb.emissive.rgb;
vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
@@ -104,7 +106,14 @@ void main()
vec3 specularColor = mix(f0, baseColor.rgb, metallic);
vec3 intensity = dist_atten * color * 3.25; // Legacy attenuation, magic number to balance with legacy materials
- final_color += intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, normalize(lv));
+
+ float nl = 0;
+ vec3 diffPunc = vec3(0);
+ vec3 specPunc = vec3(0);
+
+ pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, normalize(lv), nl, diffPunc, specPunc);
+
+ final_color += intensity* clamp(nl * (diffPunc + specPunc), vec3(0), vec3(10));
}
else
{
diff --git a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl
index dc135243a6..5eda28bd8a 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl
@@ -66,7 +66,7 @@ void main()
vec4 fcol = texture(diffuseMap, tc);
- if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
+ if (GET_GBUFFER_FLAG(norm.w, GBUFFER_FLAG_HAS_PBR))
{
vec3 orm = specCol.rgb;
float perceptualRoughness = orm.g;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index a9b299cfd7..52799dbba1 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -23,16 +23,12 @@
* $/LicenseInfo$
*/
+/*[EXTRA_CODE_HERE]*/
+
#define FLT_MAX 3.402823466e+38
out vec4 frag_color;
-vec4 decodeNormal(vec4 norm);
-
-uniform sampler2D diffuseRect;
-uniform sampler2D specularRect;
-uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
-
const float M_PI = 3.14159265;
#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO)
@@ -56,6 +52,8 @@ uniform mat3 ssao_effect_mat;
uniform vec3 sun_dir;
uniform vec3 moon_dir;
uniform int sun_up_factor;
+uniform int classic_mode;
+
in vec2 vary_fragcoord;
uniform mat4 inv_proj;
@@ -105,13 +103,7 @@ vec3 pbrBaseLight(vec3 diffuseColor,
vec3 additive,
vec3 atten);
-vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
- float perceptualRoughness,
- float metallic,
- vec3 n, // normal
- vec3 v, // surface point to camera
- vec3 l); //surface point to light
-
+GBufferInfo getGBuffer(vec2 screenpos);
void adjustIrradiance(inout vec3 irradiance, float ambocc)
{
@@ -128,13 +120,15 @@ void main()
vec2 tc = vary_fragcoord.xy;
float depth = getDepth(tc.xy);
vec4 pos = getPositionWithDepth(tc, depth);
- vec4 norm = getNorm(tc);
- vec3 colorEmissive = texture(emissiveRect, tc).rgb;
- float envIntensity = colorEmissive.r;
+
+ GBufferInfo gb = getGBuffer(tc);
+
+ vec3 colorEmissive = gb.emissive.rgb;
+ float envIntensity = gb.envIntensity;
vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
- vec4 baseColor = texture(diffuseRect, tc);
- vec4 spec = texture(specularRect, tc); // NOTE: PBR linear Emissive
+ vec4 baseColor = gb.albedo;
+ vec4 spec = gb.specular; // NOTE: PBR linear Emissive
#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO)
vec2 scol_ambocc = texture(lightMap, vary_fragcoord.xy).rg;
@@ -159,26 +153,26 @@ void main()
vec3 additive;
vec3 atten;
- calcAtmosphericVarsLinear(pos.xyz, norm.xyz, light_dir, sunlit, amblit, additive, atten);
+ calcAtmosphericVarsLinear(pos.xyz, gb.normal, light_dir, sunlit, amblit, additive, atten);
- vec3 sunlit_linear = srgb_to_linear(sunlit);
+ vec3 sunlit_linear = sunlit;
vec3 amblit_linear = amblit;
- vec3 irradiance = vec3(0);
vec3 radiance = vec3(0);
- if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
+ if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_HAS_PBR))
{
vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
float ao = orm.r;
+ vec3 irradiance = amblit_linear;
// PBR IBL
float gloss = 1.0 - perceptualRoughness;
- sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, norm.xyz, gloss, false, amblit_linear);
+ sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, gb.normal, gloss, false, amblit_linear);
adjustIrradiance(irradiance, ambocc);
@@ -187,17 +181,21 @@ void main()
calcDiffuseSpecular(baseColor.rgb, metallic, diffuseColor, specularColor);
vec3 v = -normalize(pos.xyz);
- color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten);
+ color = pbrBaseLight(diffuseColor, specularColor, metallic, v, gb.normal, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten);
}
- else if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_HDRI))
+ else if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_HAS_HDRI))
{
// actual HDRI sky, just copy color value
color = colorEmissive.rgb;
}
- else if (GET_GBUFFER_FLAG(GBUFFER_FLAG_SKIP_ATMOS))
+ else if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_SKIP_ATMOS))
{
//should only be true of WL sky, port over base color value and scale for fake HDR
+#if defined(HAS_EMISSIVE)
color = colorEmissive.rgb;
+#else
+ color = baseColor.rgb;
+#endif
color = srgb_to_linear(color);
color *= sky_hdr_scale;
}
@@ -208,31 +206,43 @@ void main()
spec.rgb = srgb_to_linear(spec.rgb);
- float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0);
+ float da = clamp(dot(gb.normal, light_dir.xyz), 0.0, 1.0);
- vec3 irradiance = vec3(0);
+ vec3 irradiance = amblit;
vec3 glossenv = vec3(0);
vec3 legacyenv = vec3(0);
- sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, norm.xyz, spec.a, envIntensity, false, amblit_linear);
+ sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, gb.normal, spec.a, envIntensity, false, amblit_linear);
adjustIrradiance(irradiance, ambocc);
// apply lambertian IBL only (see pbrIbl)
color.rgb = irradiance;
- vec3 sun_contrib = min(da, scol) * sunlit_linear;
- color.rgb += sun_contrib;
+ if (classic_mode > 0)
+ {
+ da = pow(da,1.2);
+ vec3 sun_contrib = vec3(min(da, scol));
+
+ color.rgb = srgb_to_linear(color.rgb * 0.9 + linear_to_srgb(sun_contrib) * sunlit_linear * 0.7);
+ sunlit_linear = srgb_to_linear(sunlit_linear);
+ }
+ else
+ {
+ vec3 sun_contrib = min(da, scol) * sunlit_linear;
+ color.rgb += sun_contrib;
+ }
+
color.rgb *= baseColor.rgb;
- vec3 refnormpersp = reflect(pos.xyz, norm.xyz);
+ vec3 refnormpersp = reflect(pos.xyz, gb.normal);
if (spec.a > 0.0)
{
vec3 lv = light_dir.xyz;
vec3 h, l, v = -normalize(pos.xyz);
float nh, nl, nv, vh, lightDist;
- vec3 n = norm.xyz;
+ vec3 n = gb.normal;
calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist);
if (nl > 0.0 && nh > 0.0)
@@ -249,7 +259,7 @@ void main()
}
// add radiance map
- applyGlossEnv(color, glossenv, spec, pos.xyz, norm.xyz);
+ applyGlossEnv(color, glossenv, spec, pos.xyz, gb.normal);
}
@@ -257,10 +267,11 @@ void main()
if (envIntensity > 0.0)
{ // add environment map
- applyLegacyEnv(color, legacyenv, spec, pos.xyz, norm.xyz, envIntensity);
+ applyLegacyEnv(color, legacyenv, spec, pos.xyz, gb.normal, envIntensity);
}
}
+ //color.r = classic_mode > 0 ? 1.0 : 0.0;
frag_color.rgb = max(color.rgb, vec3(0)); //output linear since local lights will be added to this shader's results
frag_color.a = 0.0;
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
index bc4d36d10d..78db8ccf5b 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
@@ -27,9 +27,6 @@
out vec4 frag_color;
-uniform sampler2D diffuseRect;
-uniform sampler2D specularRect;
-uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
uniform samplerCube environmentMap;
uniform sampler2D lightMap;
uniform sampler2D lightFunc;
@@ -80,12 +77,17 @@ vec4 getPosition(vec2 pos_screen);
const float M_PI = 3.14159265;
-vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
+void pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
float metallic,
vec3 n, // normal
vec3 v, // surface point to camera
- vec3 l); //surface point to light
+ vec3 l, // surface point to light
+ out float nl,
+ out vec3 diff,
+ out vec3 spec);
+
+GBufferInfo getGBuffer(vec2 screenpos);
void main()
{
@@ -118,8 +120,9 @@ void main()
shadow = clamp(shadow, 0.0, 1.0);
}
- vec4 norm = getNorm(tc);
- vec3 n = norm.xyz;
+ GBufferInfo gb = getGBuffer(tc);
+
+ vec3 n = gb.normal;
float dist_atten = calcLegacyDistanceAttenuation(dist, falloff);
if (dist_atten <= 0.0)
@@ -132,14 +135,14 @@ void main()
float nh, nl, nv, vh, lightDist;
calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist);
- vec3 diffuse = texture(diffuseRect, tc).rgb;
- vec4 spec = texture(specularRect, tc);
+ vec3 diffuse = gb.albedo.rgb;
+ vec4 spec = gb.specular;
vec3 dlit = vec3(0, 0, 0);
vec3 slit = vec3(0, 0, 0);
vec3 amb_rgb = vec3(0);
- if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
+ if (GET_GBUFFER_FLAG(gb.gbufferFlag, GBUFFER_FLAG_HAS_PBR))
{
vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
@@ -151,6 +154,8 @@ void main()
diffuseColor *= 1.0 - metallic;
vec3 specularColor = mix(f0, baseColor.rgb, metallic);
+ vec3 diffPunc = vec3(0);
+ vec3 specPunc = vec3(0);
// We need this additional test inside a light's frustum since a spotlight's ambiance can be applied
if (proj_tc.x > 0.0 && proj_tc.x < 1.0
@@ -168,16 +173,21 @@ void main()
dlit = getProjectedLightDiffuseColor( l_dist, proj_tc.xy );
vec3 intensity = dist_atten * dlit * 3.25 * shadow; // Legacy attenuation, magic number to balance with legacy materials
- final_color += intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv);
+
+ pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, normalize(lv), nl, diffPunc, specPunc);
+
+ final_color += intensity * clamp(nl * (diffPunc + specPunc), vec3(0), vec3(10));
}
amb_rgb = getProjectedLightAmbiance( amb_da, dist_atten, lit, nl, 1.0, proj_tc.xy ) * 3.25; //magic number to balance with legacy ambiance
- final_color += amb_rgb * pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, -lv);
+ pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, normalize(lv), nl, diffPunc, specPunc);
+
+ final_color += amb_rgb * clamp(nl * (diffPunc + specPunc), vec3(0), vec3(10));
}
}
else
{
- float envIntensity = texture(emissiveRect, tc).r;
+ float envIntensity = gb.envIntensity;
diffuse = srgb_to_linear(diffuse);
spec.rgb = srgb_to_linear(spec.rgb);
diff --git a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl
index a5592188a9..8bf4ec0a7e 100644
--- a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl
@@ -42,20 +42,25 @@ vec2 BRDF(float NoV, float roughness);
void calcDiffuseSpecular(vec3 baseColor, float metallic, inout vec3 diffuseColor, inout vec3 specularColor);
-vec3 pbrIbl(vec3 diffuseColor,
+void pbrIbl(vec3 diffuseColor,
vec3 specularColor,
vec3 radiance, // radiance map sample
vec3 irradiance, // irradiance map sample
float ao, // ambient occlusion factor
float nv, // normal dot view vector
- float perceptualRoughness);
-
-vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
- float metallic,
- vec3 n, // normal
- vec3 v, // surface point to camera
- vec3 l); //surface point to light
+ out vec3 diffuse,
+ out vec3 specular);
+
+void pbrPunctual(vec3 diffuseColor, vec3 specularColor,
+ float perceptualRoughness,
+ float metallic,
+ vec3 n, // normal
+ vec3 v, // surface point to camera
+ vec3 l, // surface point to light
+ out float nl,
+ out vec3 diff,
+ out vec3 spec);
vec3 pbrBaseLight(vec3 diffuseColor,
vec3 specularColor,
@@ -257,13 +262,20 @@ void main()
float NdotV = clamp(abs(dot(norm, v)), 0.001, 1.0);
- vec3 punctual = pbrPunctual(vec3(0), specularColor, 0.1, metallic, normalize(wavef+up*max(dist, 32.0)/32.0*(1.0-vdu)), v, normalize(light_dir));
+ float nl = 0;
+ vec3 diffPunc = vec3(0);
+ vec3 specPunc = vec3(0);
- vec3 color = punctual * sunlit_linear * 2.75 * shadow;
+ pbrPunctual(vec3(0), specularColor, 0.1, metallic, normalize(wavef+up*max(dist, 32.0)/32.0*(1.0-vdu)), v, normalize(light_dir), nl, diffPunc, specPunc);
- vec3 ibl = pbrIbl(vec3(0), vec3(1), radiance, vec3(0), ao, NdotV, 0.0);
+ vec3 punctual = clamp(nl * (diffPunc + specPunc), vec3(0), vec3(10));
+
+ vec3 color = punctual * sunlit_linear * 2.75 * shadow;
+ vec3 iblDiff;
+ vec3 iblSpec;
+ pbrIbl(vec3(0), vec3(1), radiance, vec3(0), ao, NdotV, 0.0, iblDiff, iblSpec);
- color += ibl;
+ color += iblDiff + iblSpec;
float nv = clamp(abs(dot(norm.xyz, v)), 0.001, 1.0);
vec2 brdf = BRDF(clamp(nv, 0, 1), 1.0);