So, drawing a laser beam on top of my level. . . .

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Post Reply
iNCEPTIONAL

So, drawing a laser beam on top of my level. . . .

Post by iNCEPTIONAL »

Looking at the level below, which currently uses all four of Mode 0's backgrounds and also uses colour math for the semi-transparent water:
Level.png
https://youtu.be/oCiSEChgjC4

And, thinking about the test dougeff did that allowed the drawing of an extra shape of top of all the other layers using window/shape masks and the other colour math stuff required to create the effect in his demo, viewtopic.php?t=24033, what version of the beam below would I actually be able to draw over the top of all the backgrounds in my Mode 0 level?
LevelWithBeam.png
Now, I know I can't draw that specific solid beam on top of everything else exactly as it's shown here [or at least I don't think so] because that would mean using two different kinds of colour math on the same scanline [or something like that], which I know I can't do [as far as I've come to understand it], so I'm asking what that beam could possibly look like using the window/shape masks and the rest of the options available (solid shape, semi-transparent shape, showing only certain other layers through for an interesting effect, etc)?

Ideally, I'd just want to be able to draw that green beam as semi-transparent too, in one way or another. But I'll happy consider other possible ways of getting something that can still sell the idea of some kind of beam being there.

I mean, I know the window/shape masks can be still used here in some capacity, but I just don't know how effectively they can be used, and exactly how it might look if the beam has to share the same kind of colour math as the water layer, or how many possible different options there are for how it might look trying all variations of how it's being drawn and so on (using background/backdrop colour, using fixed colour, masking out some layers but not others, etc).

If I could at least get that solid shape, or some variation of something like that in the beam window/shape mask, then I think I could use that. And I could even only draw it every second frame to create the illusion that it too is semi-transparent, if that can't be done otherwise due to how everything else in the level is being drawn here (specifically the fact the water is already using a particular colour math for the semi-transparency).

And, note, my level is already using all the normal background layers and sprites for all the background layers plus the various ships and bullets and so on, so I'm specifically trying to think about a way of getting that beam effect in addition to all of that more regular stuff, just like in dougeff's demo (but obviously taking into consideration that my specific level is already displaying semi-transparent water).
Last edited by iNCEPTIONAL on Thu Jul 21, 2022 11:54 am, edited 1 time in total.
User avatar
rainwarrior
Posts: 8733
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: So, drawing a laser beam on top of my level. . . .

Post by rainwarrior »

If your background colour (palette #0) is green, you can create that beam with 1 window. Colour math is not needed.

Dougeff mentioned that it could cut through all layers and appear "in front", though you can make the window cut through whichever layers you want, so it can actually appear anywhere in the layer stack. (Though, sprites only being a single layer complicates that a little.)

So, this solid beam could be at the front, back, or somewhere in the middle, if you want. You could change palette 0 per-scanline to get a gradient effect on the colour of the beam as well.

The beam could also share the 50% blend used by the water, though it would not blend with the water itself.


My suggestion in your previous thread to use colour math + fixed colour + window was responding to your question asking if you could place something on top of the background (palette 0) colour. In that case, the presumption was that you wanted the background colour to be seen underneath all the BG layers, and produce an additional coloured shape on top of it that did not belong to any of the other layers. i.e. you have a "sky" colour (palette 0) and then put something on top of it (but underneath BG4).

The difference in dougeff's suggestion is that instead of having a sky colour at the bottom, whatever you want for the sky would actually be part of BG4 instead. So you don't need colour math to put anything "on top" of the sky, you can just cut a hole in the sky to show your beam. Because of this BG4's palettes will have to include a colour for that sky, since palette 0 is now occupied by your green beam.

So the disadvantage of dougeff's method is that you don't get a "shared" sky colour that appears under everything, instead whatever you use for sky has to occupy 1 of the 3 colours in any of BG4's subpalettes which need to cover the sky. (It's only a minor disadvantage, and probably a good tradeoff to not occupy colour math.)
iNCEPTIONAL

Re: So, drawing a laser beam on top of my level. . . .

Post by iNCEPTIONAL »

You are correct if you are thinking those are two different things I was asking about. I'm just pondering some potentials and throwing out a few ideas to see if they're possible.

In this case though, as long as I make sure there's no gaps in any of the layers that would require seeing the background/backdrop colour (at least on any scanlines where I plan on drawing the beam), which I'm pretty sure I can do by just tweaking my current BG4 art a little bit so it's basically a full image with no transparent pixels (at least on those scanlines), and set that background/backdrop colour to the one I want to use for the beam, then it sounds like it can be done pretty much as visualised.

Assuming I have understood you correctly, that's cool to know.

Edit: You know, I'm just thinking, if I use your previous method for drawing the planet in only the top third of the screen then switch to the method you just described below that to draw the beam in only lower portion of the screen (changing the way I use the background/backdrop colour and how I create the layers as required at the same points down the screen respectively), I think I could have both the planet behind everything at the top of the screen and the beam on top of everything in the lower section of the screen, alongside everything else going on with the layers normally.
iNCEPTIONAL

Re: So, drawing a laser beam on top of my level. . . .

Post by iNCEPTIONAL »

Another question, which I might have brought up before but want to double check: Can I use the background/backdrop colour as the second "layer" when using blending to make one of the regular layers look semi-transparent?

Or, probably more technically correct (I'm not sure), can I blend a colour used on one of the layers [or the sprites] with the background/backdrop colour only?
Last edited by iNCEPTIONAL on Thu Jul 21, 2022 11:45 am, edited 1 time in total.
User avatar
rainwarrior
Posts: 8733
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: So, drawing a laser beam on top of my level. . . .

Post by rainwarrior »

Yes. CGADSUB controls which layers of the main screen can be affected by colour math, including the backdrop.
iNCEPTIONAL

Re: So, drawing a laser beam on top of my level. . . .

Post by iNCEPTIONAL »

rainwarrior wrote: Thu Jul 21, 2022 10:32 am Yes. CGADSUB controls which layers of the main screen can be affected by colour math, including the backdrop.
Great.

This helps a lot with how I might tweak my backgrounds to possibly have the planet in the background and the laser beam in the foreground at the same time. I actually had it setup like this in the first place but there seemed to be a visual bug when I got the first prototype of the level, which looked to be caused by the colour math somehow never applying to any place on the water layer that was above only the plain background/backdrop colour, so I changed BG4 to get around this, yet never actually confirmed if I really needed to. So I think I can just go back to how I was doing it originally now.
Post Reply