Resident Evil 2 "Color masks"?

Started by
4 comments, last by phil_t 8 years, 5 months ago

I've always been fasinated by prerendered technology. There's just this awesome 90s vibe about it, takes us back to our favoirte childhood games. One of those games for me was Resident Evil. I was talking to a friend today who happened to be in the business of ripping RE animations from ISO and other stuff. He showed me an interesting 'mask' image that left me wondering... (ripped it off using Rice Video Plugin)

Please see attached images.

Now, I don't know much about PS1 development nor its graphics API, so I don't know for sure how they implemented their illusion of depth. I'm almost certain (correct me if I'm wrong) that they didn't have programmable shaders at the time, but I guess it doesn't necessarily mean that they didn't have access to a depth buffer, if that's the case, and they used depth maps, well depth maps are greyscale images usually, which leaves me wondering what those colors mean in that 'mask' image... They definitely look like they're somehow related to depth, but why colored? Couldn't they just have used, say white and magenta?

Any idea what those colors mean?

(And if anybody know some detail about how they created illusion of depth please share)

Advertisement

Where'd you get the colour mask texture from?

PS1 graphics were basically all software rendered -- so you could do whatever you wanted, as long as the CPU was fast enough :)

The mask seems to be 'tagging' regions. Instead of using a z-buffering technique to test whether each pixel is in-front or behind the character, they seem to be making the decision based on whole objects, which are detected via these 'tagged' colours.

e.g. for the pillar on the right, the logic could be like: if the character's 3D position is inside the back half of the room, then ignore any character pixels that fall within the pillar's mask. If the character is in the front half of the room, draw all character pixels.

I don't think I'd call it "software rendering", exactly. Basically the PS1 CPU had an extra processor (the GTE) with some vector instructions that you'd use for transforming/lighting vertices and setting up + clipping triangles. And then the "GPU" would take the primitives and texture them, and write the result out to a framebuffer in VRAM. There's some info on the GTE here, and some info on the GPU here. Either way the GPU didn't have a Z buffer, and so most PS1 games would sort their polygons by depth. If you go watch or play a PS1 game you can usually see this causing popping artifacts all over the place: it's usually really obvious on animated characters in areas like the shoulders, where the limbs intersect the body. It did however support a very simple masking system, which I think worked by setting and detecting the MSB of a pixel in the framebuffer. So it's possible that they somehow made use of that to selectively render (or re-render) the background so that it would appear to occlude the player model.

Adding to what's been said:

In that era paletted textures were common. If the tex was originally palleted, perhaps what's important is the index rather than the actual colour.

The first thing to know is that the PS1 doesn't even have a depth buffer, so some degree of cleverness is required to have 3D models interacting with pre-rendered backgrounds.

The most obvious way is the break the background into multiple textures by depth, and then draw them in depth order. This is what games like the PS1 Final Fantasies do. The drawback with this method is that it can greatly increase the amount of VRAM taken up by background textures, especially on maps with complex depth structures. I think Resident Evil does something rather different though.

Now I'm not 100% certain (though it is the most likely option given those textures), but I would guess it makes use of the PS1's little-known mask mode. In 15-bit color mode - which is the only mode the PS1 can draw polygons in - the upper bit of each pixel in the frame buffer is used as a masking bit, and when masking is enabled, the GPU does not write to pixels that have their mask bit set. To facilitate this, the GPU also has a mask write mode, which sets the mask bit for pixels that are written.

Now, here's where the magic happens. That mask texture is a palletized texture, meaning it's trivial to recolor on the fly - just set the polygon to use a different color look-up table. The colors in the CLUT are also 15-bit, and again the upper bit has a special meaning, in this case the semi-transparent flag, which functions as a primitive alpha channel. Now an important quirk of the PS1 GPU is that semi-transparent black (i.e. color 0x8000) is treated as transparent regardless of the blend mode and thus isn't drawn.

So at draw time, first the background texture is drawn. Then mask writes are enabled, and, in contrast to standard PS1 rendering, the CLOSEST polygons are drawn (normal PS1 rendering is back to front). Then color writes are disabled, and the mask texture is drawn with a palette that will set the mask bit for the closest background pixels (either the bright green or the ice blue in the lower left corner). Then color writes are enabled again and the next-closest batch of polygons is drawn, and so on. Needless to say, any semi-transparent textures have to be drawn last, which is the one drawback of this method.

For the record, the way the PS1 hardware works means all those state changes are relatively cheap.

(The colors in the mask image that you see are likely just for the artist's convenience, since it's easier to distinguish the different discrete depth levels with colors like that than with a smooth gradient. The actual palettes used in-game are likely the same for all screens and so don't need to be saved with the mask itself.)

Looks very much like the "priority screen" in the old King's Quest games:

http://wiki.scummvm.org/index.php/AGI/Specifications/Overview#The_priority_screen

This topic is closed to new replies.

Advertisement