|
7 | 7 | #include lumi:shaders/common/userconfig.glsl |
8 | 8 | #include lumi:shaders/lib/pbr.glsl |
9 | 9 | #include lumi:shaders/lib/taa_jitter.glsl |
| 10 | +#include lumi:shaders/lib/util.glsl |
10 | 11 | #include lumi:shaders/prog/shadow.glsl |
11 | 12 | #include lumi:shaders/prog/tile_noise.glsl |
12 | 13 | #include lumi:shaders/prog/water.glsl |
@@ -149,6 +150,15 @@ struct shadingResult { |
149 | 150 | vec3 diffuse; |
150 | 151 | } shading0; |
151 | 152 |
|
| 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 | + |
152 | 162 | void lightPbr(vec3 albedo, float alpha, vec3 radiance, float roughness, float metallic, vec3 f0, vec3 toLight, vec3 toEye, vec3 normal, float disableDiffuse) |
153 | 163 | { |
154 | 164 | vec3 halfway = normalize(toEye + toLight); |
@@ -212,19 +222,23 @@ vec4 shading(vec4 color, sampler2D natureTexture, vec4 light, float ao, vec2 mat |
212 | 222 |
|
213 | 223 | baseLight += (1.0 - frx_worldHasSkylight) * (atmosv_FogRadiance * 0.5 + 0.5) * SKYLESS_AMBIENT_STR; |
214 | 224 | 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 | + |
215 | 228 |
|
216 | 229 | float bl = l2_clampScale(0.03125, 0.96875, light.x); |
217 | 230 |
|
218 | 231 | float blWhite = max(light.z, step(0.93625, light.x)); |
219 | 232 | vec3 blColor = mix(BLOCK_LIGHT_COLOR, BLOCK_LIGHT_NEUTRAL, blWhite); |
220 | 233 |
|
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; |
224 | 235 |
|
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); |
228 | 242 |
|
229 | 243 | #if HANDHELD_LIGHT_RADIUS != 0 |
230 | 244 | if (frx_heldLight.w > 0) { |
|
0 commit comments