Shader question

  • Gigatron

    Thanks man I got an xBR shader semi-working with that tool. Very nice.

    Original shader:

    const float coef        = 2.0;
    const vec3  rgbw        = vec3(14.352, 28.176, 5.472);
    
    const   vec2 OGLSize    = vec2( 1024.0, 512.0);
    const   vec2 OGLInvSize = vec2( 0.0009765625, 0.001953125); 
    const   vec2 dx         = vec2( 0.0009765625, 0.0);
    const   vec2 dy         = vec2( 0.0, 0.001953125 );
    const   vec2 x2         = vec2( 0.001953125 , 0.0);
    const   vec2 y2         = vec2( 0.0 , 0.00390625 );
    const   vec4 xy         = vec4( 0.0009765625, 0.001953125,-0.0009765625,-0.001953125);  
    const   vec4 zw         = vec4( 0.001953125 , 0.001953125,-0.001953125 ,-0.00390625 );  
    const   vec4 wz         = vec4( 0.0009765625, 0.00390625 ,-0.0009765625,-0.00390625 );  
    
    vec4 df(vec4 A, vec4 B)
    {
        return abs(A-B);
    }
    
    vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h)
    {
        return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h));
    }
    
    uniform sampler2D OGL2Texture;
    
    void main()
    {
        vec4  edr, edr_left, edr_up; bvec4 px; // px = pixel, edr = edge detection rule
        vec4  interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up;
        bvec4 nc; // new_color
        vec4  fx, fx_left, fx_up; // inequations of straight lines.
        
        vec2 fp  = fract(gl_TexCoord[0].xy*OGLSize);
        vec2 TexCoord_0 = gl_TexCoord[0].xy-fp*OGLInvSize;
    
        vec3 A  = texture2D(OGL2Texture, TexCoord_0 + xy.zw ).xyz;
        vec3 B  = texture2D(OGL2Texture, TexCoord_0     -dy ).xyz;
        vec3 C  = texture2D(OGL2Texture, TexCoord_0 + xy.xw ).xyz;
        vec3 D  = texture2D(OGL2Texture, TexCoord_0 - dx    ).xyz;
        vec3 E  = texture2D(OGL2Texture, TexCoord_0         ).xyz;
        vec3 F  = texture2D(OGL2Texture, TexCoord_0 + dx    ).xyz;
        vec3 G  = texture2D(OGL2Texture, TexCoord_0 + xy.zy ).xyz;
        vec3 H  = texture2D(OGL2Texture, TexCoord_0     +dy ).xyz;
        vec3 I  = texture2D(OGL2Texture, TexCoord_0 + xy.xy ).xyz;
        vec3 A1 = texture2D(OGL2Texture, TexCoord_0 + wz.zw ).xyz;
        vec3 C1 = texture2D(OGL2Texture, TexCoord_0 + wz.xw ).xyz;
        vec3 A0 = texture2D(OGL2Texture, TexCoord_0 + zw.zw ).xyz;
        vec3 G0 = texture2D(OGL2Texture, TexCoord_0 + zw.zy ).xyz;
        vec3 C4 = texture2D(OGL2Texture, TexCoord_0 + zw.xw ).xyz;
        vec3 I4 = texture2D(OGL2Texture, TexCoord_0 + zw.xy ).xyz;
        vec3 G5 = texture2D(OGL2Texture, TexCoord_0 + wz.zy ).xyz;
        vec3 I5 = texture2D(OGL2Texture, TexCoord_0 + wz.xy ).xyz;
        vec3 B1 = texture2D(OGL2Texture, TexCoord_0 - y2    ).xyz;
        vec3 D0 = texture2D(OGL2Texture, TexCoord_0 - x2    ).xyz;
        vec3 H5 = texture2D(OGL2Texture, TexCoord_0 + y2    ).xyz;
        vec3 F4 = texture2D(OGL2Texture, TexCoord_0 + x2    ).xyz;
    
        vec4 b  = vec4(dot(B ,rgbw), dot(D ,rgbw), dot(H ,rgbw), dot(F ,rgbw));
        vec4 c  = vec4(dot(C ,rgbw), dot(A ,rgbw), dot(G ,rgbw), dot(I ,rgbw));
        vec4 d  = b.yzwx;
        vec4 e  = vec4(dot(E,rgbw));
        vec4 f  = b.wxyz;
        vec4 g  = c.zwxy;
        vec4 h  = b.zwxy;
        vec4 i  = c.wxyz;
        vec4 i4 = vec4(dot(I4,rgbw), dot(C1,rgbw), dot(A0,rgbw), dot(G5,rgbw));
        vec4 i5 = vec4(dot(I5,rgbw), dot(C4,rgbw), dot(A1,rgbw), dot(G0,rgbw));
        vec4 h5 = vec4(dot(H5,rgbw), dot(F4,rgbw), dot(B1,rgbw), dot(D0,rgbw));
        vec4 f4 = h5.yzwx;
        
        vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
        vec4 Bo = vec4( 1.0,  1.0, -1.0,-1.0 );
        vec4 Co = vec4( 1.5,  0.5, -0.5, 0.5 );
        vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
        vec4 Bx = vec4( 0.5,  2.0, -0.5,-2.0 );
        vec4 Cx = vec4( 1.0,  1.0, -0.5, 0.0 );
        vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
        vec4 By = vec4( 2.0,  0.5, -2.0,-0.5 );
        vec4 Cy = vec4( 2.0,  0.0, -1.0, 0.5 );
        
        // These inequations define the line below which interpolation occurs.
        fx      = vec4(greaterThan(Ao*fp.y+Bo*fp.x,Co));
        fx_left = vec4(greaterThan(Ax*fp.y+Bx*fp.x,Cx)); 
        fx_up   = vec4(greaterThan(Ay*fp.y+By*fp.x,Cy)); 
    
        interp_restriction_lv1      = vec4(notEqual(e,f))*vec4(notEqual(e,h));
        interp_restriction_lv2_left = vec4(notEqual(e,g))*vec4(notEqual(d,g));
        interp_restriction_lv2_up   = vec4(notEqual(e,c))*vec4(notEqual(b,c));
    
        edr      = vec4(lessThan(weighted_distance( e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)))*interp_restriction_lv1;
        edr_left = vec4(lessThanEqual(coef*df(f,g),df(h,c)))*interp_restriction_lv2_left; 
        edr_up   = vec4(greaterThanEqual(df(f,g),coef*df(h,c)))*interp_restriction_lv2_up;
        
        nc = bvec4 (edr*(max(max(fx, edr_left*fx_left), edr_up*fx_up)));
    
        px = lessThanEqual(df(e,f),df(e,h));
    
        vec3 res = nc.x ? px.x ? F : H : nc.y ? px.y ? B : F : nc.z ? px.z ? D : B : nc.w ? px.w ? H : D : E;    
        gl_FragColor.xyz = res;    
    }[/code:255nvcq0]
    
    Conversion (tinkered around to try and make it work properly):
    fx:
    [code:255nvcq0]#ifdef GL_ES
    precision mediump float;
    #endif
    
    uniform highp float WindowsWidth;
    uniform highp float WindowsHeight;
    
    uniform mediump sampler2D samplerFront;
    varying mediump vec2 vTex;
    uniform mediump float seconds;
    uniform mediump float date;
    uniform mediump float pixelWidth;
    uniform mediump float pixelHeight;
    vec2 iResolution = vec2( 1./pixelWidth, 1./pixelHeight);
    
    const float coef        = 2.0;
    const vec3  rgbw        = vec3(14.352, 28.176, 5.472);
    
    //const vec2 dx         = vec2( 0.0009765625, 0.0);
    //const vec2 dy         = vec2( 0.0, 0.001953125 );
    //const vec2 x2         = vec2( 0.001953125 , 0.0);
    //const vec2 y2         = vec2( 0.0 , 0.00390625 );
    //const vec4 xy         = vec4( 0.0009765625, 0.001953125,-0.0009765625,-0.001953125);  
    //const vec4 zw         = vec4( 0.001953125 , 0.001953125,-0.001953125 ,-0.00390625 );  
    //const vec4 wz         = vec4( 0.0009765625, 0.00390625 ,-0.0009765625,-0.00390625 );  
    
    vec4 df(vec4 A, vec4 B)
    {
        return abs(A-B);
    }
    
    vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h)
    {
        return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h));
    }
    
    void main()
    {
    //	float x = 0.5 * (1.0 / WindowsWidth);
    //	float y = 0.5 * (1.0 / WindowsHeight);
    
    	vec2 dx         = vec2( 0.0009765625, 0.0);//vec2(x, 0.0);//
    	vec2 dy         = vec2( 0.0, 0.001953125 );//vec2(0.0, y);//
    	vec2 x2         = vec2( 0.001953125 , 0.0);//vec2(y, 0);//
    	vec2 y2         = vec2(0.0, 0.00390625);//vec2( 0.0 , y*2.0 );//
    	vec4 xy         = vec4( 0.0009765625, 0.001953125,-0.0009765625,-0.001953125);//vec4( x, y,-x,-y);//  
    	vec4 zw         = vec4( 0.001953125 , 0.001953125,-0.001953125 ,-0.00390625 );//vec4( y , y,-y ,-(y*2.0) );//  
    	vec4 wz         = vec4( 0.0009765625, 0.00390625 ,-0.0009765625,-0.00390625 );  //vec4( x, y*2.0 ,-x,-(y*2.0) );//
    
        vec4  edr, edr_left, edr_up; bvec4 px; // px = pixel, edr = edge detection rule
        vec4  interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up;
        bvec4 nc; // new_color
        vec4  fx, fx_left, fx_up; // inequations of straight lines.
        
    	lowp float alpha = texture2D(samplerFront, vTex).a;
    
        vec2 fp  = fract(vTex.xy*vec2(WindowsWidth,WindowsHeight));
        vec2 TexCoord_0 = vTex.xy-fp*vec2(0.0009765625, 0.001953125);//vec2(x, y);
    
        vec3 A  = texture2D(samplerFront, TexCoord_0 + xy.zw ).xyz;
        vec3 B  = texture2D(samplerFront, TexCoord_0     -dy ).xyz;
        vec3 C  = texture2D(samplerFront, TexCoord_0 + xy.xw ).xyz;
        vec3 D  = texture2D(samplerFront, TexCoord_0 - dx    ).xyz;
        vec3 E  = texture2D(samplerFront, TexCoord_0         ).xyz;
        vec3 F  = texture2D(samplerFront, TexCoord_0 + dx    ).xyz;
        vec3 G  = texture2D(samplerFront, TexCoord_0 + xy.zy ).xyz;
        vec3 H  = texture2D(samplerFront, TexCoord_0     +dy ).xyz;
        vec3 I  = texture2D(samplerFront, TexCoord_0 + xy.xy ).xyz;
        vec3 A1 = texture2D(samplerFront, TexCoord_0 + wz.zw ).xyz;
        vec3 C1 = texture2D(samplerFront, TexCoord_0 + wz.xw ).xyz;
        vec3 A0 = texture2D(samplerFront, TexCoord_0 + zw.zw ).xyz;
        vec3 G0 = texture2D(samplerFront, TexCoord_0 + zw.zy ).xyz;
        vec3 C4 = texture2D(samplerFront, TexCoord_0 + zw.xw ).xyz;
        vec3 I4 = texture2D(samplerFront, TexCoord_0 + zw.xy ).xyz;
        vec3 G5 = texture2D(samplerFront, TexCoord_0 + wz.zy ).xyz;
        vec3 I5 = texture2D(samplerFront, TexCoord_0 + wz.xy ).xyz;
        vec3 B1 = texture2D(samplerFront, TexCoord_0 - y2    ).xyz;
        vec3 D0 = texture2D(samplerFront, TexCoord_0 - x2    ).xyz;
        vec3 H5 = texture2D(samplerFront, TexCoord_0 + y2    ).xyz;
        vec3 F4 = texture2D(samplerFront, TexCoord_0 + x2    ).xyz;
    
        vec4 b  = vec4(dot(B ,rgbw), dot(D ,rgbw), dot(H ,rgbw), dot(F ,rgbw));
        vec4 c  = vec4(dot(C ,rgbw), dot(A ,rgbw), dot(G ,rgbw), dot(I ,rgbw));
        vec4 d  = b.yzwx;
        vec4 e  = vec4(dot(E,rgbw));
        vec4 f  = b.wxyz;
        vec4 g  = c.zwxy;
        vec4 h  = b.zwxy;
        vec4 i  = c.wxyz;
        vec4 i4 = vec4(dot(I4,rgbw), dot(C1,rgbw), dot(A0,rgbw), dot(G5,rgbw));
        vec4 i5 = vec4(dot(I5,rgbw), dot(C4,rgbw), dot(A1,rgbw), dot(G0,rgbw));
        vec4 h5 = vec4(dot(H5,rgbw), dot(F4,rgbw), dot(B1,rgbw), dot(D0,rgbw));
        vec4 f4 = h5.yzwx;
        
        vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
        vec4 Bo = vec4( 1.0,  1.0, -1.0,-1.0 );
        vec4 Co = vec4( 1.5,  0.5, -0.5, 0.5 );
        vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
        vec4 Bx = vec4( 0.5,  2.0, -0.5,-2.0 );
        vec4 Cx = vec4( 1.0,  1.0, -0.5, 0.0 );
        vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
        vec4 By = vec4( 2.0,  0.5, -2.0,-0.5 );
        vec4 Cy = vec4( 2.0,  0.0, -1.0, 0.5 );
        vec4 Ci = vec4(0.25, 0.25, 0.25, 0.25);
        
        // These inequations define the line below which interpolation occurs.
        fx      = vec4(greaterThan(Ao*fp.y+Bo*fp.x,Co));
        fx_left = vec4(greaterThan(Ax*fp.y+Bx*fp.x,Cx)); 
        fx_up   = vec4(greaterThan(Ay*fp.y+By*fp.x,Cy)); 
    
        interp_restriction_lv1      = vec4(notEqual(e,f))*vec4(notEqual(e,h));
        interp_restriction_lv2_left = vec4(notEqual(e,g))*vec4(notEqual(d,g));
        interp_restriction_lv2_up   = vec4(notEqual(e,c))*vec4(notEqual(b,c));
    
        edr      = vec4(lessThan(weighted_distance( e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)))*interp_restriction_lv1;
        edr_left = vec4(lessThanEqual(coef*df(f,g),df(h,c)))*interp_restriction_lv2_left; 
        edr_up   = vec4(greaterThanEqual(df(f,g),coef*df(h,c)))*interp_restriction_lv2_up;
        
        nc = bvec4 (edr*(max(max(fx, edr_left*fx_left), edr_up*fx_up)));
    
        px = lessThanEqual(df(e,f),df(e,h));
    
        vec3 res = nc.x ? px.x ? F : H : nc.y ? px.y ? B : F : nc.z ? px.z ? D : B : nc.w ? px.w ? H : D : E;    
        gl_FragColor.xyz = res;    
    	gl_FragColor.a = alpha;
    }[/code:255nvcq0]
    xml:
    [code:255nvcq0]<?xml version="1.0" encoding="UTF-8" ?>
    <c2effect>
    	<!-- About -->
    	<id>XBR</id>			<!-- Never change the ID.  Change the name instead -->
    	<name>xBR</name>
    	<category>Advanced Effect Layout</category>
    	<description>Use this effect on individual sprites or the whole layout. Based on code by Hyllian and Anata</description>
    	<author>Hyllian</author>
    	
    	<!-- Settings -->
    	
    	<!-- Extend the bounding box for effect processing by a number of pixels to show the edges
    		 of effects which go beyond the object edges, e.g. blur and warp. -->
    	<extend-box-horizontal>10</extend-box-horizontal>
    	<extend-box-vertical>10</extend-box-vertical>
    	
    	<!-- Set to true if the background is sampled (samplerBack is referenced at all in the shader) -->
    	<blends-background>false</blends-background>
    	
    	<!-- Set to true if the background is not sampled at 1:1 with the foreground (e.g. the
    		 background texture co-ordinates are modified in some way by the shader, as done
    		 by Glass and Lens) -->
    	<cross-sampling>false</cross-sampling>
    	
    	<!-- Set to true if the effect changes over time, e.g. Noise or Warp effects. -->
    	<animated>false</animated>
    	
    	<!-- Parameters -->
    	<parameters>
    		<param>
    			<name>Width</name>
    			<description>Destination X</description>
    			<type>float</type>
    			<initial>0</initial>
    			<uniform>WindowsWidth</uniform>
    		</param>
    		<param>
    			<name>Height</name>
    			<description>Destination Y</description>
    			<type>float</type>
    			<initial>0</initial>
    			<uniform>WindowsHeight</uniform>
    		</param>
    	</parameters>
    </c2effect>[/code:255nvcq0]
    
    Use it on a layout and input the game target resolution in the Width and Height fields. So far it'll smooth along one angle but not the other. And no luck yet getting it to work properly on an object basis.
    
    EDIT:
    Posted the wrong shader, fixed now
  • Would you like to try this one ;

    <?xml version="1.0" encoding="UTF-8" ?>
    <c2effect>
       <!-- About -->
       <id>XBR</id>         <!-- Never change the ID.  Change the name instead -->
       <name>xBR</name>
       <category>Advanced Effect Layout</category>
       <description>Use this effect on individual sprites or the whole layout. Based on code by Hyllian and Anata</description>
       <author>Hyllian</author>
       
       <!-- Settings -->
       
       <!-- Extend the bounding box for effect processing by a number of pixels to show the edges
           of effects which go beyond the object edges, e.g. blur and warp. -->
       <extend-box-horizontal>10</extend-box-horizontal>
       <extend-box-vertical>10</extend-box-vertical>
       
       <!-- Set to true if the background is sampled (samplerBack is referenced at all in the shader) -->
       <blends-background>false</blends-background>
       
       <!-- Set to true if the background is not sampled at 1:1 with the foreground (e.g. the
           background texture co-ordinates are modified in some way by the shader, as done
           by Glass and Lens) -->
       <cross-sampling>false</cross-sampling>
       
       <!-- Set to true if the effect changes over time, e.g. Noise or Warp effects. -->
       <animated>false</animated>
       
       <!-- Parameters -->
       <parameters>
          <param>
             <name>Width</name>
             <description>Destination X</description>
             <type>float</type>
             <initial>0</initial>
             <uniform>WindowsWidth</uniform>
          </param>
          <param>
             <name>Height</name>
             <description>Destination Y</description>
             <type>float</type>
             <initial>0</initial>
             <uniform>WindowsHeight</uniform>
          </param>
    	  <param>
             <name>X Coef</name>
             <description>X Coef Multiplier</description>
             <type>percent</type>
             <initial>0.2</initial>
             <uniform>x_coef</uniform>
          </param>
    	    <param>
             <name>Y Coef</name>
             <description>Y Coef Multiplier</description>
             <type>percent</type>
             <initial>0.2</initial>
             <uniform>y_coef</uniform>
          </param>
    	  
    	  
       </parameters>
    </c2effect>[/code:1zrs66q1]
    
    [code:1zrs66q1]#ifdef GL_ES
    precision mediump float;
    #endif
    
    uniform mediump sampler2D samplerFront;
    varying mediump vec2 vTex;
    uniform mediump float seconds;
    uniform mediump float date;
    uniform mediump float pixelWidth;
    uniform mediump float pixelHeight;
    vec2 iResolution = vec2( 1./pixelWidth, 1./pixelHeight);
    
    uniform  float WindowsWidth;
    uniform  float WindowsHeight;
    uniform  float x_coef;
    uniform  float y_coef;
    
    const float  coef=2.0;
    const vec3  rgbw        = vec3(14.352, 28.176, 5.472);
    
    // const vec2 dx         = vec2( 0.0009765625, 0.0);
    // const vec2 dy         = vec2( 0.0, 0.001953125 );
    // const vec2 x2         = vec2( 0.001953125 , 0.0);
    // const vec2 y2         = vec2( 0.0 , 0.00390625 );
    // const vec4 xy         = vec4( 0.0009765625, 0.001953125,-0.0009765625,-0.001953125); 
    // const vec4 zw         = vec4( 0.001953125 , 0.001953125,-0.001953125 ,-0.00390625 ); 
    // const vec4 wz         = vec4( 0.0009765625, 0.00390625 ,-0.0009765625,-0.00390625 ); 
    
    vec4 df(vec4 A, vec4 B)
    {
        return abs(A-B);
    }
    
    vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h)
    {
        return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h));
    }
    
    void main()
    {
    //   float x = 0.5 * (1.0 / WindowsWidth);
    //   float y = 0.5 * (1.0 / WindowsHeight);
    
       vec2 dx         = vec2( 0.0009765625, 0.0);//vec2(x, 0.0);//
       vec2 dy         = vec2( 0.0, 0.001953125 );//vec2(0.0, y);//
       vec2 x2         = vec2( 0.001953125 , 0.0);//vec2(y, 0);//
       vec2 y2         = vec2(0.0, 0.00390625);//vec2( 0.0 , y*2.0 );//
       vec4 xy         = vec4( 0.0009765625, 0.001953125,-0.0009765625,-0.001953125);//vec4( x, y,-x,-y);// 
       vec4 zw         = vec4( 0.001953125 , 0.001953125,-0.001953125 ,-0.00390625 );//vec4( y , y,-y ,-(y*2.0) );// 
       vec4 wz         = vec4( 0.0009765625, 0.00390625 ,-0.0009765625,-0.00390625 );  //vec4( x, y*2.0 ,-x,-(y*2.0) );//
    
        vec4  edr, edr_left, edr_up; bvec4 px; // px = pixel, edr = edge detection rule
        vec4  interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up;
        bvec4 nc; // new_color
        vec4  fx, fx_left, fx_up; // inequations of straight lines.
       
        float alpha = texture2D(samplerFront, vTex).a;
    
        vec2 fp  = fract(vTex.xy*vec2(WindowsWidth,WindowsHeight));
        vec2 TexCoord_0 = vTex.xy-fp*vec2(0.0009765625*x_coef, 0.001953125*y_coef);//vec2(x, y);
    
        vec3 A  = texture2D(samplerFront, TexCoord_0 + xy.zw ).xyz;
        vec3 B  = texture2D(samplerFront, TexCoord_0     -dy ).xyz;
        vec3 C  = texture2D(samplerFront, TexCoord_0 + xy.xw ).xyz;
        vec3 D  = texture2D(samplerFront, TexCoord_0 - dx    ).xyz;
        vec3 E  = texture2D(samplerFront, TexCoord_0         ).xyz;
        vec3 F  = texture2D(samplerFront, TexCoord_0 + dx    ).xyz;
        vec3 G  = texture2D(samplerFront, TexCoord_0 + xy.zy ).xyz;
        vec3 H  = texture2D(samplerFront, TexCoord_0     +dy ).xyz;
        vec3 I  = texture2D(samplerFront, TexCoord_0 + xy.xy ).xyz;
        vec3 A1 = texture2D(samplerFront, TexCoord_0 + wz.zw ).xyz;
        vec3 C1 = texture2D(samplerFront, TexCoord_0 + wz.xw ).xyz;
        vec3 A0 = texture2D(samplerFront, TexCoord_0 + zw.zw ).xyz;
        vec3 G0 = texture2D(samplerFront, TexCoord_0 + zw.zy ).xyz;
        vec3 C4 = texture2D(samplerFront, TexCoord_0 + zw.xw ).xyz;
        vec3 I4 = texture2D(samplerFront, TexCoord_0 + zw.xy ).xyz;
        vec3 G5 = texture2D(samplerFront, TexCoord_0 + wz.zy ).xyz;
        vec3 I5 = texture2D(samplerFront, TexCoord_0 + wz.xy ).xyz;
        vec3 B1 = texture2D(samplerFront, TexCoord_0 - y2    ).xyz;
        vec3 D0 = texture2D(samplerFront, TexCoord_0 - x2    ).xyz;
        vec3 H5 = texture2D(samplerFront, TexCoord_0 + y2    ).xyz;
        vec3 F4 = texture2D(samplerFront, TexCoord_0 + x2    ).xyz;
    
        vec4 b  = vec4(dot(B ,rgbw), dot(D ,rgbw), dot(H ,rgbw), dot(F ,rgbw));
        vec4 c  = vec4(dot(C ,rgbw), dot(A ,rgbw), dot(G ,rgbw), dot(I ,rgbw));
        vec4 d  = b.yzwx;
        vec4 e  = vec4(dot(E,rgbw));
        vec4 f  = b.wxyz;
        vec4 g  = c.zwxy;
        vec4 h  = b.zwxy;
        vec4 i  = c.wxyz;
        vec4 i4 = vec4(dot(I4,rgbw), dot(C1,rgbw), dot(A0,rgbw), dot(G5,rgbw));
        vec4 i5 = vec4(dot(I5,rgbw), dot(C4,rgbw), dot(A1,rgbw), dot(G0,rgbw));
        vec4 h5 = vec4(dot(H5,rgbw), dot(F4,rgbw), dot(B1,rgbw), dot(D0,rgbw));
        vec4 f4 = h5.yzwx;
       
        vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
        vec4 Bo = vec4( 1.0,  1.0, -1.0,-1.0 );
        vec4 Co = vec4( 1.5,  0.5, -0.5, 0.5 );
        vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
        vec4 Bx = vec4( 0.5,  2.0, -0.5,-2.0 );
        vec4 Cx = vec4( 1.0,  1.0, -0.5, 0.0 );
        vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
        vec4 By = vec4( 2.0,  0.5, -2.0,-0.5 );
        vec4 Cy = vec4( 2.0,  0.0, -1.0, 0.5 );
        vec4 Ci = vec4(0.25, 0.25, 0.25, 0.25);
       
        // These inequations define the line below which interpolation occurs.
        fx      = vec4(greaterThan(Ao*fp.y+Bo*fp.x,Co));
        fx_left = vec4(greaterThan(Ax*fp.y+Bx*fp.x,Cx));
        fx_up   = vec4(greaterThan(Ay*fp.y+By*fp.x,Cy));
    
        interp_restriction_lv1      = vec4(notEqual(e,f))*vec4(notEqual(e,h));
        interp_restriction_lv2_left = vec4(notEqual(e,g))*vec4(notEqual(d,g));
        interp_restriction_lv2_up   = vec4(notEqual(e,c))*vec4(notEqual(b,c));
    
        edr      = vec4(lessThan(weighted_distance( e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)))*interp_restriction_lv1;
        edr_left = vec4(lessThanEqual(coef*df(f,g),df(h,c)))*interp_restriction_lv2_left;
        edr_up   = vec4(greaterThanEqual(df(f,g),coef*df(h,c)))*interp_restriction_lv2_up;
       
        nc = bvec4 (edr*(max(max(fx, edr_left*fx_left), edr_up*fx_up)));
    
        px = lessThanEqual(df(e,f),df(e,h));
    
        vec3 res = nc.x ? px.x ? F : H : nc.y ? px.y ? B : F : nc.z ? px.z ? D : B : nc.w ? px.w ? H : D : E;   
        gl_FragColor.xyz = res;   
       gl_FragColor.a = alpha;
    }[/code:1zrs66q1]
    
    Dont forget to follow variables in source try to understand what they do  ....
  • Gigatron

    Can't seem to see anything with your last example.

    Tried applying to both a sprite and a Layout, with numerous combinations of values for coef and width/height, but still nothing.

    Now I feel dumb again

  • Wow thanks! It works very nice here

    So I guess the new x_coef and y_coef are necessary for the shader to know what pixel rate to scale by?

    Now I just need to figure out how to get it to blend with the alpha channel as well, so far I just grabbed the original alpha and applied that I should see if I can update it to the newest xBR version too, this one's a bit old I think.

    zenox98:

    You have 'high quality' and 'point sampling' turned on? It should work if you apply the effect to either a layout, layer or object and input the original game res width and height. I just went with the default x_coef/y_coef. Also had to add a 'precision mediump float;' at the top to get it to compile but since you didn't get an error I guess you already took care of that.

  • ErekT

    Settings OK. No errors - just nothing.

    It could be my GTX 970.

    Gigatron had to amend some of his shaders before they would work on it previously, so it may be the same situation here.

  • ErekT, zenox98

    I have made a little example to add alpha intensity. For do this , add an uniform float variable like this :

    uniform  float alpha_coef;
    
    and modify last line of glsls file; to
     gl_FragColor.a = (alpha/1.0)-alpha_coef;
    
    [/code:aq63an7w]
    and .xml file add:
    [code:aq63an7w]
       <param>
             <name>Alpha Coef</name>
             <description>Alpha Coef Multiplier</description>
             <type>percent</type>
             <initial>0.01</initial>
             <uniform>alpha_coef</uniform>
          </param>
    
    [/code:aq63an7w]
    
    Finally  the result: [url=http://gigatron3k.free.fr/html5/C2/FX/alpha]http://gigatron3k.free.fr/html5/C2/FX/alpha[/url]
    
    Hope this will help //
  • You the man, thanks again

  • Ignore my previous posts about it not working.

    Re-visited today and it's working. Must be magic or something

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • still can't get it working :maybe i'm stupid

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)