Post Reply 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Graphics Issues
05-24-2013, 12:58 AM (This post was last modified: 05-24-2013 12:58 AM by [Unknown].)
Post: #4
RE: Graphics Issues
Well, 1.75 is *definitely* wrong. But there are a few things that could be going on here... let me explain.

PSP games can set an "alphatest". It has four separate settings: enable/disable, reference value, mask, and operation.

Masks aren't currently supported (GLES doesn't support integer masking), although I have an idea for supporting most of the values we've seen ( but I'm not sure of any issues it causes to verify it well..

That said, assuming you have turned on server compatibility reporting, this game isn't showing in that list so it's not likely to be using an alphatest mask. Most games don't.

Anyway, the alphatest otherwise compares the alpha of *each pixel* to the reference value. The comparison operator can be ==, !=, <, <=, etc. If the alphatest passes (e.g. if they are ==), it draws the pixel.

Due to either simplicity or (iirc?) bugs in certain cards/drivers, we reverse the operation: we change "==" into "!=", and don't draw it if it fails. That's the "discard" in the line.

Anyway, the reference value is between 0 and 255 - the alpha value. It's specified as an integer.

The alpha value in OpenGL is a float, and is affected by things like texture mapping. So, for example, the alpha value it calculates may be "0.498" (between 0.0 = 0 and 1.0 = 255), which actually means "127" is "alpha reference value" language. Make sense?

So, floor(v.a * 255.0) scales this properly to 0 - 255, so that it looks like the reference value. The problem is, it still has a pesky decimal point. For example, "0.5" would turn into "127.5". If the alphatest is "!= 128", then it will draw things it shouldn't, because 127.5 != 128.0 is true. And floor makes that 127.0, not 128.0.

Adding 0.5 makes it always round up (like you were taught in math class.) I don't know, but the PSP itself might be doing even/odd rounding (common in computers to prevent bias) or it may do its math in a way that doesn't even need rounding for alpha.

In any case, 1.75 is too high - that's more than rounding up, that's totally changing the value. So now, "127.5 != 128.0" turns into floor(127.5 + 1.75) = floor(129.25) = 129, so "129.0 != 128.0". The test still won't pass correctly.

It'd be useful to see what operator it's using. Can you do a frame dump (Debug -> Dump Next Frame To Log) and paste a link to the result here? You may have to select the option more than once if the game doesn't (internally) run at 60 fps.

Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
Graphics Issues - Denizen - 05-22-2013, 12:26 AM
RE: Graphics Issues - [Unknown] - 05-22-2013, 05:13 AM
RE: Graphics Issues - Denizen - 05-24-2013, 12:05 AM
RE: Graphics Issues - [Unknown] - 05-24-2013 12:58 AM
RE: Graphics Issues - Denizen - 05-24-2013, 02:59 PM
RE: Graphics Issues - Denizen - 05-26-2013, 12:08 AM

Forum Jump: