Javascript effect error

  • Hi, I'm currently trying to make a fast motion blur effect for my game

    Here is the fx's file code:

    //////////////////////////////////////////////////////////////////////////
    // Motion Blur effect
    varying mediump vec2 vTex;
    uniform mediump sampler2D samplerFront;
    uniform mediump float quality;
    uniform mediump float seconds;
    
    function scrUpdater() {
    		mediump vec4 front = texture2D(samplerFront, vTex);
            gl_FragColor = front + oldfront*quality/100 ;
        }
    
    void main(void)
    {
    	if (seconds == 0){
    		mediump vec4 front = texture2D(samplerFront, vTex);
            gl_FragColor = front;
    	}
    	else {
    		mediump vec4 oldfront = texture2D(samplerFront, vTex);
    		setTimeout(scrUpdater(), 10);
    	}
    }
    
    [/code:q701en8b]
    
    When I use it in Construct 2, I get this error:
    
    [img="http://image.noelshack.com/fichiers/2015/52/1450886713-javascript-error.png"]
    
    Can someone help me?
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Looks like you are mixing C and JavaScript. 'function' is not a valid keyword, and I don't think setTimeout() is a valid call.

  • What should I put in its place?

    I've seen many tutorials like this one: (add in http)://www.w3schools.com/js/js_functions.asp

    They all use 'function'.

    Also, for the setTimeout() call, it doesn"t give me any error, and I've seen it here:

    (add in http)://stackoverflow.com/questions/14226803/javascript-wait-5-seconds-before-executing-next-line

  • As far as I know effects use the 'OpenGL Shading Language' not Javascript. So javascript doesn't work here.

  • Asmodean Ah. Well that's a huge mistake I made!

    Thank you mate x)

    EDIT: Sooooo... I don't have a single chuking idea of how to translate this into OpenGL Shading Language. Can someone help me here?

  • Does the following Shader tutorial from gigatron help at all?

    https://www.scirra.com/tutorials/4900/shader-toy-to-c2

  • Mmh, I managed to get a motion blur to work, however this was absolutely not what I expected...

    I expected to get something like that: (https)://www.scirra.com/forum/request-directional-blur_t122854

    Or at least like that: (https)://youtu.be/Siud1xP8Veg

  • *moved to the more appropriate 'Effects' section

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