Pixel-Composer/shaders/sh_downsample/sh_downsample.fsh

26 lines
460 B
Plaintext
Raw Normal View History

2023-03-26 07:13:36 +02:00
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform float down;
uniform vec2 dimension;
void main() {
vec4 col = vec4(0.);
2023-10-18 14:58:55 +02:00
vec2 tx = 1. / dimension;
2023-03-26 07:13:36 +02:00
float wei = 0.;
for( float i = 0.; i < down; i++ )
for( float j = 0.; j < down; j++ ) {
2023-10-18 14:58:55 +02:00
vec4 samp = texture2D( gm_BaseTexture, v_vTexcoord * down + vec2(i, j) * tx );
2023-03-26 07:13:36 +02:00
col += samp;
2023-08-31 18:49:57 +02:00
wei += samp.a;
2023-03-26 07:13:36 +02:00
}
2023-08-31 18:49:57 +02:00
col /= wei;
2023-03-26 07:13:36 +02:00
2023-10-18 14:58:55 +02:00
gl_FragColor = col;
2023-03-26 07:13:36 +02:00
}