Jump to content
  • 0

128 Sprites - I see weird "drop out"


Getafix
 Share

Question

Hi,

I am playing around with sprites.  I am drawing 128 4bpp sprites in interleaved rows of 10 - using BASIC.  What I see are the sprites 40-49 being clipped badly, along with some other ones.  If I only draw 30-49, I see the same clipping.  However, if I start drawing at 31, then 40-48 are correct, but 49 is still clipped, but in a different way.

I don't really see this being a sprite work unit issue, because it should then happen consistently across other scanlines as well, or is there something I am not understanding?  Just a bug in the emulator?

drawing 0-127. 20 clipped, 40-48 clipped and 49 mostly missing. 59 clipped, 69 clipped, 79 clipped and 118 clipped.

sprites.gif.50b52b33cbc5a799844d870f69fe1f55.gif

Drawing 30-49. Same result as drawing all 128 sprites.

image.png.49057801722a3fdb9b243dc3af181698.png

Drawing 31-49. 49 now half visible.

sprites1.png.1adc9e56d5bbd91cc800489e37638bbc.png

Thanks

Stefan

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

You can't just place all 128 sprites everywhere you want. The VERA has a limited amount of time per scanline to read from the sprite attributes and place them in the buffer.

This is known as the "sprite tearing" effect, and exists in older game consoles as well. Those consoles mainly are limited in number of sprites per line, but the VERA sprites instead have a certain number of "work units" that they cost. If the sprite renderer caps out at ~801 work units on a given line, then nothing else will be rendered, hence the missing sprites there.

  • Thanks 1
Link to comment
Share on other sites

  • 0
2 minutes ago, StinkerB06 said:

The VERA has a limited amount of time per scanline to read from the sprite attributes and place them in the buffer.  If the sprite renderer caps out at ~801 work units on a given line, then nothing else will be rendered, hence the missing sprites there.

Sure.  What I am asking is why is it happening only on a few of the scan lines and not on all patterns that are exactly the same?  Sprite rows 3,4 & 5 are repeated at rows 9, 10 and 11, but those rows do not exhibit the same behaviour.  Is a work unit counted on a per scan line basis, or does it not neccesarily start at the left edge of the screen, at the start of a scan line?  If it is the latter, then is there a way to know how it works (counts work units)?  If the former (does start at the start of a scan line at the left) then why does it only run out of work units, sometimes?

  • Like 1
Link to comment
Share on other sites

  • 0

So it looks like there are 64x64 sprites. 4bpp? If so, each sprite drawn on a line is 1+8+64 workunits, or 73 work units. So you can expect to draw 10 of these to a line, plus most of an 11th before you'll see tearing (enough that you'll probably only tear the very right-most edge of the 11th). The real question is, why are you not seeing much (much much) more tearing than you do?

Other things to keep in mind is that the sprites are not drawn left-to-right, they are drawn in ID order. I'd have to step through the code with a snapshot of VRAM (or simply with your code and assets) to suss out why you're seeing this particular tearing behavior, but in a general sense you are very much overloading the VERA with sprite data per line.

 

  • Thanks 1
Link to comment
Share on other sites

  • 0

The ID's are 0-127 left to right (I assume the IDs are the $FC00 + ID indicies?).  The sprites are indeed 64x64 4bpp, and there are 10 on a line, yes.  @StephenHorn I attach the basic file that poke's the data and shows the sprites, if you feel inclined to check it out further.  If not, not a problem - I will assume there's an emulator issue which causes the delayed (onlines with 20 sprites) clipping and inconsistant results on a line by line basis.  At least till I learn otherwise 😉

sprites.bas

Edited by Getafix
Link to comment
Share on other sites

  • 0

 

On 8/6/2020 at 10:07 AM, StephenHorn said:

So it looks like there are 64x64 sprites. 4bpp? If so, each sprite drawn on a line is 1+8+64 workunits, or 73 work units. So you can expect to draw 10 of these to a line, plus most of an 11th before you'll see tearing (enough that you'll probably only tear the very right-most edge of the 11th). The real question is, why are you not seeing much (much much) more tearing than you do?

Other things to keep in mind is that the sprites are not drawn left-to-right, they are drawn in ID order. I'd have to step through the code with a snapshot of VRAM (or simply with your code and assets) to suss out why you're seeing this particular tearing behavior, but in a general sense you are very much overloading the VERA with sprite data per line.

 

Whoa!   That's something I never knew about sprites!  You learn something new every day...!

 

Edited by rje
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

Please review our Terms of Use