(shouting)

LunaLua Offical Thread

The second SMBX collab!

Shall I stream some LunaLua live development?

Yes
23
92%
No
2
8%
 
Total votes: 25

User avatar
Wohlstand
Moondust and TheXTech developer
Posts: 186
Joined: 10 years ago
First name: Vitaly
Pronouns: he/him/his
Location: Moscow, Russia

Re: Presenting: Lunadll for Lua!

Post by Wohlstand »

Because my server will be temporary down because I will have some works with it's hardware, the LunaLUA builtd will be available here:
https://drive.google.com/folderview?id= ... e_web#list
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Horikawa Otane wrote:Could peeps get this working in the next month or two?
For those interested in the current status of the OpenGL renderer for LunaDLL, I have it mostly working at this point though have a little cleanup to do, some very obvious optimizations I haven't done yet, and performance testing.

One note is that the rendering of masks that aren't black and white will be subtly different than SMBX's default rendering. Left is the OpenGL renderer and right is the default SMBX renderer.
Image

The default SMBX rendering use a bitwise AND on the colors to do the mask, and a bitwise OR on the colors to to paint the foreground. OpenGL technically can do bitwise color operations but they're not hardware accelerated usually so they're not a real option.

Instead, I treat the mask as a "multiply" channel, and treat the foreground as a "max" operator channel. For attempts at using SMBX graphics layering for lighting it should look similar except a little better.

This approach doesn't quite allow the mask GIF to be used as an alpha channel, but it should allow good compatibility with the old method in most cases, including 100% comparability with the type of lazily created masks that Wohl made a fix tool for (the ones where the foreground content is in the mask file).

I'm pretty confident this rendering method should work well for existing SMBX content in every case except for
1) if level difficulty intentionally depended on the strange artefacts that the bitwise operations created (which I hope nobody has done), and
2) the hypothetical case where the bitwise nature of it's old rendering was very specifically taken advantage of to make two things with a very similar color create a highly contrasting pattern when layered ontop of eachother (which I rather strongly doubt anyone has done)
User avatar
FrozenQuills
hehe haha 2024
Posts: 843
Joined: 9 years ago
Location: my skull

Re: Presenting: Lunadll for Lua!

Post by FrozenQuills »

Rednaxela wrote:I'm pretty confident this rendering method should work well for existing SMBX content in every case except for
1) if level difficulty intentionally depended on the strange artefacts that the bitwise operations created (which I hope nobody has done), and
2) the hypothetical case where the bitwise nature of it's old rendering was very specifically taken advantage of to make two things with a very similar color create a highly contrasting pattern when layered ontop of eachother (which I rather strongly doubt anyone has done)
I may be wrong on this but I think Willhart did both of those in one of his A2XT levels to great effect (Dark Prince I believe)
Image
Image
avatar by crayonchewer!
Image
Image
Image
SMBX Tileset Compiler and Separator
The boss entry that made me eat a shoe.

5th place counter: 5
(SMBX Forums CC11, SMBX Forums CC12, Endgame Madness Contest, SMWC Kaizo Contest 2016, SMWC 24hr Contest 2018)
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

FrozenQuills wrote:I may be wrong on this but I think Willhart did both of those in one of his A2XT levels to great effect (Dark Prince I believe)
Hrm... he definitely did it seems:
Willhart wrote:
Image
Unfortunately I think it's basically impossible to make a hardware accelerated renderer that is compatible with that... (well... it might be possible with a bunch of work put into some multi-pass rendering plus a custom shader but there would probably be a pretty huge performance penalty to that...)

I wonder if the best option might be make it possible to blacklist specific levels as incompatible with the accelerated renderer... There's certainly no good way I can automatically detect that type of situation.
User avatar
Willhart
Stalker, Doxxer, and Sexual Harasser
Banned
Posts: 2434
Joined: 13 years ago
Location: Finland

Re: Presenting: Lunadll for Lua!

Post by Willhart »

Horikawa Otane wrote:
Rednaxela wrote: I'm pretty confident this rendering method should work well for existing SMBX content in every case except for
1) if level difficulty intentionally depended on the strange artefacts that the bitwise operations created (which I hope nobody has done), and
2) the hypothetical case where the bitwise nature of it's old rendering was very specifically taken advantage of to make two things with a very similar color create a highly contrasting pattern when layered ontop of eachother (which I rather strongly doubt anyone has done)
Would it be possible to create support for both?

