You've already forked minecraft-assets
Create/Update assets for version 1.20.5-rc2
This commit is contained in:
24
assets/minecraft/shaders/program/box_blur.fsh
Normal file
24
assets/minecraft/shaders/program/box_blur.fsh
Normal file
@@ -0,0 +1,24 @@
|
||||
#version 150
|
||||
|
||||
uniform sampler2D DiffuseSampler;
|
||||
|
||||
in vec2 texCoord;
|
||||
in vec2 sampleStep;
|
||||
|
||||
uniform float Radius;
|
||||
uniform float RadiusMultiplier;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
// This shader relies on GL_LINEAR sampling to reduce the amount of texture samples in half.
|
||||
// Instead of sampling each pixel position with a step of 1 we sample between pixels with a step of 2.
|
||||
// In the end we sample the last pixel with a half weight, since the amount of pixels to sample is always odd (actualRadius * 2 + 1).
|
||||
void main() {
|
||||
vec4 blurred = vec4(0.0);
|
||||
float actualRadius = round(Radius * RadiusMultiplier);
|
||||
for (float a = -actualRadius + 0.5; a <= actualRadius; a += 2.0) {
|
||||
blurred += texture(DiffuseSampler, texCoord + sampleStep * a);
|
||||
}
|
||||
blurred += texture(DiffuseSampler, texCoord + sampleStep * actualRadius) / 2.0;
|
||||
fragColor = blurred / (actualRadius + 0.5);
|
||||
}
|
||||
Reference in New Issue
Block a user