mirror of
https://github.com/Merlin1809/Eclipse-Shader.git
synced 2026-10-10 04:53:07 +08:00
Improve pom shadow fix
This commit is contained in:
@@ -412,7 +412,6 @@ void main() {
|
||||
|
||||
vec2 adjustedTexCoord = data_in.lmtexcoord.xy;
|
||||
|
||||
float saveDepth = 0.0;
|
||||
#if defined POM && (defined WORLD && !defined ENTITIES && !defined HAND || defined COLORWHEEL)
|
||||
// vec2 tempOffset=offsets[framemod8];
|
||||
|
||||
@@ -436,6 +435,8 @@ void main() {
|
||||
|
||||
#if defined DEPTH_WRITE_POM
|
||||
gl_FragDepth = gl_FragCoord.z;
|
||||
float original_depth = gl_FragCoord.z;
|
||||
float final_depth = gl_FragCoord.z;
|
||||
#endif
|
||||
|
||||
#if !defined BLOCKENTITIES && !defined ENTITIES && !defined HAND && defined SHADER_GRASS && !defined COLORWHEEL && defined WORLD && !defined CUTOUT
|
||||
@@ -464,15 +465,6 @@ void main() {
|
||||
for (int loopCount = 0; (loopCount < MAX_OCCLUSION_POINTS) && (1.0 - pomdepth + pomdepth * readNormal(coord.st).a ) < coord.p && coord.p >= 0.0; ++loopCount) {
|
||||
coord = coord + interval * used_POM_DEPTH;
|
||||
sumVec += used_POM_DEPTH;
|
||||
|
||||
#if defined POM_OFFSET_SHADOW_BIAS
|
||||
// absolutely disgusting but works for now
|
||||
if(loopCount > MAX_OCCLUSION_POINTS*0.01 * POM_DEPTH * 30.0) saveDepth = max(0.20,saveDepth);
|
||||
if(loopCount > MAX_OCCLUSION_POINTS*0.02 * POM_DEPTH * 30.0) saveDepth = max(0.25,saveDepth);
|
||||
if(loopCount > MAX_OCCLUSION_POINTS*0.03 * POM_DEPTH * 30.0) saveDepth = max(0.30,saveDepth);
|
||||
if(loopCount > MAX_OCCLUSION_POINTS*0.05 * POM_DEPTH * 30.0) saveDepth = max(0.35,saveDepth);
|
||||
if(loopCount > MAX_OCCLUSION_POINTS*0.06 * POM_DEPTH * 30.0) saveDepth = max(0.40,saveDepth);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (coord.t < mincoord) {
|
||||
@@ -486,7 +478,8 @@ void main() {
|
||||
|
||||
#if defined DEPTH_WRITE_POM
|
||||
vec3 truePos = fragpos + sumVec*inverseMatrix(tbnMatrix)*interval;
|
||||
gl_FragDepth = toClipSpace3(truePos).z;
|
||||
final_depth = toClipSpace3(truePos).z;
|
||||
gl_FragDepth = final_depth;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -713,7 +706,8 @@ void main() {
|
||||
Albedo.a = opaqueMasks;
|
||||
|
||||
#if defined POM_OFFSET_SHADOW_BIAS && defined POM && (!defined ENTITIES && !defined HAND || defined COLORWHEEL)
|
||||
if(saveDepth > 0) Albedo.a = saveDepth;
|
||||
float pom_offset = abs(final_depth-original_depth);
|
||||
if(pom_offset > 0.0) Albedo.a = pom_offset*8.0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -375,7 +375,7 @@ float ComputeShadowMap(inout vec3 directLightColor, vec3 playerPos, float maxDis
|
||||
vec3 projectedShadowPosition = mat3(shadowModelView) * playerPos + shadowModelView[3].xyz;
|
||||
#endif
|
||||
|
||||
applyShadowBias(projectedShadowPosition, playerPos, geoNormals, 0.0);
|
||||
applyShadowBias(projectedShadowPosition, playerPos, geoNormals);
|
||||
|
||||
projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
|
||||
|
||||
@@ -394,7 +394,7 @@ float ComputeShadowMap(inout vec3 directLightColor, vec3 playerPos, float maxDis
|
||||
|
||||
#if defined END_ISLAND_LIGHT && defined END_SHADER
|
||||
vec4 shadowPos = customShadowMatrixSSBO * vec4(playerPos, 1.0);
|
||||
applyShadowBias(shadowPos.xyz, playerPos, geoNormals, 0.0);
|
||||
applyShadowBias(shadowPos.xyz, playerPos, geoNormals);
|
||||
shadowPos = customShadowPerspectiveSSBO * shadowPos;
|
||||
vec3 projectedShadowPosition = shadowPos.xyz / shadowPos.w;
|
||||
#endif
|
||||
|
||||
@@ -1071,7 +1071,7 @@ void main() {
|
||||
// bool isReflective = abs(translucentMasks - 0.7) < 0.01 || isWater || isReflectiveEntity;
|
||||
// bool isEntity = abs(translucentMasks - 0.9) < 0.01 || isReflectiveEntity;
|
||||
|
||||
bool lightningBolt = abs(opaqueMasks-0.5) <0.01;
|
||||
// bool lightningBolt = abs(opaqueMasks-0.5) <0.01;
|
||||
// bool isLeaf = abs(opaqueMasks-0.55) <0.01;
|
||||
bool entities = abs(opaqueMasks-0.45) < 0.01;
|
||||
bool isGrass = abs(opaqueMasks-0.60) < 0.01;
|
||||
@@ -1084,7 +1084,7 @@ void main() {
|
||||
#endif
|
||||
|
||||
#if defined POM_OFFSET_SHADOW_BIAS
|
||||
float POM_DEEPNESS = opaqueMasks < 0.43 ? 1.0 - min(max(0.4-opaqueMasks,0.0)/0.4,1.0) : 0.0;
|
||||
float POM_DEEPNESS = opaqueMasks < 0.43 ? opaqueMasks*2.5 : 0.0;
|
||||
#else
|
||||
const float POM_DEEPNESS = 0.0;
|
||||
#endif
|
||||
@@ -1304,8 +1304,16 @@ void main() {
|
||||
shadowMapFalloff = 1.0;
|
||||
shadowMapFalloff2 = 1.0;
|
||||
}
|
||||
|
||||
vec3 shadowPlayerPos = feetPlayerPos;
|
||||
|
||||
#if defined POM_OFFSET_SHADOW_BIAS && defined POM
|
||||
vec3 viewPos2 = toScreenSpace(vec3(texcoord/RENDER_SCALE - TAA_Offset*texelSize*0.5, z - POM_DEEPNESS / 20.0));
|
||||
|
||||
vec3 feetPlayerPos2 = mat3(gbufferModelViewInverse) * viewPos2 + gbufferModelViewInverse[3].xyz;
|
||||
|
||||
vec3 shadowPlayerPos = feetPlayerPos2;
|
||||
#else
|
||||
vec3 shadowPlayerPos = feetPlayerPos;
|
||||
#endif
|
||||
|
||||
#if LIGHTLEAKFIX_MODE == 1
|
||||
if(!hand) GriAndEminShadowFix(shadowPlayerPos, FlatNormals, lightLeakFix);
|
||||
@@ -1318,7 +1326,7 @@ void main() {
|
||||
vec3 projectedShadowPosition = mat3(shadowModelView) * shadowPlayerPos + shadowModelView[3].xyz;
|
||||
#endif
|
||||
|
||||
applyShadowBias(projectedShadowPosition, shadowPlayerPos, FlatNormals, POM_DEEPNESS);
|
||||
applyShadowBias(projectedShadowPosition, shadowPlayerPos, FlatNormals);
|
||||
projectedShadowPosition = diagonal3_old(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
|
||||
|
||||
// Calclulate distortion factor before bias application
|
||||
@@ -1336,7 +1344,7 @@ void main() {
|
||||
|
||||
#if defined END_ISLAND_LIGHT && defined END_SHADER
|
||||
vec4 shadowPos = customShadowMatrixSSBO * (gbufferModelViewInverse * vec4(viewPos, 1.0));
|
||||
applyShadowBias(shadowPos.xyz, shadowPlayerPos, FlatNormals, POM_DEEPNESS);
|
||||
applyShadowBias(shadowPos.xyz, shadowPlayerPos, FlatNormals);
|
||||
shadowPos = customShadowPerspectiveSSBO * shadowPos;
|
||||
vec3 projectedShadowPosition = shadowPos.xyz / shadowPos.w;
|
||||
#endif
|
||||
@@ -1484,7 +1492,7 @@ void main() {
|
||||
float photonicsFalloff = smoothstep(128.0, 114.0, viewDist);
|
||||
#endif
|
||||
|
||||
vec3 gi_color = texture(colortex15, texcoord).xyz*2.5*PHOTONICS_INDIRECT_BRIGHTNESS;
|
||||
vec3 gi_color = texture(colortex15, texcoord).xyz*2.5*PHOTONICS_INDIRECT_BRIGHTNESS* skylight;
|
||||
gi_color += mix(MinimumLightColor * (MIN_LIGHT_AMOUNT * 0.004 + nightVision*0.02), MinimumLightColor * (MIN_LIGHT_AMOUNT_INSIDE * 0.004 + nightVision*0.02), 1.0-lightmap.y);
|
||||
|
||||
Indirect_lighting = mix(Indirect_lighting, gi_color, photonicsFalloff);
|
||||
@@ -1642,7 +1650,7 @@ void main() {
|
||||
|
||||
Emission(FINAL_COLOR, albedo, SpecularTex.a);
|
||||
|
||||
if(lightningBolt) FINAL_COLOR = vec3(77.0, 153.0, 255.0);
|
||||
// if(lightningBolt) FINAL_COLOR = vec3(77.0, 153.0, 255.0);
|
||||
|
||||
#if defined DEFERRED_SPECULAR
|
||||
vec3 specularNoises = vec3(vec2(blueNoise(), ig_noise), ig_noise);
|
||||
|
||||
@@ -13,14 +13,10 @@ void GriAndEminShadowFix(
|
||||
if(zoomLevel > 0.001 && isEyeInWater != 1) WorldPos = WorldPos - ( fract(WorldPos+cameraPosition - WorldPos*0.0001)*zoomLevel - zoomLevel*0.5);
|
||||
}
|
||||
|
||||
void applyShadowBias(inout vec3 projectedShadowPosition, in vec3 playerPos, in vec3 geoNormals, float POM_DEEPNESS){
|
||||
void applyShadowBias(inout vec3 projectedShadowPosition, in vec3 playerPos, in vec3 geoNormals){
|
||||
|
||||
// Calculate the bias size according to the 1:1 ratio of one shadow texel to one full block
|
||||
#if defined POM_OFFSET_SHADOW_BIAS
|
||||
float biasSize = (shadowDistance / shadowMapResolution*2.0) * (2.0 + POM_DEEPNESS*(1.0+POM_DEPTH*3.0));
|
||||
#else
|
||||
float biasSize = (shadowDistance / shadowMapResolution*2.0) * 2.0;
|
||||
#endif
|
||||
float biasSize = (shadowDistance / shadowMapResolution*2.0) * 2.0;
|
||||
|
||||
float biasDistanceFactor = length(projectedShadowPosition.xy);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user