add new shadow sample shape to translucents rendering

This commit is contained in:
Xonk 2024-05-10 15:36:29 -04:00
parent 749b109b44
commit a74595afb6
4 changed files with 33 additions and 10 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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