Page 1 of 2
Pixel exact collision brush to brush
Posted: Wed Sep 13, 2023 8:42 am
by fingus
Maybe this is a limitation of using RebelSDL, it would be a nice feature if #BRUSH-to-#BRUSH Collision can handle it pixel exact (on visible alpha-pixels for example).
Or this is a Limitation of Hollywood 9.1 (Linux). I didn't find informations in the readme of the Hollywood 10-Release, that this feature was improved/added.
Re: Pixel exact collision brush to brush
Posted: Wed Sep 13, 2023 9:34 am
by fingus
Add: With RebelSDL-Plugin 1.1
Re: Pixel exact collision brush to brush
Posted: Wed Sep 13, 2023 9:35 pm
by airsoftsoftwair
Hmm, the
Collision() function should support pixel-exact collision detection?! What exactly isn't working for you?
Re: Pixel exact collision brush to brush
Posted: Thu Sep 14, 2023 12:48 pm
by fingus
Imagine a sidescroller like R-Type.
I use a giant wide-brush as prerendered game-level. The level has graphics on top and bottom and in between it is full alpha transparent.
When i put my player brush on it the #brush-collision gives me always true back, even if i don't touch the visible areas of the level (top and bottom).
An other example is, when an object touch the invisible alpha-border of another brush, collision is true immediately.
So in my case the collision will be true if at least one pixel (visible or not) of each BRUSH-BOX is overlapping.
Maybe this is a limitation of Hardware-Brushes in combination with DoubleBuffering and RebelSDL on Linux?
Re: Pixel exact collision brush to brush
Posted: Thu Sep 14, 2023 2:36 pm
by fingus
@Andreas:
I send you an example (code + images).
Re: Pixel exact collision brush to brush
Posted: Sun Sep 24, 2023 12:54 pm
by airsoftsoftwair
fingus wrote: ↑Thu Sep 14, 2023 12:48 pm
Maybe this is a limitation of Hardware-Brushes in combination with DoubleBuffering and RebelSDL on Linux?
Yes, it's a limitation of hardware brushes, not only on Linux but in general. For hardware brushes collision detection is never pixel exact because that would require reading from the hardware brush but that isn't easily possible because it's in GPU memory and reading from GPU memory is only possible with significant overhead. AmigaOS will also freeze the mouse pointer when reading from video memory but also on other platforms reading from VRAM is a real performance killer.
To work around this limitation you could use hardware brushes for drawing and software copies of the hardware brushes for collision detection. For software brushes collision detection will always be pixel-perfect. I'll add a note in the
Collision() documentation that informs the user that hardware brushes don't support pixel-perfect collision detection.
Re: Pixel exact collision brush to brush
Posted: Tue Sep 26, 2023 11:39 pm
by Tuxedo
airsoftsoftwair wrote: ↑Sun Sep 24, 2023 12:54 pm
Yes, it's a limitation of hardware brushes, not only on Linux but in general. For hardware brushes collision detection is never pixel exact because that would require reading from the hardware brush but that isn't easily possible because it's in GPU memory and reading from GPU memory is only possible with significant overhead. AmigaOS will also freeze the mouse pointer when reading from video memory but also on other platforms reading from VRAM is a real performance killer.
To work around this limitation you could use hardware brushes for drawing and software copies of the hardware brushes for collision detection. For software brushes collision detection will always be pixel-perfect. I'll add a note in the
Collision() documentation that informs the user that hardware brushes don't support pixel-perfect collision detection.
Hum...stupid question...but that method dont double the memory usage since you have to load an hardware copy and a non hardware copy of the same brush?
Re: Pixel exact collision brush to brush
Posted: Wed Sep 27, 2023 10:23 am
by fingus
Tuxedo wrote: ↑Tue Sep 26, 2023 11:39 pm
airsoftsoftwair wrote: ↑Sun Sep 24, 2023 12:54 pm
Yes, it's a limitation of hardware brushes, not only on Linux but in general. For hardware brushes collision detection is never pixel exact because that would require reading from the hardware brush but that isn't easily possible because it's in GPU memory and reading from GPU memory is only possible with significant overhead. AmigaOS will also freeze the mouse pointer when reading from video memory but also on other platforms reading from VRAM is a real performance killer.
To work around this limitation you could use hardware brushes for drawing and software copies of the hardware brushes for collision detection. For software brushes collision detection will always be pixel-perfect. I'll add a note in the
Collision() documentation that informs the user that hardware brushes don't support pixel-perfect collision detection.
Hum...stupid question...but that method dont double the memory usage since you have to load an hardware copy and a non hardware copy of the same brush?
Yes is does, at least for all bitmaps that need pixel-exact collision. Normally only the Playfield and the small Player-/Enemy-/Bullet-Sprites which doesn't represent the majority of RAM-allocation in my game-project. There are also other big bitmaps like parallax-layer, background-/foreground-layer which didn´t need collision at all. So in times of Gigabytes of RAM/VRAM i can life with it.
Re: Pixel exact collision brush to brush
Posted: Wed Sep 27, 2023 10:26 am
by fingus
airsoftsoftwair wrote: ↑Sun Sep 24, 2023 12:54 pm
fingus wrote: ↑Thu Sep 14, 2023 12:48 pm
Maybe this is a limitation of Hardware-Brushes in combination with DoubleBuffering and RebelSDL on Linux?
Yes, it's a limitation of hardware brushes, not only on Linux but in general. For hardware brushes collision detection is never pixel exact because that would require reading from the hardware brush but that isn't easily possible because it's in GPU memory and reading from GPU memory is only possible with significant overhead. AmigaOS will also freeze the mouse pointer when reading from video memory but also on other platforms reading from VRAM is a real performance killer.
To work around this limitation you could use hardware brushes for drawing and software copies of the hardware brushes for collision detection. For software brushes collision detection will always be pixel-perfect. I'll add a note in the
Collision() documentation that informs the user that hardware brushes don't support pixel-perfect collision detection.
Thank you for the hint, it does work, so i'm not forced to use an own collision-function which saves me a lot of work, thank you!
Re: Pixel exact collision brush to brush
Posted: Sat Sep 30, 2023 2:41 pm
by Tuxedo
fingus wrote: ↑Wed Sep 27, 2023 10:23 am
Yes is does, at least for all bitmaps that need pixel-exact collision. Normally only the Playfield and the small Player-/Enemy-/Bullet-Sprites which doesn't represent the majority of RAM-allocation in my game-project. There are also other big bitmaps like parallax-layer, background-/foreground-layer which didn´t need collision at all. So in times of Gigabytes of RAM/VRAM i can life with it.
Yes I think same of you, but my Amiga-optimizer heart was still herer
