Page 1 of 1
Silhouette Shader
Posted: Sat Jul 27, 2019 7:07 pm
by Emral
Never recolour your stuff again.
CAVEAT: THIS REQUIRES THERE TO BE NO SHARED COLOURS BETWEEN THE MASKED FOREGROUND AREA AND ANYTHING BEHIND IT.
A download link can be found here:
https://drive.google.com/file/d/1KyXbzE ... sp=sharing
Demo:
https://www.youtube.com/watch?v=3yZSJNPa7u8
2:10
To use this library, load the sh_silhouette.lua file in your luna.lua file. Make sure the other file is also in an accessible directory.
Modifications and adaptations of the code is permitted. If you use this particular code as a basis for an enhanced version of these NPCs, please give credit.
Customizable stuff:
sh_silhouette.speed: I forgot to take this out please ignore it lol
sh_silhouette.lowpriority: Highest priority of background area.
sh_silhouette.priority: Highest priority of masked area (goes until lowpriority).
sh_silhouette.color: Color of the mask. Can be changed at runtime (to produce the thunder effect in the video, for example).
Re: Silhouette Shader
Posted: Sat May 16, 2020 6:37 am
by cato
Eventu is depreciated and the routine class is kinda hard to use. How would I replace eventu functions with routine?
Besides, is there any way to reverse the effects, such that the screen only turns black during the thunder, then turns back normal afterwards?
Re: Silhouette Shader
Posted: Sat May 16, 2020 6:43 am
by Emral
cato wrote: ↑Sat May 16, 2020 6:37 am
Eventu is depreciated and the routine class is kinda hard to use. How would I replace eventu functions with routine?
Besides, is there any way to reverse the effects, such that the screen only turns black during the thunder, then turns back normal afterwards?
Hard to use? You should be fine by just replacing all instances of eventu with Routine, and then no longer loading eventu. It's baaaasically the same as eventu in terms of usage.
As for reversing the effect of the demo, you need to modify the alpha value of sh_silhouette.color in the opposite way of the demo.
Re: Silhouette Shader
Posted: Sat May 16, 2020 10:08 am
by cato
Enjl wrote: ↑Sat May 16, 2020 6:43 am
Hard to use? You should be fine by just replacing all instances of eventu with Routine, and then no longer loading eventu. It's baaaasically the same as eventu in terms of usage.
As for reversing the effect of the demo, you need to modify the alpha value of sh_silhouette.color in the opposite way of the demo.
Thank you so much. I just replaced every eventu with routine and its sub-functions still works.
Also, I got it to work by making the a = 1 and reducing the colour by 0.01.
Re: Silhouette Shader
Posted: Sat May 16, 2020 11:20 am
by Emral
Nice! Good to hear you got it to work.
Re: Silhouette Shader
Posted: Tue May 19, 2020 6:23 am
by cato
Now, I found another problem. For whatever reasons, SMBX keeps shutting down without crash files/logs/reports.
After several tests, I would assume it has to do with frame freezes. When the player gets a power-up, the frames would freeze, and somehow causes Routine.waitframe to mess up, the same thing with the player taking damage and entering warps.
For alternatives, I may need to disable powerups for the sections that require Routine.waitframe, and use instant teleport warps instead of pipe warps. But, is there a way to fix this?
Re: Silhouette Shader
Posted: Tue May 19, 2020 8:00 am
by Hoeloe
I think whatever issue you're experiencing is not what you think it is. It might help to share some code.
Re: Silhouette Shader
Posted: Tue May 19, 2020 8:19 am
by cato
Code: Select all
local sh_silhouette = require("sh_silhouette")
function onStart()
lightning = Layer.get("Lightning") --load the layer
sh_silhouette.color.a = 0 --reset color
end
function onTick()
if lunatime.tick() % 640 == 65 then
Routine.run(thunder)
end
end
function thunder()
lightning:show(true)
SFX.play(43)
sh_silhouette.color.a = 1
Routine.waitFrames(65)
for i=1, 100 do
sh_silhouette.color.a = sh_silhouette.color.a - 0.01
Routine.waitFrames(1)
end
lightning:hide(true)
end
Should be the exact same thing as the code in the video but used Routine instead of Eventu.
Note that the level runs completely fine without getting a power-up.
Edit: After resetting configuration, it did work fine.
Edit2: And it didn't work again.
Re: Silhouette Shader
Posted: Tue May 19, 2020 7:53 pm
by TheGameyFireBro105
how do i load it?
Re: Silhouette Shader
Posted: Wed May 20, 2020 1:02 am
by Emral
The first line in the code directly above the post you made.
Re: Silhouette Shader
Posted: Wed May 20, 2020 3:09 am
by cato
cato wrote: ↑Tue May 19, 2020 8:19 am
Should be the exact same thing as the code in the video but used Routine instead of Eventu.
Note that the level runs completely fine without getting a power-up.
Edit: After resetting configuration, it did work fine.
Edit2: And it didn't work again.
Here is the log files content in PGE editor. They have the same content. Maybe related to the crashes.
Code: Select all
Warning: (:0, ): libpng warning: iCCP: known incorrect sRGB profile
Warning: (:0, ): libpng warning: iCCP: cHRM chunk does not match sRGB
Warning: (:0, ): libpng warning: iCCP: known incorrect sRGB profile
Warning: (:0, ): libpng warning: iCCP: cHRM chunk does not match sRGB
Warning: (:0, ): libpng warning: IDAT: Extra compressed data
Warning: Error of the script :
Uncaught exception at line 10:
SyntaxError: Unexpected token `?'
Warning: Error while loading main.js in test-plugin-with-error, skipping...
Warning: (:0, ): libpng warning: iCCP: known incorrect sRGB profile
Warning: (:0, ): libpng warning: iCCP: cHRM chunk does not match sRGB
Come to think of it, it shouldn't be the Routine problem. I disabled the function and it still crashes.
I may see if it was the npc lightning problem ( the vines used in ToB3 ). It should be lua problem as the level has no problem with the script emptied.
Re: Silhouette Shader
Posted: Wed May 20, 2020 3:43 am
by Emral
The logs in the editor would be completely useless in this case. The editor has no bearing on the game. The game saves its own logs into data/logs.
Re: Silhouette Shader
Posted: Wed May 20, 2020 3:55 am
by cato
Enjl wrote: ↑Wed May 20, 2020 3:43 am
The logs in the editor would be completely useless in this case. The editor has no bearing on the game. The game saves its own logs into data/logs.
Then I have no idea what went wrong. The game tester closes without producing the logs.
Re: Silhouette Shader
Posted: Wed May 20, 2020 3:57 am
by Emral
cato wrote: ↑Wed May 20, 2020 3:55 am
Enjl wrote: ↑Wed May 20, 2020 3:43 am
The logs in the editor would be completely useless in this case. The editor has no bearing on the game. The game saves its own logs into data/logs.
Then I have no idea what went wrong. The game tester closes without producing the logs.
My scripts are fairly lightweight, so I struggle with thinking of what the issue may be as well. What are your computer specs like? Do you have trouble with any other shaders?
Re: Silhouette Shader
Posted: Wed May 20, 2020 4:29 am
by cato
Enjl wrote: ↑Wed May 20, 2020 3:57 am
My scripts are fairly lightweight, so I struggle with thinking of what the issue may be as well. What are your computer specs like? Do you have trouble with any other shaders?
Device: LEGION Y740-171RHg
Processor: Intel(R) Core(TM) i7-9750H CPU@ 2.60GHz 2.59GHz
RAM: 32.0GB
System x64 OS and Processor
Windows 10
Getting the powerup while having the lightning NPC will force the engine to close.
And I have never used any other shaders before.
Re: Silhouette Shader
Posted: Thu Jul 21, 2022 8:34 pm
by KurttheKing
How come I need WinZip to open it?
Re: Silhouette Shader
Posted: Fri Jul 22, 2022 5:35 am
by ShadowXeldron
KurttheKing98YT wrote: ↑Thu Jul 21, 2022 8:34 pm
How come I need WinZip to open it?
You don't. You should use
7-Zip instead. Unlike WinZip, its free and probably has better performance.
Re: Silhouette Shader
Posted: Fri Jul 22, 2022 8:03 am
by KurttheKing
Dragon0307 wrote: ↑Fri Jul 22, 2022 5:35 am
KurttheKing98YT wrote: ↑Thu Jul 21, 2022 8:34 pm
How come I need WinZip to open it?
You don't. You should use
7-Zip instead. Unlike WinZip, its free and probably has better performance.
OK, thanks!
Re: Silhouette Shader
Posted: Fri Jul 22, 2022 4:09 pm
by deice
Dragon0307 wrote:
You don't. You should use
7-Zip instead. Unlike WinZip, its free and probably has better performance.
just for the record, i believe winzip does create and decompress
zip archives faster because deflate is faster than lzma (but has a worse compression ratio; and even so this speed difference is only noticeable with very large files). 7-zip has it beat in just about every other possible category.
in any case since this is a 7z archive that concern too is irrelevant (though i would say it's better to upload scripts in the "zip" format because windows users who make up the primary userbase of smbx2 can open those without installing any additional software, especially since the files are as small as they are).