Problem withe shader script, lighting, help needed [SOLVED]

  • #1, by red363Friday, 29. July, 00:23 2 weeks ago
    Hello!

    I found some bug, and I can't solve it, I'm sure that the problem is with the script, because. There was already a similar story here:

    https://www.visionaire-studio.net/forum/thread/shadertoolkit...

    The essence of the problem is similar, only now it is connected with shader lighting.

    The essence of the problem: two light sources are placed in the scene. When you exit the game in the menu and after loading the autosave (continue the game) everything works. However, when completely exiting the game, and then restarting and loading autosave from the menu (continue game), these lights do not work.

    link to the scene with an example:
    https://1drv.ms/u/s!Anl4w4tP7uAPhOVnlUVkUrYADwsY7g?e=nNim6A

    I would be very grateful for any help, for me this is a very critical problem, because. lighting is used in most of the scenes and this is the main design element.

    Newbie

    71 Posts


  • #2, by afrlmeFriday, 29. July, 01:36 2 weeks ago
    Here you go. It's  just an edited version of your ved. I created a called by other action &  added the lighting code into an execute a script action part. I edited the at begin of scene action & replaced the execute a script with a call action to call the called by other action I just created. I then created a new script in the script section of the editor & added an hook function that listens out for successful save game load then calls the  called  by other action. Seems to be working for me.

    Imperator

    7158 Posts

  • #3, by red363Friday, 29. July, 05:35 2 weeks ago
    Here you go. It's  just an edited version of your ved. I created a called by other action &  added the lighting code into an execute a script action part. I edited the at begin of scene action & replaced the execute a script with a call action to call the called by other action I just created. I then created a new script in the script section of the editor & added an hook function that listens out for successful save game load then calls the  called  by other action. Seems to be working for me.
    Afrlme, thanks a lot for your help, but unfortunately it still doesn't work.
    As before, the problem occurs if you completely exit the game. And then run it (starts with a menu) and click continue the game (loading from the last autosave). Then the scene opens without light sources.

    You can see this by simply launching the game from the menu scene and then clicking on the continue game button

    Newbie

    71 Posts

  • #4, by red363Friday, 29. July, 06:16 2 weeks ago
    The project has different scenes, each with different lighting. And what's more, it changes depending on the conditions in the scene (for example, clicking on the switch turns on the light, clicking again turns it off), etc.

    Newbie

    71 Posts

  • #5, by SimonSFriday, 29. July, 08:07 2 weeks ago
    Remove the pause in the beginning of scene action, add a shaderDeactivateLighting() before shaderActivateLighting(3).

    Thread Captain

    1551 Posts

  • #6, by red363Friday, 29. July, 18:08 2 weeks ago
    Remove the pause in the beginning of scene action, add a shaderDeactivateLighting() before shaderActivateLighting(3).

    Unfortunately that didn't solve the problem roll

    Newbie

    71 Posts

  • #7, by red363Friday, 29. July, 18:11 2 weeks ago
    after restarting the game and loading an autosave from the menu
    shaderActivateLighting does not work in principle, even if you create a "switch" that works on click.

    Newbie

    71 Posts

  • #8, by SimonSFriday, 29. July, 21:00 2 weeks ago
    Alright, search for shaders_compiled = {} in the shadertoolkit, replace with:
    local shaders_compiled = {}

    Thread Captain

    1551 Posts

  • #9, by red363Friday, 29. July, 22:13 2 weeks ago
    Alright, search for shaders_compiled = {} in the shadertoolkit, replace with:
    local shaders_compiled = {}
    Wow! Thanks a lot Simon, everything seems to be working now
    (I breathed a sigh of relief).

    Newbie

    71 Posts

  • #10, by afrlmeFriday, 29. July, 22:19 2 weeks ago
    Interesting. So it was caching &/or not correctly updating the shader variables? Adding local made a new variable each loop which seems to  have solved the issue.

    Have you updated the shader toolkit script on your luadocs page with that edit @ Simon?

    Imperator

    7158 Posts

Write post