allow shadows to cast anywhere freely. this sacrifices the smooth transition that they had beforehand.

This commit is contained in:
Xonk
2025-03-10 01:11:18 -04:00
parent d31ebc8630
commit 940a202327
5 changed files with 40 additions and 48 deletions

View File

@ -140,7 +140,7 @@ float encodeVec2(float x,float y){
#ifdef OVERWORLD_SHADER
float ComputeShadowMap(inout vec3 directLightColor, vec3 playerPos, float maxDistFade){
if(maxDistFade <= 0.0) return 1.0;
// if(maxDistFade <= 0.0) return 1.0;
// setup shadow projection
vec3 projectedShadowPosition = mat3(shadowModelView) * playerPos + shadowModelView[3].xyz;
@ -191,7 +191,8 @@ float ComputeShadowMap(inout vec3 directLightColor, vec3 playerPos, float maxDis
directLightColor *= mix(vec3(1.0), translucentTint.rgb, maxDistFade);
#endif
return mix(1.0, shadowmap, maxDistFade);
return shadowmap;
// return mix(1.0, shadowmap, maxDistFade);
}
#endif
@ -417,7 +418,7 @@ void main() {
Shadows = ComputeShadowMap(directLightColor, shadowPlayerPos, shadowMapFalloff);
Shadows = mix(LM_shadowMapFallback, Shadows, shadowMapFalloff2);
Shadows *= mix(LM_shadowMapFallback, 1.0, shadowMapFalloff2);
#ifdef CLOUDS_SHADOWS
Shadows *= GetCloudShadow(feetPlayerPos+cameraPosition, WsunVec);

View File

@ -290,7 +290,7 @@ uniform float dhFarPlane;
#ifdef OVERWORLD_SHADER
float ComputeShadowMap(inout vec3 directLightColor, vec3 playerPos, float maxDistFade, float noise){
if(maxDistFade <= 0.0) return 1.0;
// if(maxDistFade <= 0.0) return 1.0;
// setup shadow projection
vec3 projectedShadowPosition = mat3(shadowModelView) * playerPos + shadowModelView[3].xyz;
@ -365,7 +365,8 @@ float ComputeShadowMap(inout vec3 directLightColor, vec3 playerPos, float maxDis
directLightColor *= mix(vec3(1.0), translucentTint.rgb / samples, maxDistFade);
#endif
return mix(1.0, shadowmap / samples, maxDistFade);
return shadowmap / samples;
// return mix(1.0, shadowmap / samples, maxDistFade);
}
#endif
@ -584,7 +585,8 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
Shadows = ComputeShadowMap(DirectLightColor, shadowPlayerPos, shadowMapFalloff, blueNoise());
Shadows = mix(LM_shadowMapFallback, Shadows, shadowMapFalloff2);
// Shadows = mix(LM_shadowMapFallback, Shadows, shadowMapFalloff2);
Shadows *= mix(LM_shadowMapFallback,1.0,shadowMapFalloff2);
#ifdef CLOUDS_SHADOWS
Shadows *= GetCloudShadow(feetPlayerPos+cameraPosition, WsunVec);

View File

@ -457,9 +457,9 @@ void main() {
}
#endif
if (z < 1.0){
// if (z < 1.0){
gl_FragData[0] = vec4(minshadowfilt, 0.1, 0.0, 0.0);
gl_FragData[0] = vec4(minshadowfilt, 0.0, 0.0, 0.0);
#ifdef Variable_Penumbra_Shadows
if (LabSSS > -1) {
@ -467,6 +467,8 @@ void main() {
vec3 feetPlayerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz;
vec3 projectedShadowPosition = mat3(shadowModelView) * feetPlayerPos + shadowModelView[3].xyz;
projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
float TEST = projectedShadowPosition.z * (0.5/6.0) + 0.5;
//apply distortion
#ifdef DISTORT_SHADOWMAP
@ -477,7 +479,7 @@ void main() {
#endif
//do shadows only if on shadow map
// if (abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.z) < 6.0 || length(feetPlayerPos) < far){
if (abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.z) < 6.0 ){
const float threshMul = max(2048.0/shadowMapResolution*shadowDistance/128.0,0.95);
float distortThresh = (sqrt(1.0-NdotL*NdotL)/NdotL+0.7)/distortFactor;
float diffthresh = distortThresh/6000.0*threshMul;
@ -495,7 +497,7 @@ void main() {
// vec2 offsetS = SpiralSample(i, 7, 8, noise) * 0.5;
vec2 offsetS = CleanSample(i, VPS_Search_Samples - 1, noise) * 0.5;
float weight = 3.0 + (i+noise) *rdMul/SHADOW_FILTER_SAMPLE_COUNT*shadowMapResolution*distortFactor/2.7;
float d = texelFetch2D(shadow, ivec2((projectedShadowPosition.xy+offsetS*rdMul)*shadowMapResolution),0).x;
@ -508,21 +510,23 @@ void main() {
#else
avgDepth += max(projectedShadowPosition.z - d, 0.0)*1000.0;
#endif
avgBlockerDepth += d * b;
}
gl_FragData[0].g = avgDepth / VPS_Search_Samples;
gl_FragData[0].b = blockerCount / VPS_Search_Samples;
if (blockerCount >= 0.9){
avgBlockerDepth /= blockerCount;
float ssample = max(projectedShadowPosition.z - avgBlockerDepth,0.0)*1500.0;
gl_FragData[0].r = clamp(ssample, scales.x, scales.y)/(scales.y)*(mult-minshadowfilt)+minshadowfilt;
}
// }
gl_FragData[0].g = avgDepth / VPS_Search_Samples;
gl_FragData[0].b = blockerCount / VPS_Search_Samples;
if (blockerCount >= 0.9){
avgBlockerDepth /= blockerCount;
float ssample = max(projectedShadowPosition.z - avgBlockerDepth,0.0)*1500.0;
gl_FragData[0].r = clamp(ssample, scales.x, scales.y)/(scales.y)*(mult-minshadowfilt)+minshadowfilt;
}
}
}
#endif
}
// }
#endif
}

View File

@ -626,9 +626,9 @@ vec3 ComputeShadowMap_COLOR(in vec3 projectedShadowPosition, float distortFactor
tintedSunlight *= translucentTint.rgb / samples;
// #endif
return mix(directLightColor, shadowColor.rgb / samples, maxDistFade);
// return 1.0;
// return mix(1.0, shadow / samples, maxDistFade);
return shadowColor.rgb / samples;
// return mix(directLightColor, shadowColor.rgb / samples, maxDistFade);
}
#endif
@ -1071,16 +1071,16 @@ void main() {
#ifdef SCREENSPACE_CONTACT_SHADOWS
vec2 SS_directLight = SSRT_Shadows(toScreenSpace_DH(texcoord/RENDER_SCALE, z, DH_depth1), isDHrange, normalize(WsunVec*mat3(gbufferModelViewInverse)), interleaved_gradientNoise_temporal(), sunSSS_density > 0.0 && shadowMapFalloff2 < 1.0, hand);
// Shadows = SS_directLight.r;
// combine shadowmap with a minumum shadow determined by the screenspace shadows.
shadowColor *= SS_directLight.r;
// combine shadowmap blocker depth with a minumum determined by the screenspace shadows, starting after the shadowmap ends
ShadowBlockerDepth = mix(SS_directLight.g, ShadowBlockerDepth, shadowMapFalloff2);
// shadowColor = vec3(SS_directLight.r*0 + 1);
// ShadowBlockerDepth = SS_directLight.g;
ShadowBlockerDepth = max(ShadowBlockerDepth, SS_directLight.g*(1.0-shadowMapFalloff2));
#else
ShadowBlockerDepth = max(ShadowBlockerDepth, (1.0-shadowMapFalloff2) * 10.0);
#endif
#ifdef TRANSLUCENT_COLORED_SHADOWS
SSSColor = tintedSunlight;
#else
@ -1090,11 +1090,7 @@ void main() {
SSSColor *= SubsurfaceScattering_sun(albedo, ShadowBlockerDepth, sunSSS_density, clamp(dot(feetPlayerPos_normalized, WsunVec),0.0,1.0), SSS_shadow, shadowMapFalloff2);
if(isEyeInWater != 1) SSSColor *= lightLeakFix;
#ifndef SCREENSPACE_CONTACT_SHADOWS
SSSColor = mix(vec3(0.0), SSSColor, shadowMapFalloff2);
#endif
#ifdef CLOUDS_SHADOWS
float cloudShadows = GetCloudShadow(feetPlayerPos.xyz + cameraPosition, WsunVec);
shadowColor *= cloudShadows;
@ -1289,10 +1285,8 @@ void main() {
#ifdef AO_in_sunlight
// Direct_lighting = max(shadowColor*NdotL * (AO*0.7+0.3), SSSColor);
Direct_lighting = shadowColor*NdotL*(AO*0.7+0.3) + SSSColor * (1.0-NdotL);
#else
// Direct_lighting = max(shadowColor*NdotL, SSSColor);
Direct_lighting = shadowColor*NdotL + SSSColor * (1.0-NdotL);
#endif
#endif