Gigatron's Recent Forum Activity

  • Ok i will convert this online here

    Look and compare changed source from the original;

    1 - i must have an .xml file first ; eg : glitch.xml contains uniform variables to communicate between C2 and glsl main code here ;

    2 - glitch.xml and glitch.fx ;

    // Global header for all C2 FX i use ;
    
    #ifdef GL_ES
    precision mediump float;
    #endif
    
    uniform mediump sampler2D samplerBack;
    uniform mediump sampler2D samplerFront;
    varying mediump vec2 vTex;
    uniform mediump vec2 destStart;
    uniform mediump vec2 destEnd;
    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 xx;   /// USED in place of iMouse.x    .. to communicate with shader variable so
                                    // include  xx to .xml file with float  
    
    // No change here 
    
    float sat( float t ) {
       return clamp( t, 0.0, 1.0 );
    }
    
    vec2 sat( vec2 t ) {
       return clamp( t, 0.0, 1.0 );
    }
    
    //remaps inteval [a;b] to [0;1]
    float remap  ( float t, float a, float b ) {
       return sat( (t - a) / (b - a) );
    }
    
    //note: /\ t=[0;0.5;1], y=[0;1;0]
    float linterp( float t ) {
       return sat( 1.0 - abs( 2.0*t - 1.0 ) );
    }
    
    vec3 spectrum_offset( float t ) {
       vec3 ret;
       float lo = step(t,0.5);
       float hi = 1.0-lo;
       float w = linterp( remap( t, 1.0/6.0, 5.0/6.0 ) );
       float neg_w = 1.0-w;
       ret = vec3(lo,1.0,hi) * vec3(neg_w, w, neg_w);
       return pow( ret, vec3(1.0/2.2) );
    }
    
    //note: [0;1]
    float rand( vec2 n ) {
      return fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453);
    }
    
    //note: [-1;1]
    float srand( vec2 n ) {
       return rand(n) * 2.0 - 1.0;
    }
    
    float trunc( float x, float num_levels )
    {
       return floor(x*num_levels) / num_levels;
    }
    vec2 trunc( vec2 x, float num_levels )
    {
       return floor(x*num_levels) / num_levels;
    }
    
    // Main loop  fx running here at 60 fps 
    
    /// let's adapt to c2 
    
    void main()      /// changed
    {
       vec2 uv = vTex;    ///    change from :  fragCoord.xy / iResolution.xy;  
                                     ///   vTex is the sprite area we used to assign FX .
        uv.y = 1.0 - uv.y; ///  Flip  Y if texture is inversed .....  comment this if so
       
       float time = mod(seconds, 32.0); // + modelmat[0].x + modelmat[0].z;  //// Change iGlobalTime to seconds
    
       float GLITCH = 0.1 + xx / iResolution.x;   /// iMouse not exist but assign a variable like uniform float xx 
                                                                              ///  and replace iMouse
       
       float gnm = sat( GLITCH );
       float rnd0 = rand( trunc( vec2(time, time), 6.0 ) );
       float r0 = sat((1.0-gnm)*0.7 + rnd0);
       float rnd1 = rand( vec2(trunc( uv.x, 10.0*r0 ), time) ); //horz
       //float r1 = 1.0f - sat( (1.0f-gnm)*0.5f + rnd1 );
       float r1 = 0.5 - 0.5 * gnm + rnd1;
       r1 = 1.0 - max( 0.0, ((r1<1.0) ? r1 : 0.9999999) ); //note: weird ass bug on old drivers
       float rnd2 = rand( vec2(trunc( uv.y, 40.0*r1 ), time) ); //vert
       float r2 = sat( rnd2 );
    
       float rnd3 = rand( vec2(trunc( uv.y, 10.0*r0 ), time) );
       float r3 = (1.0-sat(rnd3+0.8)) - 0.1;
    
       float pxrnd = rand( uv + time );
    
       float ofs = 0.05 * r2 * GLITCH * ( rnd0 > 0.5 ? 1.0 : -1.0 );
       ofs += 0.5 * pxrnd * ofs;
    
       uv.y += 0.1 * r3 * GLITCH;
    
        const int NUM_SAMPLES = 10;
        const float RCP_NUM_SAMPLES_F = 1.0 / float(NUM_SAMPLES);
       
       vec4 sum = vec4(0.0);
       vec3 wsum = vec3(0.0);
       for( int i=0; i<NUM_SAMPLES; ++i )
       {
          float t = float(i) * RCP_NUM_SAMPLES_F;
          uv.x = sat( uv.x + ofs * t );
          vec4 samplecol = texture2D( samplerFront, uv, -10.0 );    /// iChannel0 not exist assign to samplerFront 
          vec3 s = spectrum_offset( t );
          samplecol.rgb = samplecol.rgb * s;
          sum += samplecol;
          wsum += s;
       }
       sum.rgb /= wsum;
       sum.a *= RCP_NUM_SAMPLES_F;
    
       gl_FragColor.a = sum.a;                                    /// replace fragColor with gl_FragColor.a
       gl_FragColor.rgb = sum.rgb; // * outcol0.a;   // replace this one too
    }[/code:3kduj4ay]
  • Irbis

    Select a shader , and i will try to explain step by step to Convert that to C2 ..

    Regards

  • JayTholen

    I think it's ok now the latest file i ve sent ;

  • [quote:31ncov9u]I've played a bit with Chris's 2nd version and somehow made that one work hehe ^^

    But holy cow - working with C2 shaders is no fun

    At least I've learned how to modify any shader to enable/add more options

    Be sure it's really easy ... after long time study

    For online test use shadertoy if it's ok .. convert it to C2 ... etc

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well... the distortion sure does work Gigatron

    Compare how the texture looks and how it looks after shader.

    Everything is a bit oversaturated and overexposed (too white/bright).

    Why is that? And can you get rid of it? I've noticed its visible on your "mars" example too.

    The texture is dark and detailed when the sphere version is bright as sun

    It's not hard to correct this , unfortunately i ve done many change on this shader ...So

    can you PM me the shader you use ? i will modify this one ...

    Thanks

  • After search in my shader collection no need to pay ... square dot is the way i think ;

    http://gigatron3k.free.fr/html5/C2/FX/squaredot/

  • >

    > Also not sure if you noticed my amendment to my last post, any thoughts on how to do the page curl if the sprite object was just clicked on ?

    >

    You must convert or i must convert mouse position to vector or normalize this position to -1.0 to 1. 0.

    And then you can change fx prameters with this converted values...

  • Sorry here are the missing fx in one file;

    http://gigatron3k.free.fr/html5/C2/FX/fxfiles.rar

  • timcs

    All fx of C2 must be in effects drawer.... this mean you need 2 file inside... for example; effect.fx and effect.xml

    to use page fx ; open new project .. insert sprite object .. load picture into this sprite

    so select the page fx for this sprite; then you can manipulate fx variables on the left... with mouse object on your project.

    every thick parameter 0 to mouse.x/100.0 or something ....

    Good luck

    Ps: i have mailed the guy to port this : http://gigatron3k.free.fr/html5/C2/FX/pagecss/

    but not received answer... i can't make plugin yet.. cause it's shareware...

  • timcs

    All fx of C2 must be in effects drawer.... this mean you need 2 file inside... for example; effect.fx and effect.xml

    to use page fx ; open new project .. insert sprite object .. load picture into this sprite

    so select the page fx for this sprite; then you can manipulate fx variables on the left... with mouse object on your project.

    every thick parameter 0 to mouse.x/100.0 or something ....

    Good luck

  • Hi all, and happy new year ..

    I am now really busy... but some nice fx will out soon.. i will before finish my

    todo list ... remain 20;

    I have quickly done a new demo for your pleasure..

    http://gigatron3k.free.fr/html5/C2/FX/goahead/

    See you soon ;

Gigatron's avatar

Gigatron

Member since 8 Jan, 2012

Twitter
Gigatron has 33 followers

Connect with Gigatron

Trophy Case

  • 12-Year Club
  • x2
    Popular Game One of your games has over 1,000 players
  • Famous Game One of your games has over 10,000 players
  • x3
    Coach One of your tutorials has over 1,000 readers
  • Email Verified

Progress

16/44
How to earn trophies