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) {
@ -468,6 +468,8 @@ void main() {
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
float distortFactor = calcDistort(projectedShadowPosition.xy);
@ -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;
@ -513,6 +515,7 @@ void main() {
}
gl_FragData[0].g = avgDepth / VPS_Search_Samples;
gl_FragData[0].b = blockerCount / VPS_Search_Samples;
if (blockerCount >= 0.9){
@ -520,9 +523,10 @@ void main() {
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
}
#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);
ShadowBlockerDepth = max(ShadowBlockerDepth, SS_directLight.g*(1.0-shadowMapFalloff2));
// shadowColor = vec3(SS_directLight.r*0 + 1);
// ShadowBlockerDepth = SS_directLight.g;
#else
ShadowBlockerDepth = max(ShadowBlockerDepth, (1.0-shadowMapFalloff2) * 10.0);
#endif
#ifdef TRANSLUCENT_COLORED_SHADOWS
SSSColor = tintedSunlight;
#else
@ -1091,10 +1091,6 @@ void main() {
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

View File

@ -122,21 +122,12 @@ const float sunPathRotation = -35; //[-90 -89 -88 -87 -86 -85 -84 -83 -82 -81 -8
const int shadowMapResolution = 2048; // [512 768 1024 1536 2048 3172 4096 8192]
const float shadowDistance = 128.0; // [32.0 48.0 64.0 80.0 96.0 112.0 128.0 144.0 160.0 176.0 192.0 208.0 224.0 240.0 256.0 272.0 288.0 304.0 320.0 336.0 352.0 368.0 384.0 512.0 768.0 1024.0 1536.0 2048.0 4096.0 8192.0]
#ifdef IS_IRIS
#define OPTIMIZED_SHADOW_DISTANCE 1 // [-1 1]
const float shadowDistanceRenderMul = OPTIMIZED_SHADOW_DISTANCE;
#else
#define OPTIMIZED_SHADOW_DISTANCE 1 // [-1 1]
const float shadowDistanceRenderMul = float(OPTIMIZED_SHADOW_DISTANCE);
#endif
const float shadowDistanceRenderMul = 1.0;
const float entityShadowDistanceMul = 0.25; // [0.01 0.02 0.03 0.04 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.75 1.00]
#define RENDER_ENTITY_SHADOWS
#define RENDER_PLAYER_SHADOWS
#define SCREENSPACE_CONTACT_SHADOWS
#define Variable_Penumbra_Shadows
#define VPS_Search_Samples 4 // [4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32]