Hi there! I’m trying to (once again) figure out the best way to dynamically “cut off” parts of the sprite (effectively a stencil). For example if there’s a portal you want the sprite to disappear into it (not just disappear completely in 1 frame - that looks weird and cheap).
I’ve previously done something similar by having a condition in the fp/vp that doesn’t render anything outside of a hardcoded y range. The issue is that the value was hand-picker and it introduced a conditional in the fp which I believe is bad practice.
What I want to do now now is to be able to dynamically place these “portals” or “doors” and have the sprite “disappear” and “appear” from them (while still rendering the sprite as usual if the door or portal isn’t used) - looking for any ideas on how to approach this.
Hi! If I understand correctly, you want to block parts of the sprite by the portal or door so it’s only visible on the area that the sprite is rendering on? Sounds like you probably could be using the stencil buffer to achieve that. I have an example here that might help you:
I’ve actually ended up going another way of adding a variable to the fragment program which makes everything to the side of a line alpha = 0 (thanks to everyone here and @JCash and @roccosaienz on Discord for inspiration!)