Anyone checked out the new Shader stuff yet?

  • #10, by SDMonoSaturday, 09. August 2014, 20:07 10 years ago
    Yeah I was trying 0.1 and that's already very noticeable. So a gamma slider between -0.1 - 0.1 is enough I guess.

    Does your shaky cam move with the character?

    ps: Also like the 0 saturation... gotta love black&white!!! smile

    Forum Fan

    148 Posts


  • #11, by afrlmeSaturday, 09. August 2014, 20:24 10 years ago
    it's based on current position of game camera aka the current scroll position of the scene. But you could also have it kill the dynamic camera while character is walking or if game camera is moving to a new scroll position.

    I've not finished messing about yet. I'm still trying to find the right balance & best method.

    yeah 0.1 is noticeable. have you tried the contrast function? increase to add more depth to the colors on the screen. dark colors become darker/sharper etc.

    Imperator

    7278 Posts

  • #12, by ke4Saturday, 09. August 2014, 20:31 10 years ago
    Thanks razz

    Key Killer

    810 Posts

  • #13, by TraivlinTuesday, 12. August 2014, 23:40 10 years ago
    Hey, great script. I'm trying to learn how to write something similar to this myself.
    What is the startTween function part of? I can't find it in the script.

    Btw. for the reset values in the wiki:
    shaderLightness(1, 3000); doesn't reset the lightness, though
    shaderLightness(0, 3000) does.

    Newbie

    34 Posts

  • #14, by afrlmeWednesday, 13. August 2014, 00:10 10 years ago
    yeah cheers. I think I got confused with values because I copied the page from one of the other wiki pages & forgot to edit the values properly. - I often do that to save time on having to type everything out again.

    Corrected now. smile

    startTween is used to control & access the shader settings... I assume that code is internal in the engine source code.

    You can actually manipulate data structure objects with startTweenObject function.

    here's a few examples...
    -- 1. fade scene brightness (current scene) to 100% over 3s with easeLinearIn easing...
    startObjectTween(game:getLink(VGameCurrentScene), VSceneBrightness, game:getLink(VGameCurrentScene):getInt(VSceneBrightness), 100, 3000, easeLinearIn)
    
    -- 2. same as above but with direct link to scene & fade down to 25%...
    startObjectTween(getObject("Scenes[scn001_cell]"), VSceneBrightness, getObject("Scenes[scn001_cell]"):getInt(VSceneBrightness), 25, 3000, easeLinearOut)
    
    -- 3. smooth camera scrolling from current position to another...
    startObjectTween(game,VGameScrollPosition,game:getPoint(VGameScrollPosition),{x=100,y=0},3000,easeBackInOut)
    


    here's some example script SimonS wrote - I'm not 100% sure what it does but it applies some kind of overlay over the screen. You need to understand openGL ES 2.0 code to understand/write scripts like this though I think. I had a little look into it but I found it hard to find any simple examples/explanations to point me in the right direction.
    shader = {_temporary_=0, num = shaderCompile([[#ifdef GL_ES
    precision lowp float; 
    precision lowp int; 
    #endif
    varying vec2 texcoord; 
    uniform mat4 mvp_mat;
    attribute vec2 position; 
    attribute vec2 uv; 
    uniform int pass;
    void main () 
    { 
    gl_Position = mvp_mat * vec4(position.x,position.y,0.0,1.0); 
    texcoord = uv; 
    }]],[[#ifdef GL_ES
    precision highp float; 
    precision lowp  int; 
    #endif
    
    uniform sampler2D composite;
    uniform int pass;
    varying vec2 texcoord;
    
    void main() {
    vec2 m = vec2(0.5, 0.5);
    float d = distance(m, texcoord) * 1.0;
    vec3 c = texture2D(composite, texcoord).rgb * (1.0 - d * d);
    gl_FragColor = vec4(c.rgb, 1.0);
    }
    ]])}
    shaderSetOptions("active",shader.num)
    


    In regards to startTween(), have you actually looked over the shader toolkit script?

    Here's a few simple functions I added to the script SimonS wrote.
    
    -- * allows you to pan the camera left or right * --
    function shaderPan(offset, delay, easing, axis)
     if axis then startTween("shader_offsety", shader_offsety, offset, delay, easing) else startTween("shader_offsetx", shader_offsetx, offset, delay,easing) end
    end
    
    -- * allows you to zoom the camera in or out * --
    function shaderZoom(zoom, delay, easing)
     startTween("shader_scale", shader_scale, zoom, delay, easing)
    end
    
    -- * allows you to rotate the screen (w/ degree instead of pi) * --
    function shaderRotate(degree, delay, easing)
     degree = (degree / 360 * 2 * 3.14) -- convert degree to pi
     startTween("shader_rotate", shader_rotate, degree, delay, easing)
    end
    

    ...as you can see I am triggering the openGL functions via the startTween function which contains a command & the relevant data for manipulating the screen/camera/object.

    Imperator

    7278 Posts

  • #15, by TraivlinWednesday, 13. August 2014, 02:16 10 years ago
    Thanks for those examples.
    Guess I have a lot of work to do smile

    I've found something strange while testing the script.
    If you call shaderFollowCharacter(), you can only call
    shaderStopFollow()
    shaderViewport(1, 0, 0, 0, delay, easeQuintOut)
    if the delay you've used for shaderFollowCharacter is similar (greater or approx. delay-10) to that of shaderViewport, otherwise it will snap back to its new character zoom position.

    shaderFollowCharacter("", 2, 3000)
    3 sec pause
    shaderStopFollow()
    shaderViewport(1, 0, 0, 0, 3000, easeQuintOut)
    


    works.

    shaderFollowCharacter("", 2, 3000)
    3 sec pause
    shaderStopFollow()
    shaderViewport(1, 0, 0, 0, 2000, easeQuintOut)
    


    doesn't work.

    Don't know why - just noticed and letting you know smile

    Newbie

    34 Posts

  • #16, by afrlmeWednesday, 13. August 2014, 12:42 10 years ago
    Try adding a 1-10ms pause between stopFollow & viewport.

    Some of Simon's shader toolkit script needs a few rewrites here & there to improve certain things. He intends to work on it at some point. Some of the stuff like shaderColorize & shaderHue don't seem right to me. To me they should transition/fade between current hue/colorize value to target hue/colorize value & not cycle through all the other colors first. The only way to not get it to go through other colors first is to instantly snap from one hue to another by setting a delay of 0.

    Imperator

    7278 Posts

  • #17, by TraivlinWednesday, 13. August 2014, 14:36 10 years ago
    Try adding a 1-10ms pause between stopFollow & viewport.


    Hmm, that still doesn't work for me. I suppose you mean an actionpart pause?

    Newbie

    34 Posts

  • #18, by afrlmeWednesday, 13. August 2014, 15:31 10 years ago
    I assumed what you listed above in the code blocks meant you were executing them as execute a script action parts with an action part pause?

    creating pause/delay in lua script is not very easy as it requires loops & functions to check current time against initial time + delay value. Also you can't pause between lines unlike in the editor which allows you to pause between actions.

    The only method I can think of pausing between lines in lua would be to create each line as an entry in a table.

    ShaderFollowCharacter controls all of the openGL camera settings when activated, hence my thinking that adding a small pause after shaderStopFollow() should provide enough time for that function to be executed thus allowing you to use the shaderViewport function.

    Could you tell me exactly what is, or is not happening please? & is there anything listed in the log file? an error perhaps?

    Imperator

    7278 Posts

  • #19, by TraivlinWednesday, 13. August 2014, 17:12 10 years ago
    Yeah, that's what I thought about the pauses, just making sure you didn't mean some kind of lua pause.
    Nothing in messages.log.

    I'll just show you a video:

    https://www.youtube.com/watch?v=YXaGpjZollo

    You can read the text if you select 1080p from the cogwheel in the bottom right corner.

    Newbie

    34 Posts

  • #20, by afrlmeWednesday, 13. August 2014, 17:26 10 years ago
    hmm very strange... I'm not sure why it should work ok with 3000ms delay as opposed to 2000ms delay.

    One bit of advice I can offer though is in regards to the key input actions. You should use key (released) actions instead of the default key actions; scroll down the list to find the released section.

    The reason for this is because the default key presses act similar to rapid fire/turbo option on certain controllers, meaning that whatever actions are listed will repeatedly get executed over & over again until the key is released, whereas the released key will only execute the listed actions once you have released the key.

    Imperator

    7278 Posts