Jump to content
  • Advertisement
Sign in to follow this  
vexe

Resident Evil 2 "Color masks"?

This topic is 1122 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)

Edited by vexe

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!