From a74595afb6e40d4a3591c64c2e8e37f50a54a091 Mon Sep 17 00:00:00 2001 From: Xonk Date: Fri, 10 May 2024 15:36:29 -0400 Subject: [PATCH] add new shadow sample shape to translucents rendering --- shaders/dimensions/DH_solid.vsh | 2 +- shaders/dimensions/all_translucent.fsh | 25 ++++++++++++++++++++++++- shaders/dimensions/composite.fsh | 4 ++-- shaders/lib/climate_settings.glsl | 12 ++++++------ 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/shaders/dimensions/DH_solid.vsh b/shaders/dimensions/DH_solid.vsh index 0694f08..6e77482 100644 --- a/shaders/dimensions/DH_solid.vsh +++ b/shaders/dimensions/DH_solid.vsh @@ -91,7 +91,7 @@ void main() { #if defined Seasons && defined OVERWORLD_SHADER - YearCycleColor(gcolor.rgb, gl_Color.rgb, dhMaterialId == DH_BLOCK_LEAVES, dh_material_id == DH_BLOCK_GRASS); + YearCycleColor(gcolor.rgb, gl_Color.rgb, dhMaterialId == DH_BLOCK_LEAVES, dhMaterialId == DH_BLOCK_GRASS); #endif #if DOF_QUALITY == 5 diff --git a/shaders/dimensions/all_translucent.fsh b/shaders/dimensions/all_translucent.fsh index 462f29b..93aa7d2 100644 --- a/shaders/dimensions/all_translucent.fsh +++ b/shaders/dimensions/all_translucent.fsh @@ -207,6 +207,28 @@ vec2 tapLocation_simple( return vec2(cos_v, sin_v) * sqrt(alpha); } +vec2 CleanSample( + int samples, float totalSamples, float noise +){ + + // this will be used to make 1 full rotation of the spiral. the mulitplication is so it does nearly a single rotation, instead of going past where it started + float variance = noise * 0.897; + + // for every sample input, it will have variance applied to it. + float variedSamples = float(samples) + variance; + + // for every sample, the sample position must change its distance from the origin. + // otherwise, you will just have a circle. + float spiralShape = pow(variedSamples / (totalSamples + variance),0.5); + + float shape = 2.26; // this is very important. 2.26 is very specific + float theta = variedSamples * (PI * shape); + + float x = cos(theta) * spiralShape; + float y = sin(theta) * spiralShape; + + return vec2(x, y); +} vec3 viewToWorld(vec3 viewPos) { vec4 pos; @@ -370,7 +392,8 @@ float ComputeShadowMap(inout vec3 directLightColor, vec3 playerPos, float maxDis float rdMul = 14.0*distortFactor*d0*k/shadowMapResolution; for(int i = 0; i < samples; i++){ - vec2 offsetS = tapLocation_simple(i, 7, 9, noise) *0.5; + // vec2 offsetS = tapLocation_simple(i, 7, 9, noise) * 0.5; + vec2 offsetS = CleanSample(i, samples - 1, noise) * 0.3; projectedShadowPosition.xy += rdMul*offsetS; #else int samples = 1; diff --git a/shaders/dimensions/composite.fsh b/shaders/dimensions/composite.fsh index d2b4d66..9cb9989 100644 --- a/shaders/dimensions/composite.fsh +++ b/shaders/dimensions/composite.fsh @@ -505,8 +505,8 @@ void main() { for(int i = 0; i < VPS_Search_Samples; i++){ - vec2 offsetS = SpiralSample(i, 7, 8, noise) * 0.5; - // vec2 offsetS = CleanSample(i, VPS_Search_Samples - 1, noise) * 0.5; + // 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; diff --git a/shaders/lib/climate_settings.glsl b/shaders/lib/climate_settings.glsl index e25125b..a446b09 100644 --- a/shaders/lib/climate_settings.glsl +++ b/shaders/lib/climate_settings.glsl @@ -67,14 +67,14 @@ vec3 SpringToSummer = mix(WinterToSpring, SummerCol, SpringTime); // make it so that you only have access to parts of the texture that use the tint index - bool IsTintIndex = floor(dot(glcolor,vec3(0.5))) < 1.0; + #ifdef DH_SEASONS + bool IsTintIndex = isPlants || isLeaves; + #else + bool IsTintIndex = floor(dot(glcolor,vec3(0.5))) < 1.0; + #endif // multiply final color by the final lerped color, because it contains all the other colors. - #ifdef DH_SEASONS - if(isPlants || isLeaves) FinalColor = SpringToSummer; - #else - if(IsTintIndex) FinalColor = SpringToSummer; - #endif + if(IsTintIndex) FinalColor = SpringToSummer; // #ifdef Snowy_Winter // // this is to make snow only exist in winter