Silhouette Shader

Share and discuss custom LunaLua code and content packs for SMBX2.

Moderator: Userbase Moderators

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9890
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Silhouette Shader

Postby Emral » Sat Jul 27, 2019 7:07 pm

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).

cato
Volcano Lotus
Volcano Lotus
Posts: 564
Joined: Thu Aug 24, 2017 3:06 am
Flair: Koishi enjoyer
Contact:

Re: Silhouette Shader

Postby cato » 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?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9890
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Silhouette Shader

Postby Emral » Sat May 16, 2020 6:43 am

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.

cato
Volcano Lotus
Volcano Lotus
Posts: 564
Joined: Thu Aug 24, 2017 3:06 am
Flair: Koishi enjoyer
Contact:

Re: Silhouette Shader

Postby cato » Sat May 16, 2020 10:08 am

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.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9890
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Silhouette Shader

Postby Emral » Sat May 16, 2020 11:20 am

Nice! Good to hear you got it to work.

cato
Volcano Lotus
Volcano Lotus
Posts: 564
Joined: Thu Aug 24, 2017 3:06 am
Flair: Koishi enjoyer
Contact:

Re: Silhouette Shader

Postby cato » Tue May 19, 2020 6:23 am

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?

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Silhouette Shader

Postby Hoeloe » Tue May 19, 2020 8:00 am

I think whatever issue you're experiencing is not what you think it is. It might help to share some code.

cato
Volcano Lotus
Volcano Lotus
Posts: 564
Joined: Thu Aug 24, 2017 3:06 am
Flair: Koishi enjoyer
Contact:

Re: Silhouette Shader

Postby cato » Tue May 19, 2020 8:19 am

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.
Last edited by cato on Wed May 20, 2020 2:59 am, edited 1 time in total.

TheGameyFireBro105
Eerie
Eerie
Posts: 747
Joined: Thu Jan 09, 2020 6:09 pm
Flair: Good at remakes
Pronouns: he/him

Re: Silhouette Shader

Postby TheGameyFireBro105 » Tue May 19, 2020 7:53 pm

how do i load it?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9890
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Silhouette Shader

Postby Emral » Wed May 20, 2020 1:02 am

TheGameyFireBro105 wrote:
Tue May 19, 2020 7:53 pm
how do i load it?
The first line in the code directly above the post you made.

cato
Volcano Lotus
Volcano Lotus
Posts: 564
Joined: Thu Aug 24, 2017 3:06 am
Flair: Koishi enjoyer
Contact:

Re: Silhouette Shader

Postby cato » Wed May 20, 2020 3:09 am

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.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9890
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Silhouette Shader

Postby Emral » 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.

cato
Volcano Lotus
Volcano Lotus
Posts: 564
Joined: Thu Aug 24, 2017 3:06 am
Flair: Koishi enjoyer
Contact:

Re: Silhouette Shader

Postby cato » 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.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9890
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Silhouette Shader

Postby Emral » Wed May 20, 2020 3:57 am

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?

cato
Volcano Lotus
Volcano Lotus
Posts: 564
Joined: Thu Aug 24, 2017 3:06 am
Flair: Koishi enjoyer
Contact:

Re: Silhouette Shader

Postby cato » Wed May 20, 2020 4:29 am

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.

KurttheKing
Tweeter
Tweeter
Posts: 144
Joined: Tue Mar 15, 2022 4:55 pm
Flair: Certified Nerd
Pronouns: He/Him
Contact:

Re: Silhouette Shader

Postby KurttheKing » Thu Jul 21, 2022 8:34 pm

How come I need WinZip to open it?

ShadowXeldron
Snifit
Snifit
Posts: 232
Joined: Sun Dec 08, 2019 8:21 am
Flair: phpBB > ProBoards
Pronouns: He/Him
Contact:

Re: Silhouette Shader

Postby ShadowXeldron » 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.

KurttheKing
Tweeter
Tweeter
Posts: 144
Joined: Tue Mar 15, 2022 4:55 pm
Flair: Certified Nerd
Pronouns: He/Him
Contact:

Re: Silhouette Shader

Postby KurttheKing » Fri Jul 22, 2022 8:03 am

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!

deice
Rocky Wrench
Rocky Wrench
Posts: 620
Joined: Fri Jul 23, 2021 7:35 am

Re: Silhouette Shader

Postby deice » Fri Jul 22, 2022 4:09 pm

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).


Return to “LunaLua”

Who is online

Users browsing this forum: DeviousQuacks23 and 5 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari