SHADER Toolkit. Discussions, examples and other cool stuff!

  • #30, by afrlmeSunday, 05. October 2014, 18:05 10 years ago
    First things first. You need to include the shader toolkit script as a definition script in your game to be able to use the shader functions or write your own.

    I have started writing example pages for each of the available functions @ here. Unfortunately I haven't gotten round to creating pages for each of the functions yet. I typed up more before the new wiki, but we lost some of the data for the wiki a little while ago & thus I have to redo those pages again. Also I will probably need Simon's help in typing up the pages to do with the lighting section of the shader as he will be able to explain what each lighting parameter is etc.

    P.S: I will be including a working .ved on the shader function pages. I've already created .ved's for a few of them. Check the resource section.

    Imperator

    7278 Posts


  • #31, by afrlmeSaturday, 25. October 2014, 01:07 10 years ago
    A'llo all,

    Well... I'm pretty happy with this .ved example of shaderGlow. Instructions are in the included readme.txt file.

    Don't forget to check out the shader function examples on the wiki script index page. I've included a working .ved example in most of the pages I've created so far; apart from one or two like shaderAddEffect because there are loads of effects to show but I've a fun idea for showcasing that one.

    Also quick note: the shader toolkit script has been uploaded the day, so please make sure you are using the correct one as shaderNoise has been fixed by SimonS & I modified the shaderGlow function so that you can now transition between glow/radius values over x amount of milliseconds.

    Regards,
    Lee.

    Imperator

    7278 Posts

  • #32, by unrealWednesday, 05. November 2014, 03:40 10 years ago
    I've been searching for a way to use the shaders only on one object of the scene but in the "GameShaderExclude" filters there is nothing except the interface, text, cursor, etc.

    Is it possible to use the shaders only on a object of the scene ?

    Thanks.

    Newbie

    66 Posts

  • #33, by SimonSWednesday, 05. November 2014, 11:37 10 years ago
    Yep, possible, but depends on the effect.

    Most of the additional effects can be used like this:

    local eff="ripple1"
    shaderAddEffect(eff)
    shaderRemoveEffect(eff)
    shader_effects[eff].num.strength=1
    bind(eff, "time", field("shader_iTime"))
    shaderSetOptions({{shader = shader_effects[eff].num(), comp_dst=5, comp_src=4 }}, 1)
    Objects.target_object.ShaderSet = 1
    


    Change the target_object to your objects name an ripple1 to the desired effect. Should create a nice ripple, good for some lake.

    The other effects require some rework to the script. Blur and glow are not possible with the current version, don't know if I do that in the future.

    Thread Captain

    1580 Posts

  • #34, by afrlmeWednesday, 05. November 2014, 12:28 10 years ago
    Simon could you please break down what you've written into clean syntax so we can understand what you have just written?

    I get the first, second & third lines. Not sure why you added both shaderAdd & shaderRemove effect though. Rest is a little unclear.

    @ Unreal: game.ShaderExclude is just for preventing the shader from affecting certain things like interfaces, the mouse cursor, displayed text etc.

    Let's say you applied shader lighting effects (spotlights) to various places of your scene which would automatically make certain parts of your scene dark, but without excluding certain things from the shader, the mouse cursor & text etc would also end up light/dark/tinted in certain parts of the scene, meaning you might not be able to see them properly.

    If Simon breaks down the syntax for applying shader effects to objects for me then I might create a function that simplifies it, when I get a bit of time.

    Imperator

    7278 Posts

  • #35, by SimonSWednesday, 05. November 2014, 12:39 10 years ago
    local eff="ripple1" -- effect name
    
    -- the following lines are to make sure the shader is compiled, 
    -- a shader is mini program, that needs to be compiled to use it
    
    shaderAddEffect(eff)
    shaderRemoveEffect(eff)
    
    -- this is a standard setting, the shader has a variable that is called strength, we set that to 1
    
    shader_effects[eff].num.strength=1
    
    -- also for any animation inside the shader, it needs the time, 
    -- so we bind the variable time in the shader to our time
    
    bind(eff, "time", field("shader_iTime"))
    
    --[[ that is tricky, it contains the settings for something we could call "effect channel", 
    like in an audio mixer, send to channel 1 or such. 
    So we say use the shader "eff" and composition method 5 and 4, list of methods here:
    
    0 GL_ZERO
    1 GL_ONE
    2 GL_SRC_COLOR
    3 GL_ONE_MINUS_SRC_COLOR
    4 GL_SRC_ALPHA
    5 GL_ONE_MINUS_SRC_ALPHA
    6 GL_DST_ALPHA
    7 GL_ONE_MINUS_DST_ALPHA
    8 GL_DST_COLOR
    9 GL_ONE_MINUS_DST_COLOR
    10 GL_SRC_ALPHA_SATURATE
    the comp dst means what of the destination goes into the equation
    and comp src the same for source. 
    So we use the alpha channel of the source image (GL_SRC_ALPHA) 
    and for the destination the inverse (GL_ONE_MINUS_SRC_ALPHA).
    Destination means our surface, source is the image we are drawing.
    If we use GL_ONE, GL_ONE you will see that image is like blended 
    onto the surface because the colors are added. 
    ]]
    
    shaderSetOptions({{shader = shader_effects[eff].num(), comp_dst=5, comp_src=4 }}, 1)
    
    -- simplest thing of them, set the object "target_object" to the effect channel 1
    
    Objects.target_object.ShaderSet = 1
    

    Thread Captain

    1580 Posts

  • #36, by afrlmeWednesday, 05. November 2014, 13:11 10 years ago
    OK I think I got it cheers. smile

    We can do this for most of the shader effects apart from blur & glow? Are we allowed to apply other effects such as saturation, lightness?

    I think blur & glow would be nice effects to add to individual scene objects/characters - well at some point. I'm sure someone would find uses for it. The current glow is a bit too general as it automatically affects certain parts of scenes, but I'm not sure what it uses to determine which parts.

    Imperator

    7278 Posts

  • #37, by SimonSWednesday, 05. November 2014, 13:24 10 years ago
    Some effects work, some do not. Problem is I have to rewrite big portions of the script to make these possible. Saturation, lightness and such have the problem, that they are applied at the end of the chain, so I would need at least 2 copies of the shader and also a possibility to control both seperately. Blur and glow are adding to the problem that these are multipass effects and I also need to be careful with bleeding on the edge... The glow is just copying the colors and filtering them so only the bright colors are left, then just a blur on that and add it to the screen.

    Thread Captain

    1580 Posts

  • #38, by afrlmeWednesday, 05. November 2014, 13:54 10 years ago
    I think the best approach might be to create the effects & shader stuff internally & just provide people with some parameters for each one. Like Construct2 for example, from what I've seen it comes with various shader functions in action parts that you can set options for & choose what to apply it to.

    It would be safer than letting people mess about with the shader code itself. Someone creates an effect with an action part then it gets added to a table which automatically gets deleted after x loops, time passed - if not set to infinite loop, or something.

    I'm not sure if that would mean more work for you or less, or be more or less complicated. I find the GSL code quite confusing for my short term memory brain. grin

    Imperator

    7278 Posts

  • #39, by MachtnixWednesday, 05. November 2014, 15:48 10 years ago
    Hi,

    I don't understand this discussion (it's too complicated in English). I don't know what I need and what not. What I realize is:
    This is a script to make shadows of 3D-persons from a free defined light source? Well?
    Question: Can I make a shadow of a character which has another shape than it's body?

    Machtnix

    Thread Captain

    1097 Posts

  • #40, by unrealWednesday, 05. November 2014, 16:43 10 years ago
    It did work ! Awesome ! Thank you SimonS ! smile

    Newbie

    66 Posts