Like if a level has opengl.bitwise = true; or something, it'll do the un-accelerated bitwise in the level, but otherwise it'll do your method?
One of my a2xt levels does indeed need the strange transparency artefacts from the default smbx. I did exactly the number 2.
https://www.youtube.com/watch?v=l3yrq2t01AU
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Horikawa Otane wrote:Would it be possible to create support for both?

Like if a level has opengl.bitwise = true; or something, it'll do the un-accelerated bitwise in the level, but otherwise it'll do your method?
Rather than try to do the almost-certainly-unaccelerated bitwise rendering in the opengl renderer, I think it's safer to simply switch to the old SMBX rendering engine, so rather than "opengl.bitwise = true" and "opengl.bitwise = false" I'd rather "renderer = bitblt" and "renderer = opengl". That could be in a config file that could perhaps exist both per-episode and per-level.
Or instead of a config file (or as well?), I could implement a LunaLua function to switch the active renderer. The transition between renderers should be completely seamless without any flicker or anything.
User avatar
Willhart
Stalker, Doxxer, and Sexual Harasser
Banned
Posts: 2434
Joined: 13 years ago
Location: Finland

Re: Presenting: Lunadll for Lua!

Post by Willhart »

Can Lua be used to open websites, while in game?
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Willhart wrote:Can Lua be used to open websites, while in game?
You mean like... launch the user's default web browser with a specific URL, so the web browser appears in a new window? Not possible with the current versions of LunaLua, but quite simple to add support for if there's a good use case for it.
SMetoid99
Posts: 0
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by SMetoid99 »

Can you do a code for health system as opposed to losing power ups when you get hit and a stacking system that stacks whatever power ups you collect so if you get fireflower, leaf, hammersuit etc everyone of them is in the item box as opposed to just one.
User avatar
Wohlstand
Moondust and TheXTech developer
Posts: 186
Joined: 10 years ago
First name: Vitaly
Pronouns: he/him/his
Location: Moscow, Russia

Re: Presenting: Lunadll for Lua!

Post by Wohlstand »

Willhart wrote:Can Lua be used to open websites, while in game?
If we will make function:

Code: Select all

void openURL(char *url)
{
	std::string urlt = "start \"";
	urlt = urlt+"%s\"";
	system(urlt.c_str());
}
and when we will bind it
User avatar
Willhart
Stalker, Doxxer, and Sexual Harasser
Banned
Posts: 2434
Joined: 13 years ago
Location: Finland

Re: Presenting: Lunadll for Lua!

Post by Willhart »

Rednaxela wrote:
Willhart wrote:Can Lua be used to open websites, while in game?
You mean like... launch the user's default web browser with a specific URL, so the web browser appears in a new window? Not possible with the current versions of LunaLua, but quite simple to add support for if there's a good use case for it.
The raocow video today had a room full of paintings that had some video urls. They were probably links to the creators favorite videos. It would have been neat if a page opened after going to a door or talking to a tv or something. It would have made the videos easier to watch.

It could also be used for directly linking to the talkhaus, raocow's videos, and level related content like the wiki pages and outsourced stuff credits. It could also be used for linking secret rewards like artwork and sketches. This was just an idea that came to mind, and I'm sure there are many other things that would be more important right now. Also it really would not add anything to the gameplay, and It would likely only be used on the hubs.

edit: It can also be used wrong on contests and joke levels and it might accidentally open same page multiple times in a row.
User avatar
romajiQuadhash
typos "raocow" as "roacow" (and I TAS)
Posts: 12
Joined: 9 years ago
First name: Romaji Quadhash
Pronouns: ke/keh/ker
Location: ""Canada""

Re: Presenting: Lunadll for Lua!

Post by romajiQuadhash »

Rednaxela wrote:
Horikawa Otane wrote:Could peeps get this working in the next month or two?
For those interested in the current status of the OpenGL renderer for LunaDLL, I have it mostly working at this point though have a little cleanup to do, some very obvious optimizations I haven't done yet, and performance testing.

One note is that the rendering of masks that aren't black and white will be subtly different than SMBX's default rendering. Left is the OpenGL renderer and right is the default SMBX renderer.
Image

The default SMBX rendering use a bitwise AND on the colors to do the mask, and a bitwise OR on the colors to to paint the foreground. OpenGL technically can do bitwise color operations but they're not hardware accelerated usually so they're not a real option.

Instead, I treat the mask as a "multiply" channel, and treat the foreground as a "max" operator channel. For attempts at using SMBX graphics layering for lighting it should look similar except a little better.

