demotool/shaders/downsample.f.glsl

21 lines
675 B
Text
Raw Normal View History

2017-09-30 21:22:38 +02:00
#version 450 core
2017-10-04 17:48:25 +02:00
//! type fragment
2017-09-30 21:22:38 +02:00
layout( location = 0 ) uniform sampler2D u_InputTexture;
layout( location = 1 ) uniform vec2 u_OutputSize;
layout( location = 2 ) uniform int u_SourceLOD;
layout( location = 0 ) out vec3 color;
void main( void )
{
const vec2 c = gl_FragCoord.xy;
color = ( .25 * (
textureLod( u_InputTexture , ( c + vec2( .5 , .5 ) ) / u_OutputSize , u_SourceLOD )
+ textureLod( u_InputTexture , ( c + vec2(-.5 , .5 ) ) / u_OutputSize , u_SourceLOD )
+ textureLod( u_InputTexture , ( c + vec2( .5 ,-.5 ) ) / u_OutputSize , u_SourceLOD )
+ textureLod( u_InputTexture , ( c + vec2(-.5 ,-.5 ) ) / u_OutputSize , u_SourceLOD )
) ).rgb;
}