SHADER Toolkit. Discussions, examples and other cool stuff!

  • #1, by PykeTuesday, 30. September 2014, 22:45 6 years ago
    I don't know if you guys have implemented the Shader Toolkit - but if you haven't I strongly urge you to give it a go!

    http://wiki.visionaire-tracker.net/wiki/Shader_(CMS)

    From the short while that I've played with it I can already see how incredible powerful it can be.

    I thought I would start this thread as a discussion about the Shaders where we can ask questions, and post examples of some of the stuff we have created with it.
    My recent focus has been on the lighting - specifically creating torches and other 'mood enhancing' features.

    Just some warning - the current script HAS caused some crashes on my side, so it isn't incredible stable. Just remember that when creating your shaders and working on your game!

    Newbie

    59 Posts


  • #2, by SimonSTuesday, 30. September 2014, 22:59 6 years ago
    I will add some more things in the future, I would really like to hear your thoughts about it. It's also possible to set a shader on an object, but I haven't completed that in the script.

    If you have a reproducible crash, would really like to see it. The function I use is not completely sanitized, so it can happen.

    Thread Captain

    1380 Posts

  • #3, by PykeTuesday, 30. September 2014, 23:02 6 years ago
    Hey Simon - seems the crash Im experiencing isn't to do with the shader toolkit at all. Im gonna Skype David with the dmp file now!

    Newbie

    59 Posts

  • #4, by PykeTuesday, 30. September 2014, 23:10 6 years ago
    Onto the actual Shader discussion!

    I love the Toolkit. I know pretty much next to nothing about setting up shaders, but I've been able to Frankenstein together some rather nice and workable effects.

    I managed to cannibalize your flashlight shader and created a flashlight, and a shader that just creates a light halo around the character.

    LIGHT HALO



    shaderActivateLighting(3)

    bind(shader_effects["light1"].num, "lights[2].position", point(inverty(scrollfix(offset(field("game.CurrentCharacter.Position"),{0,-80}))), 1))
    bind(shader_effects["light1"].num, "lights[3].position", point(inverty(scrollfix(offset(field("game.CurrentCharacter.Position"),{1000,1000}))),
    factor(dist(offset(field("game.CurrentCharacter.Position"),{0,2}), cursor), -500)))

    shaderLamp(2, 1, {100,500,1}, {20,900,10},{0.03,-0.00000001,0.0}, {0,0,0}, {1,1,1}, 1, 90, 1)
    shaderLamp(3, 1, {1000,500,1}, {0,0,1}, {5.01,0.0,0.000002}, {2,2,2}, {2,2,2}, 5, 90, 1)



    FLASHLIGHT



    shaderActivateLighting(2)

    bind(shader_effects["light1"].num, "lights[0].position", point(inverty(scrollfix(offset(field("game.CurrentCharacter.Position"),{0,-80}))), 1))
    bind(shader_effects["light1"].num, "lights[0].targetpos", point(inverty(cursor), 20))
    bind(shader_effects["light1"].num, "lights[1].position", point(inverty(scrollfix(offset(field("game.CurrentCharacter.Position"),{100,100}))),
    factor(dist(offset(field("game.CurrentCharacter.Position"),{0,10}), cursor), -500)))

    shaderLamp(0, 0, {900,500,1}, {0,900,10}, {0.001,0.000001,0}, {0,0,0}, {1,1,1}, 1, 90, 0)
    shaderLamp(1, 1, {1000,50,1}, {0,0,1}, {0.01,0.0,0.000001}, {2,2,2}, {2,2,2}, 5)



    YOUR ORIGINAL FLASHLIGHT SCRIPT



    shaderActivateLighting(4)

    bind(shader_effects["light1"].num, "lights[0].position", point(inverty(scrollfix(offset(field("game.CurrentCharacter.Position"),{0,-200}))), 1))
    bind(shader_effects["light1"].num, "lights[0].targetpos", point(inverty(cursor), 10))
    bind(shader_effects["light1"].num, "lights[1].position", point(inverty(scrollfix(offset(field("game.CurrentCharacter.Position"),{0,-200}))),
    factor(dist(offset(field("game.CurrentCharacter.Position"),{0,-200}), cursor), 10)))

    shaderLamp(0, 0, {900,500,1}, {0,900,10}, {0.001,0.000001,0}, {0,0,0}, {1,1,1}, 1, 90, 0)
    shaderLamp(1, 1, {1000,50,1}, {0,0,1}, {0.01,0.0,0.000001}, {1,1,1}, {0,0,0}, 1)
    shaderLamp(2, 1, {1500,50,1}, {0,0,1}, {0.01,0,0.000001}, {0,0,0}, {0,1,0}, 1)
    shaderLamp(3, 0, {1300,900,1}, {0,400,10}, {0.001,0.000001,0}, {0,0,0}, fromHSV(1,1,1), 1, 90, 0)

    Newbie

    59 Posts

  • #5, by PykeTuesday, 30. September 2014, 23:12 6 years ago
    I would love to know how to create a sort of flickering light - like lightning, or a globe that's burst.

    I'm going to delve into the effects in the next few days, specifically the Television ones, and try to recreate a Chromatic Aberration effect (very 80's....)

    Newbie

    59 Posts

  • #6, by SimonSTuesday, 30. September 2014, 23:33 6 years ago
    You could try this:
    prev_random = 0
    function softRandom()
    prev_random = math.random() * 0.2 + prev_random * 0.8
    return prev_random
    end

    bind(shader_effects["light1"].num, "lights[2].position", point(inverty(scrollfix(offset(field("game.CurrentCharacter.Position"),{0,-80}))), function() return softRandom()*4 + 1 end))
    1
    2
    3
    4
    5
    6
    7
    8

    I've soften the random, cause it was just too hard to the eye. Now it's more like a candle.

    btw. if you enable 3 lights then the last light has the id 2. So the light halo is not completely correct or optimized.

    Thread Captain

    1380 Posts

  • #7, by afrlmeTuesday, 30. September 2014, 23:40 6 years ago
    Very nice, I'll have a look at these the morrow smile

    @ Simon: I take it that bind is essentially a loop continues to make sure the light is placed in the correct position etc?

    Imperator

    6846 Posts

  • #8, by SimonSTuesday, 30. September 2014, 23:43 6 years ago
    It's a shorthand for a loop that sends the values to the shader every frame, because these values update over time.

    Thread Captain

    1380 Posts

  • #9, by afrlmeTuesday, 30. September 2014, 23:51 6 years ago
    I figured as much. I knew something had to be updating the position of your flashlight example. I haven't gotten around to going over the examples yet to see what is doing what. smile

    If he wants to create a slower reaction then it might be an idea to include a loop in the editor with a pause value & the jump to x action part to adjust exactly when it should change to a new value. It's actually kind of fun if you generate random pause values by combining a random editor value & linking it to the pause action part. I've used that method to create dynamic lighting before & it works quite well.

    Imperator

    6846 Posts

  • #10, by PykeWednesday, 01. October 2014, 00:47 6 years ago
    How would I create a general ambient colour in a room? Still wanting to keep the other effects, but having the room lit by 2 or 3 subtle light sources?

    That Flicker script works well for turning the torch on and off. It gives it a nice bit of polish!

    Newbie

    59 Posts

  • #11, by DilatedWednesday, 01. October 2014, 08:35 6 years ago
    Ohhhhh this sounds great, going to try it when I get back to my home set up grin

    Forum Fan

    149 Posts

Write post