This approach doesn't quite allow the mask GIF to be used as an alpha channel, but it should allow good compatibility with the old method in most cases, including 100% comparability with the type of lazily created masks that Wohl made a fix tool for (the ones where the foreground content is in the mask file).

I'm pretty confident this rendering method should work well for existing SMBX content in every case except for
1) if level difficulty intentionally depended on the strange artefacts that the bitwise operations created (which I hope nobody has done), and
2) the hypothetical case where the bitwise nature of it's old rendering was very specifically taken advantage of to make two things with a very similar color create a highly contrasting pattern when layered ontop of eachother (which I rather strongly doubt anyone has done)
This looks really good!
This is a sig
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

SMetoid99 wrote:Can you do a code for health system as opposed to losing power ups when you get hit and a stacking system that stacks whatever power ups you collect so if you get fireflower, leaf, hammersuit etc everyone of them is in the item box as opposed to just one.
That's certainly possible to implement with LunaLua, but not something I think anyone has code existing for thus far.
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Preliminary performance testing results with the new OpenGL rendering engine:

Using a test level where I spawn in 1000 paragoombas, I get a frame rate of 33 FPS with the default BitBlt renderer, and 43 FPS with the OpenGL renderer.

As an alternate measurement method, a profiler indicates that default renderer accounts for 25% of SMBX's CPU usage in that scenario, whereas the OpenGL renderer accounts for 13% of SMBX's CPU usage.

