demotool/shaders/combine.f.glsl

27 lines
694 B
Text
Raw Normal View History

#version 450 core
2017-10-04 18:06:39 +02:00
//! type fragment
layout( location = 0 ) uniform sampler2D u_MainInput;
layout( location = 1 ) uniform sampler2D u_BlurInput;
layout( location = 2 ) uniform vec2 u_OutputSize;
2017-09-30 19:41:45 +02:00
layout( location = 3 ) uniform vec2 u_Parameters;
layout( location = 0 ) out vec3 color;
void main( void )
{
vec2 tmp = gl_FragCoord.xy / u_OutputSize;
2017-09-30 19:41:45 +02:00
float f = u_Parameters.x;
color = textureLod( u_MainInput , tmp , 0 ).rgb;
2017-09-30 21:22:38 +02:00
vec3 bloom = vec3( 0 );
2017-09-30 21:27:50 +02:00
for ( int i = 0 ; i < 6 ; i ++ ) {
2017-09-30 21:22:38 +02:00
bloom += f * textureLod( u_BlurInput , tmp , i ).rgb;
f = pow( f , u_Parameters.y + 1 );
}
2017-09-30 21:22:38 +02:00
color = color + bloom / 2.2;
2017-09-30 19:41:45 +02:00
color = color / ( color + 1. );
2017-09-30 21:22:38 +02:00
color = pow( color , vec3( 1.0 / 2.2 ) );
}