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

  • #1, z red363Friday, 29. July 2022, 00:23 hodinky 2 years 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.

    Fanoušek fóra

    101 Posts


  • #2, z afrlmeFriday, 29. July 2022, 01:36 hodinky 2 years 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.

    Imperátor

    7285 Posts

  • #3, z red363Friday, 29. July 2022, 05:35 hodinky 2 years 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

    Fanoušek fóra

    101 Posts

  • #4, z red363Friday, 29. July 2022, 06:16 hodinky 2 years 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.

    Fanoušek fóra

    101 Posts

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

    Kapitán

    1582 Posts

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

    Unfortunately that didn't solve the problem roll

    Fanoušek fóra

    101 Posts

  • #7, z red363Friday, 29. July 2022, 18:11 hodinky 2 years 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.

    Fanoušek fóra

    101 Posts

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

    Kapitán

    1582 Posts

  • #9, z red363Friday, 29. July 2022, 22:13 hodinky 2 years 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).

    Fanoušek fóra

    101 Posts

  • #10, z afrlmeFriday, 29. July 2022, 22:19 hodinky 2 years 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?

    Imperátor

    7285 Posts