Further improvement to the performance of the OpenGL renderer will likely require either:
1) Automatically detecting masks that are purely black and white, and for that case performing the optimization of merging the mask and foreground texture into a single RGBA texture (Not only does this halve the rendering operations, but also means that when rendering many of one sprite in a row it won't need to constantly alternate bound textures. Texture binding can be a notable bit of overhead in OpenGL after all.)
2) Implementing a dynamically generated texture atlas (Probably not worth trying until I try #1 first)

I'll probably check in this initial implementation without further optimizations for the moment, but I'll likely look into implementing #1 too at some point.

I might also look into what other bottlenecks I might be able to patch which aren't graphics related. After all, the 1000 paragoomba had a hefty 75% of the overhead not being graphics related (or 87% with the OpenGL renderer).
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Horikawa Otane wrote:It's giving me "Module Triggers not Found"

(Changing it to loadSharedAPI("triggers"); gives me an 'attempt to index null value trigger' error)
It should be loadSharedAPI yeah...

It's hard to know for certain what the significance of that error after that fix without more information (i.e. which line of code it occurred on, which the stack trace it gives will tell you. Also I assume the error said "triggers" and not "trigger")

Also I assume triggers.lua is present in LuaScriptsLib, right?
SMetoid99
Posts: 0
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by SMetoid99 »

Rednaxela wrote:
SMetoid99 wrote:Can you do a code for health system as opposed to losing power ups when you get hit and a stacking system that stacks whatever power ups you collect so if you get fireflower, leaf, hammersuit etc everyone of them is in the item box as opposed to just one.
That's certainly possible to implement with LunaLua, but not something I think anyone has code existing for thus far.
damn it, was hoping someone would have the code cause it would really help me
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Horikawa Otane wrote: Line 4.

Yeah it said triggers. And I have triggers.lua there.
So... I've tried to reproduce this, but I can't. I don't get any such error when that lua code after replacing

Code: Select all

triggers = require("triggers");
with

Code: Select all

triggers = loadSharedAPI("triggers");
So there must be something different in your setup... wait... re-reading what you said, when you switched it to loadSharedAPI, did you inadvertently remove the "triggers =" part of the line too?
test.zip
(977 Bytes) Downloaded 45 times
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

Acutally Rednaxela and me figured a lot about the warp struct: See here
... including the filename of the level for the warp.

But I didn't bind it yet for lua.
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Given what we know about the warp struct, adding the Lua bindings sufficient to do what you want shouldn't be too hard, so one of us could certainly do that in pretty short order.

Also, I think the idea of that being an effect in the hub is a pretty darn snazzy idea!
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Horikawa Otane wrote:Basically, the goal would be if a player is within 1 block (around 32 pixels) of the warp, they would automatically become the character that warp is meant to filter to. It'd be a neat effect as you run through the hub!
So, earlier today Kevsoft added the Warp bindings for Lua. I just made a little test level using them based on what you wanted. I also included some invincibility frames after the character switch and a character-dependent sound effect for flavour just because.
WarpTest.zip
(1.15 KiB) Downloaded 54 times
Also here's a build of the development version of LunaDLL which is required to run the that test level:
LunaLUA_0.7-ish-Prerelease.zip
(628.3 KiB) Downloaded 59 times
Lua code here:

Code: Select all

local characterMap = {}
characterMap["link-1.lvl"] = 5;
characterMap["luigi-1.lvl"] = 2;

function onLoop()
    for idx, warp in pairs(Warp.get()) do
        if (math.abs(warp.entranceX - player.x) < 32) and (math.abs(warp.entranceY - player.y) < 64) then
            lastChar = player:mem(0xF0, FIELD_WORD)        
            newChar = characterMap[warp.levelFilename]
            
            -- If this warp has a character specified, and it's not the character that we already are
            if (newChar ~= nil) and (newChar ~= lastChar) then
                -- Set character
                player:mem(0xF0, FIELD_WORD, newChar)
                
                -- Start powerup blinking, just because
                player:mem(0x140, FIELD_WORD, 30)
                
                -- Sound effect as well, just because
                if (newChar == 1) or (newChar == 2) then
                    playSFX(6)
                elseif (newChar == 5) then
                    playSFX(79)
                elseif (newChar == 3) then
                    playSFX(59)
                elseif (newChar == 4) then
                    playSFX(7)
                end
            end
        end
    end
end
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Horikawa Otane wrote:Does the 0.7.0.0 beta have the opengl acceleration? And if so, how do we turn it off and use the old renderer? I need to turn it off for a particular level, I think.
That development build I posted technically has the opengl code in it, but it's completely disabled without a way to enable it exposed yet, so for all useful intents and purposes it doesn't have it yet.
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

So, lots of people know how the smbx.exe file that's modified to load LunaDLL triggers AV scanners. It's a big nuisance really.

To fix this in the next LunaDLL release, I've implemented a loader of sorts called "LunaLoader.exe" which allows you to load LunaDLL into a 100% unmodified vanilla copy of smbx.exe, which does not panic the AV scanners. ;)

Next LunaDLL release will be an interesting/exciting one in some ways, with lots of work by both Kev and myself.

(Horikawa: Regarding the opengl renderer you want to try out, I'll get back to that within the next few days. Probably would have had what I wanted to finish in it before public testing done at the end of the weekend except I took up the relay level organizing stuff, and then tonight I felt like finishing up the LunaLoader stuff that I had in progress)
User avatar
Willhart
Stalker, Doxxer, and Sexual Harasser
Banned
Posts: 2434
Joined: 13 years ago
Location: Finland

Re: Presenting: Lunadll for Lua!

Post by Willhart »

I've made couple of levels that involve layers attached to moving npcs that are killed by lava while in motion. This can be used to make custom conveyor belts that are less glitchy than the smbx ones, make slopes act like conveyor belts and make the player move upward after walking of specific ledges.

Is something like this possible to make with lunalua too? Having to kill the npcs at the level start makes midpoints a little complicated to use, and requires different setup for each direction. All the blocks on a same layer will affect the player like they were moving.


And here is a link to the level. https://drive.google.com/file/d/0Bxij3Y ... sp=sharing.
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Willhart wrote:I've made couple of levels that involve layers attached to moving npcs that are killed by lava while in motion. This can be used to make custom conveyor belts that are less glitchy than the smbx ones, make slopes act like conveyor belts and make the player move upward after walking of specific ledges.

Is something like this possible to make with lunalua too? Having to kill the npcs at the level start makes midpoints a little complicated to use, and requires different setup for each direction. All the blocks on a same layer will affect the player like they were moving.


And here is a link to the level. https://drive.google.com/file/d/0Bxij3Y ... sp=sharing.
Ooh... that's a rather interesting glitch in SMBX... LunaLua should be able to very easily give blocks or layers (which depends on exactly how this glitch is occurring under the hood) the same property without involving NPCs at all. I'll post an update once I get a chance to test some things tonight.
User avatar
TaviTurnip
Reach for the top
Abministrator
Posts: 1077
Joined: 14 years ago
First name: Rena
Location: Winter

Re: Presenting: Lunadll for Lua!

Post by TaviTurnip »

Horikawa Otane wrote:People are idiots, so I need to swap them out for stars and stuff. I'd like to make sure none exist.
Just because they're idiots doesn't mean you can replace people out of existence, Horikawa :< </3
I regularly stream on Twitch! with other members of the talkhaus. Come watch Monday, Tuesday and Friday at 2PM for blind playthroughs and Pokémon and Touhou and stuff. Come hang out with us!
Post Reply