Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <shader language="GLSL">
- <fragment><![CDATA[
- uniform sampler2D rubyTexture;
- uniform vec2 rubyInputSize;
- uniform vec2 rubyTextureSize;
- uniform vec2 rubyOutputSize;
- // #define TRIAD1
- // To see how the render is made, uncomment this
- // only 1/3 of the input pixel will be displayed for 1/3 of the lines
- // #define SHOW_HOW_ITS_DONE 3.0
- // To change the size of the spots 2.0 to 5.0 seems good
- #define SPOT_SIZE 3.0
- // To change the shape of the spots 1 = circle, 0.25 = ellipse with width = 2*height
- #define X_SIZE_ADJUST 0.4
- // To increase bloom / luminosity play with this parameter
- #define FACTOR_ADJUST 1.5
- float factor( float lumi, vec2 dxy)
- {
- float dist = sqrt( X_SIZE_ADJUST * dxy.x * dxy.x + dxy.y * dxy.y );
- return (2.0 + lumi ) * (1.0 - smoothstep( 0.0, SPOT_SIZE, dist ) ) / FACTOR_ADJUST ;
- }
- vec2 ar_correction = vec2( rubyOutputSize.x/rubyOutputSize.y * rubyInputSize.y/rubyInputSize.x,1.0 );
- vec2 arInputSize = rubyInputSize * ar_correction;
- vec2 arTextureSize = rubyTextureSize * ar_correction;
- vec4 luminosity_weights = vec4( 0.6, 0.3, 0.1, 0.0 );
- vec4 get_color( vec2 pos )
- {
- vec2 texture_coords = ( pos + vec2(0.5) ) / arTextureSize;
- vec4 color = texture2D(rubyTexture, texture_coords );
- #ifdef SHOW_HOW_ITS_DONE
- if ( mod(pos.x, SHOW_HOW_ITS_DONE ) != 0.0 )
- color.rgb = vec3(0.0);
- if ( mod(pos.y, SHOW_HOW_ITS_DONE ) != 0.0 )
- color.rgb = vec3(0.0);
- #endif
- return color;
- }
- void main(void) {
- vec2 coords_5x = floor( gl_TexCoord[0].xy * arTextureSize * 5.0 );
- vec2 coords_snes = floor( gl_TexCoord[0].xy * arTextureSize );
- vec2 ecart = coords_5x - ( vec2(5.0) * coords_snes + vec2(2.0) );
- vec4 color = vec4(0.0,0.0,0.0,1.0);
- float i,j;
- float n = 1.0;
- // If SPOT_SIZE is small enough, j=0 might be enough...
- // If SPOT_SIZE is too big, n = 2.0 or even 3.0 may be necessary... But not very realistic
- for( i = -n; i <= n; i+=1.0 )
- {
- for( j = -n; j <= n; j+=1.0 )
- {
- vec4 pcol = get_color( coords_snes + vec2(i,j) );
- float luminosity = dot( pcol, luminosity_weights );
- vec2 dxy = ecart - vec2( 5.0*i, 5.0*j );
- float distance = sqrt( dot(dxy, dxy) );
- #ifdef SHOW_HOW_ITS_DONE
- color += pcol * factor( luminosity, dxy ) ;
- #else
- color += pcol * factor( luminosity, dxy ) ;
- #endif
- }
- }
- #ifdef TRIAD1
- vec2 coords_screen = floor( gl_TexCoord[0].xy * rubyOutputSize );
- float modulo = mod( coords_screen.y + coords_screen.x , 3.0 );
- if ( modulo == 0.0 )
- color.rgb *= vec3(1.0,0.5,0.5);
- else if ( modulo <= 1.0 )
- color.rgb *= vec3(0.5,1.0,0.5);
- else
- color.rgb *= vec3(0.5,0.5,1.0);
- #endif
- gl_FragColor = clamp( color, 0.0, 1.0 );
- }
- ]]></fragment>
- </shader>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement