mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-26 10:12:54 +08:00
Add dynamic step size for DH noise
This commit is contained in:
@ -126,8 +126,19 @@ vec4 applyNoise(in vec4 fragColor, const in vec3 viewPos, const in float viewDis
|
||||
noiseAmplification = (1.0 - pow(lum * 2.0 - 1.0, 2.0)) * noiseAmplification; // Lessen the effect on depending on how dark the object is, equasion for this is -(2x-1)^{2}+1
|
||||
noiseAmplification *= fragColor.a; // The effect would lessen on transparent objects
|
||||
|
||||
// Mikis idea. make it such that you can control the step amount as distance increases out from where vanilla chunks end.
|
||||
// ideally, close = higher steps and far = lower steps
|
||||
float highestSteps = 16.0;
|
||||
float lowestSteps = 2.0;
|
||||
float transitionLength = 16.0 * 16.0; // distance it takes to reach the lowest steps from the highest. measured in meters/blocks.
|
||||
|
||||
float transitionGradient = clamp((length(viewPos - cameraPosition) - (far+32.0)) / transitionLength,0.0,1.0);
|
||||
transitionGradient = 1.0-pow(1.0-transitionGradient,2.0); // make the gradient appear smoother and less sudden when approaching low steps.
|
||||
|
||||
int dynamicNoiseSteps = int(mix(highestSteps, lowestSteps, transitionGradient));
|
||||
|
||||
// Random value for each position
|
||||
float randomValue = rand(quantize(viewPos, noiseSteps))
|
||||
float randomValue = rand(quantize(viewPos, dynamicNoiseSteps))
|
||||
* 2.0 * noiseAmplification - noiseAmplification;
|
||||
|
||||
// Modifies the color
|
||||
|
Reference in New Issue
Block a user