Help with ANSI Art effect

0 favourites
  • 1 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Is based in the ASCII FX by Gigatron , just i'm editing some variables and the Binary matrix chars to get as i want but there is somethng i can't achieve.

    I think i know where is the problem but after some edits still can't get fixed.

    Original code:

    gl_FragColor = vec4(cha*col,1.);[/code:2u8pxu1u]
    [img="https://cdn.pbrd.co/images/GU4f61p.png"]
    
    But for each character shows a color+black, and i want to get  Light color+Dark color, something like this:
    [code:2u8pxu1u]/gl_FragColor = vec4((cha+col)*col,1.);[/code:2u8pxu1u]
    [img="https://cdn.pbrd.co/images/GU4g4yV.png"]
    
    Now each character have two colors without black, but seems also changes the real black color of the entire image to light colors :S.
    
    How can i fix it?
    
    Here is the actual Shader code i'm using:
    
    [code:2u8pxu1u]// Directlyfrom shadertoy ..By FMS_CAT
    // Adapted by gigatron // have fun !
    
    // AnsiArt version by Matriax 
    
    precision highp float;
    
    uniform float textureSizeWidth; //width of the texture
    uniform float textureSizeHeight; //height of the texture
    uniform float texelSizeX; //width of one texel 
    uniform float texelSizeY; //height of one texel 
    uniform mediump float seconds;
    uniform mediump float pixelWidth;
    uniform mediump float pixelHeight;
    varying mediump vec2 vTex;
    uniform sampler2D samplerFront;
    vec2 iResolution = vec2( 1.0/pixelWidth, 1.0/pixelHeight);
    
    uniform float zoom;
    
    #define P(id,a,b,c,d,e,f,g,h) if( id == int(pos.y) ){ int pa = a+2*(b+2*(c+2*(d+2*(e+2*(f+2*(g+2*(h))))))); cha = floor(mod(float(pa)/pow(2.,float(pos.x)+0.0),2.0)); }
    
    float gray(vec3 _i)
    {
        return (_i.x+_i.y+_i.z)/3.;
    }
    
    void main()
    {
        vec2 uv = -vec2(floor(gl_FragCoord.x/8./zoom)*8.*zoom,floor(gl_FragCoord.y/12./zoom)*12.*zoom)/iResolution;
        ivec2 pos = ivec2(mod(gl_FragCoord.x/zoom,8.),mod(gl_FragCoord.y/zoom,12.));
        vec4 tex = texture2D(samplerFront,vTex);
        float cha = 0.;
        
        {
            float g = gray(tex.xyz);
            if( g < .05 )
            {
              P(11,0,0,0,0,0,0,0,0);
              P(10,0,0,0,0,0,0,0,0);
                P(9,0,0,0,0,0,0,0,0);
                P(8,0,0,0,0,0,0,0,0);
                P(7,0,0,0,0,0,0,0,0);
                P(6,0,0,0,0,0,0,0,0);
                P(5,0,0,0,0,0,0,0,0);
                P(4,0,0,0,0,0,0,0,0);
                P(3,0,0,0,0,0,0,0,0);
                P(2,0,0,0,0,0,0,0,0);
                P(1,0,0,0,0,0,0,0,0);
                P(0,0,0,0,0,0,0,0,0);
            }
            else if( g < .25 ) // .
            {
                
              P(11,0,0,1,0,0,0,1,0);
              P(10,1,0,0,0,1,0,0,0);
                P(9,0,0,1,0,0,0,1,0);
                P(8,1,0,0,0,1,0,0,0);
                P(7,0,0,1,0,0,0,1,0);
                P(6,1,0,0,0,1,0,0,0);
                P(5,0,0,1,0,0,0,1,0);
                P(4,1,0,0,0,1,0,0,0);
                P(3,0,0,1,0,0,0,1,0);
                P(2,1,0,0,0,1,0,0,0);
                P(1,0,0,1,0,0,0,1,0);
                P(0,1,0,0,0,1,0,0,0);
                
                
            }
            else if( g < .5 ) // ,
            {
            	/*
              P(11,1,0,1,0,1,0,1,0);
              P(10,0,1,0,1,0,1,0,1);
                P(9,1,0,1,0,1,0,1,0);
                P(8,0,1,0,1,0,1,0,1);
                P(7,1,0,1,0,1,0,1,0);
                P(6,0,1,0,1,0,1,0,1);
                P(5,1,0,1,0,1,0,1,0);
                P(4,0,1,0,1,0,1,0,1);
                P(3,1,0,1,0,1,0,1,0);
                P(2,0,1,0,1,0,1,0,1);
                P(1,1,0,1,0,1,0,1,0);
                P(0,0,1,0,1,0,1,0,1);
                */
              P(11,0,1,0,1,0,1,0,1);
              P(10,1,0,1,0,1,0,1,0);
                P(9,0,1,0,1,0,1,0,1);
                P(8,1,0,1,0,1,0,1,0);
                P(7,0,1,0,1,0,1,0,1);
                P(6,1,0,1,0,1,0,1,0);
                P(5,0,1,0,1,0,1,0,1);
                P(4,1,0,1,0,1,0,1,0);
                P(3,0,1,0,1,0,1,0,1);
                P(2,1,0,1,0,1,0,1,0);
                P(1,0,1,0,1,0,1,0,1);
                P(0,1,0,1,0,1,0,1,0);
                
                
                
            }
            else if( g < .75 ) // -
            {
              P(11,1,1,0,1,1,1,0,1);
              P(10,0,1,1,1,0,1,1,1);
                P(9,1,1,0,1,1,1,0,1);
                P(8,0,1,1,1,0,1,1,1);
                P(7,1,1,0,1,1,1,0,1);
                P(6,0,1,1,1,0,1,1,1);
                P(5,1,1,0,1,1,1,0,1);
                P(4,0,1,1,1,0,1,1,1);
                P(3,1,1,0,1,1,1,0,1);
                P(2,0,1,1,1,0,1,1,1);
                P(1,1,1,0,1,1,1,0,1);
                P(0,0,1,1,1,0,1,1,1);
            }
     
             else // 100
            {
              P(11,1,1,1,1,1,1,1,1);
              P(10,1,1,1,1,1,1,1,1);
                P(9,1,1,1,1,1,1,1,1);
                P(8,1,1,1,1,1,1,1,1);
                P(7,1,1,1,1,1,1,1,1);
                P(6,1,1,1,1,1,1,1,1);
                P(5,1,1,1,1,1,1,1,1);
                P(4,1,1,1,1,1,1,1,1);
                P(3,1,1,1,1,1,1,1,1);
                P(2,1,1,1,1,1,1,1,1);
                P(1,1,1,1,1,1,1,1,1);
                P(0,1,1,1,1,1,1,1,1);
            }
    	}
        
        //vec3 col = vec3(1.);
        vec3 col = tex.xyz/max(tex.x,max(tex.y,tex.z));
       // gl_FragColor = vec4(cha*col,1.);
        gl_FragColor = vec4((cha+col)*col,1.);
    
    }[/code:2u8pxu1u]
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)