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

  • #1, by red363Friday, 29. July 2022, 00:23 A year 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.

    Forum Fan

    101 Posts


  • #2, by afrlmeFriday, 29. July 2022, 01:36 A year 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

    7278 Posts

  • #3, by red363Friday, 29. July 2022, 05:35 A year 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

    Forum Fan

    101 Posts

  • #4, by red363Friday, 29. July 2022, 06:16 A year 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.

    Forum Fan

    101 Posts

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

    Thread Captain

    1580 Posts

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

    Unfortunately that didn't solve the problem roll

    Forum Fan

    101 Posts

  • #7, by red363Friday, 29. July 2022, 18:11 A year 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.

    Forum Fan

    101 Posts

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

    Thread Captain

    1580 Posts

  • #9, by red363Friday, 29. July 2022, 22:13 A year 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).

    Forum Fan

    101 Posts

  • #10, by afrlmeFriday, 29. July 2022, 22:19 A year 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

    7278 Posts