Skip to content

Commit 3dbc492

Browse files
committed
Perfectly diffuse non-directionals, tweak vanilla-ish blocklight shading
1 parent c905684 commit 3dbc492

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

assets/lumi/shaders/prog/shading.glsl

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include lumi:shaders/common/userconfig.glsl
88
#include lumi:shaders/lib/pbr.glsl
99
#include lumi:shaders/lib/taa_jitter.glsl
10+
#include lumi:shaders/lib/util.glsl
1011
#include lumi:shaders/prog/shadow.glsl
1112
#include lumi:shaders/prog/tile_noise.glsl
1213
#include lumi:shaders/prog/water.glsl
@@ -149,6 +150,15 @@ struct shadingResult {
149150
vec3 diffuse;
150151
} shading0;
151152

153+
vec3 specularPbr(vec3 radiance, float roughness, vec3 f0, vec3 toLight, vec3 toEye, vec3 normal)
154+
{
155+
vec3 halfway = normalize(toEye + toLight);
156+
vec3 fresnel = pbr_fresnelSchlick(pbr_dot(toEye, halfway), f0);
157+
float NdotL = pbr_dot(normal, toLight);
158+
159+
return pbr_specularBRDF(roughness, radiance, halfway, toLight, toEye, normal, fresnel, NdotL);
160+
}
161+
152162
void lightPbr(vec3 albedo, float alpha, vec3 radiance, float roughness, float metallic, vec3 f0, vec3 toLight, vec3 toEye, vec3 normal, float disableDiffuse)
153163
{
154164
vec3 halfway = normalize(toEye + toLight);
@@ -212,19 +222,23 @@ vec4 shading(vec4 color, sampler2D natureTexture, vec4 light, float ao, vec2 mat
212222

213223
baseLight += (1.0 - frx_worldHasSkylight) * (atmosv_FogRadiance * 0.5 + 0.5) * SKYLESS_AMBIENT_STR;
214224
baseLight += (1.0 - frx_worldHasSkylight) * skylessColor * SKYLESS_AMBIENT_STR;
225+
baseLight += atmosv_SkyAmbientRadiance * lightmapRemap(light.y);
226+
baseLight += albedo * light.z * EMISSIVE_LIGHT_STR;
227+
215228

216229
float bl = l2_clampScale(0.03125, 0.96875, light.x);
217230

218231
float blWhite = max(light.z, step(0.93625, light.x));
219232
vec3 blColor = mix(BLOCK_LIGHT_COLOR, BLOCK_LIGHT_NEUTRAL, blWhite);
220233

221-
baseLight += blColor * BLOCK_LIGHT_STR * bl;
222-
baseLight += atmosv_SkyAmbientRadiance * lightmapRemap(light.y);
223-
baseLight += albedo * light.z * EMISSIVE_LIGHT_STR;
234+
vec3 blockLight = blColor * BLOCK_LIGHT_STR * bl;
224235

225-
lightPbr(albedo, color.a, baseLight, max(material.x, 0.5 * material.y), material.y, f0, normal, toEye, normal, disableDiffuse);
226-
float dotNorth = abs(dot(normal, vec3(0.0, 0.0, 1.0)));
227-
vec3 shaded = shading0.specular + shading0.diffuse * (0.6 + 0.4 * dotNorth);
236+
// vanilla-ish style diffuse
237+
float dotUpNorth = l2_max3(abs(normal * vec3(0.6, 1.0, 0.8)));
238+
// perfect diffuse light
239+
vec3 shaded = albedo * (baseLight + blockLight) * dotUpNorth * max(1.0 - material.y, 0.5) / PI;
240+
// block light specular
241+
shaded += specularPbr(blockLight, max(material.x, 0.5 * material.y), f0, normal, toEye, normal);
228242

229243
#if HANDHELD_LIGHT_RADIUS != 0
230244
if (frx_heldLight.w > 0) {

0 commit comments

Comments
 (0)