Hi, I have no idea if it is already implemented, but in the case it isn't, I would suggest Windowing
It is used in quite a lot of Super Nintendo games, such as Super Mario World for the keyhole effect, or Super Metroid with the X-Ray glasses.
You also have this video that makes a pretty unique use of this technique :
I also found a video that explains the effect pretty well if you are interested :
https://youtu.be/uRjf8ZP6rs8?t=243
I have no idea if that can drain performances, but I think the basic principle is you don't display a layer when the pixel you want to draw is outside of a 2 X-values interval of the screen, and you can make more complex shapes (such as a circle for example) by changing those X values between scanlines.
What do you think about this suggestion?
Hi!
Thanks for the suggestion and related documentation, this is quite interesting :-)
Tilengine implements a feature that, albeit not as complex as SNES windowing feature, is quite similar and can do the same trick in most scenarios. This is
layer clipping:
https://www.tilengine.org/doc/md_layers....totoc_md37
The idea is simple: each background layer can have a clip region, defined by a rectangle, that masks out what lies outside the rectangle. Playing with the clipping rectangles of two or more layers using raster effects to tweak their shape can lead to very interesting special effects.
The explanation about how windowing works in SNES is very well explained. The SNES has a limited number of layers, so having the ability to combine masking with constant color blending (transparency) within a single layer is important. In Tilengine you can have more layers, and you can also clip and do color math. So, despite having somewhat different implementation, I think I could do all the shown effects with Tilengine without implementing any new feature. Some effects are more difficult than others, however.
What do you think? What effect do you have in mind?
(01-19-2023, 04:16 AM)megamarc Wrote: [ -> ]Hi!
Thanks for the suggestion and related documentation, this is quite interesting :-)
Tilengine implements a feature that, albeit not as complex as SNES windowing feature, is quite similar and can do the same trick in most scenarios. This is layer clipping:
https://www.tilengine.org/doc/md_layers....totoc_md37
The idea is simple: each background layer can have a clip region, defined by a rectangle, that masks out what lies outside the rectangle. Playing with the clipping rectangles of two or more layers using raster effects to tweak their shape can lead to very interesting special effects.
The explanation about how windowing works in SNES is very well explained. The SNES has a limited number of layers, so having the ability to combine masking with constant color blending (transparency) within a single layer is important. In Tilengine you can have more layers, and you can also clip and do color math. So, despite having somewhat different implementation, I think I could do all the shown effects with Tilengine without implementing any new feature. Some effects are more difficult than others, however.
What do you think? What effect do you have in mind?
I was thinking to the effects I mentionned.
About transparency, I still have a question. Can Tilengine do that kind of blending effects without having to change the palette?
https://imgur.com/9oaWrY5
Hi!
The effects you mention could be implemented in Tilengine right now, combining layer clipping and layer blending. The ability of the SNES to clip the portion of the layer that lies outside of a pair of x1 - x2 values is what's implemented in tilengine's clipping.
However the SNES can do much more, after watching the video you posted and reading this excellent documentation:
http://emudev.de/q00-snes/windows-bg-pri...-pipeline/
1. Inverse masking: draw what lies outside the x1 - x2 values and skip the inner section
2. Do color math (transparency) with the masked out portions and a fixed color
3. Build clipping masks composed of two rectangles and do bitwise math between them
Tilengine is not an SNES emulator. However I always seek for inspiration on classic systems to implement new features, and I think I could implement points 1 and 2 in Tilengine with relative ease without compromising performance. Point 3 will be left out for now.
Regarding the question about how to do the color trick without changing the palettes, you can do it with two layers in Tilengine:
1. Background layer without priority holds the basic background with standard palette
2. Foreground layer with priority enabled holds a vertical color gradient between black and half intensity red, and enable blending mode BLEND_ADD.
Additive blending of the foreground layer will cause the underlying elements to get progressively lighted with a red tint
(02-11-2023, 01:10 AM)megamarc Wrote: [ -> ]I've released Tilengine 2.14 with a layer window feature very similar to the SNES one, enhancing window clipping already implemented:
https://megamarc.itch.io/tilengine/devlo...yer-window
Oh that looks pretty nice! I'll try to do exemples inspired from Super Mario World and Super Metroid too when possible.
I am also trying to work on a Go version of Tilengine, so, I have to study the depths of the library. Pretty interesting and complex the way it works. I hope I can achieve that.
Hi,
I have a suggestion to improve this feature. What if the user can decide if he wants to show what's inside the rectangle or what's outside of the rectange?
What I mean is currently, the layer is not displayed inside the rectangle. But with my suggestion, the user would be able to mask inside or outside the rectangle (a boolean for inside/outside can maybe do the job).
What do you think of this idea?
Hi!
I think the feature you're looking for is already implemented. It's the last parameter (invert) of function
TLN_SetLayerWindow():
https://github.com/megamarc/Tilengine/bl...ine.h#L584
It allows to clip the outside (false) or the inside (true). TheĀ
LayerWindow.c sample allows you to play with this setting interactively.
Is this the feature you was missing?
(04-04-2023, 08:14 PM)megamarc Wrote: [ -> ]Hi!
I think the feature you're looking for is already implemented. It's the last parameter (invert) of function TLN_SetLayerWindow():
https://github.com/megamarc/Tilengine/bl...ine.h#L584
It allows to clip the outside (false) or the inside (true). TheĀ LayerWindow.c sample allows you to play with this setting interactively.
Is this the feature you was missing?
Hi!
Woops, yeah it is this feature, sorry. But thanks for your answer!