Lamp Effect with ShaderToolKit

  • #1, by madeleine-vFriday, 10. June 2022, 22:56 2 years ago
    Hello, everyone. I'm trying to produce a lighting effect that appears around the main character, holding a small lamp. I've looked around the forum, but I'm unable to get any of the previously posted scripts to work. They either produce a black screen, or have the light zoom off into the upper right corner. Any help would be greatly appreciated. Thank you!

    Newbie

    11 Posts


  • #2, by madeleine-vWednesday, 15. June 2022, 23:09 2 years ago
    Here are two example pictures of what I'm talking about. The two threads with scripts that produced anything other than a black screen are here: 



    I was hoping for light to be a very integral part of my game, held by the PC, but I'm unable to use it currently, which is disappointing for the puzzles I wanted to create. Can anyone shed some light?

    Newbie

    11 Posts

  • #3, by SimonSThursday, 16. June 2022, 08:20 2 years ago
    The function point has been renamed to shaderPoint because it collides with internal functions:


    And then the fixed example:

    shaderActivateLighting(2)
    
    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.00001}, {0,0,0}, {1,1,1}, 1)
    
    bind("light1", "lights[0].position", shaderPoint(inverty(scrollfix(offset(field("game.CurrentCharacter.Position"),{0,-200}))), 1))
    bind("light1", "lights[0].targetpos", shaderPoint(inverty(cursor), 10))
    bind("light1", "lights[1].position", shaderPoint(inverty(scrollfix(offset(field("game.CurrentCharacter.Position"),{0,-200}))),
        factor(dist(scrollfix(offset(field("game.CurrentCharacter.Position"),{0,-200})), cursor), 10)))

    Thread Captain

    1580 Posts

  • #4, by madeleine-vThursday, 16. June 2022, 21:32 2 years ago
    Oh wow, that looks incredible. Thank you, Simon. Is there any way to have it more of a Halo effect around the character rather than directed at the cursor? I was going to create an animation for the PC holding a candlestick. 

    Newbie

    11 Posts

  • #5, by SimonSThursday, 16. June 2022, 22:06 2 years ago
    Try this:

    shaderActivateLighting(1)
    shaderLamp(0, 1, {100,50,1}, {0,0,1}, {0.4,0.0,0.000001}, {0,0,0}, {1,1,1}, 1)
    bind("light1", "lights[0].position", shaderPoint(
        inverty(scrollfix(offset(field("game.CurrentCharacter.Position"),{0,-200}))),
        function() return 80 + 10 * graphics.noise(6 * getTime() / 1000.0) end
       ))

    Thread Captain

    1580 Posts

  • #6, by madeleine-vThursday, 16. June 2022, 22:33 2 years ago
    That's perfect, thank you! grin

    A couple more questions, sorry I'm a noob. If I wanted to have another character be alight sort of using this effect, would that be possible? Even if they were to move? 
    If there's a stagnant object in the scene, would it be possible to also have them alight? 

    Newbie

    11 Posts

  • #7, by SimonSThursday, 16. June 2022, 23:18 2 years ago
    Just add more light with settings, change Char2 to your other character and Object1 to your object. There's a limit of 6 lights currently. Just set the count in the first call and add the 2 calls changing the first param and the lights[ ] index. Example:

    shaderActivateLighting(3)
    shaderLamp(0, 1, {100,50,1}, {0,0,1}, {0.4,0.0,0.000001}, {0,0,0}, {1,1,1}, 1)
    bind("light1", "lights[0].position", shaderPoint(
        inverty(scrollfix(offset(field("game.CurrentCharacter.Position"),{0,-200}))),
        function() return 80 + 10 * graphics.noise(6 * getTime() / 1000.0) end
       ))
    shaderLamp(1, 1, {100,50,1}, {0,0,1}, {0.4,0.0,0.000001}, {0,0,0}, {1,1,1}, 1)
    bind("light1", "lights[1].position", shaderPoint(
        inverty(scrollfix(offset(field("Characters.Char2.Position"),{0,-200}))),
        function() return 80 + 10 * graphics.noise(6 * getTime() / 1000.0) end
       ))
    shaderLamp(2, 1, {100,50,1}, {0,0,1}, {0.4,0.0,0.000001}, {0,0,0}, {1,1,1}, 1)
    bind("light1", "lights[2].position", shaderPoint(
        inverty(scrollfix(offset(field("Objects.Object1.Position"),{0,-200}))),
        function() return 80 + 10 * graphics.noise(6 * getTime() / 1000.0) end
       ))
    

    Thread Captain

    1580 Posts

  • #8, by madeleine-vFriday, 17. June 2022, 00:15 A year ago
    Thank you, Simon

    I will play around with these effects later. They make every seen look so full of life. Please take care

    Newbie

    11 Posts