Friday 23 July 2021

Max Payne - two decades later - Graphics Critique

 


It has been two decades since the video game Max Payne was release on July 23, 2001.  The game itself was some incredible homage to The Matrix and Detective Film Noire but in this article we are only going to examine the graphics. The rendering present in the game was phenomenal for its time and as such received multiple graphics awards.  To understand the what the developers achieve and could have been achieved we have to first understand the PC computing landscape 20 years ago**.


2001 


Max Payne was released targeting directx 8.0 with specs of 450 Mhz cpu (singular) and 16 Mb graphics card. Two put this in perspective that is roughly three orders of magnitude less GPU memory than a modern RTX 2080. The DirectX 8.0 graphics API at least has pixel and vertex shaders but the spec had extreme limitations on caps like number of instructions.  The 450 Mhz cpu is more than two orders of magnitude slower than a modern PC cpu today.

So with this perspective in mind we can probably conclude** that the rendering will be limited to:

  • Forward only rendering (no render-to-texture) 

  • No dynamic shadows 

  • Very low resolution textures 

  • Hundreds of polys on screen


So with these severe limitations how was such realism and fidelity possible? The answer is an amazing technical synergy of rendering smoke and mirrors.  Most of these techniques could be summarized as tricking the human visual perception into thinking complex rendering computations are being done live in realtime when they are actually have been precalculated. The next sections will examine in detail each technique and how they contribute to the total graphical experience.

Particle Effects

The particle effects of this game are its best graphical feature. For a game that involves slowmo matrix style fighting with bullets and other mildly destructive weaponry this investment and care certainly pays off.  Similar games of this time do not even come close to the effect fidelity found in this title**.


A bullet hitting a wall in slowmo. Bullet with vapor trail impacts wall. Decal is then created for the crack. Immediately a puff of several white smoke particles appear  along with a handful of chip particles. These chip particles are actually flip flipbook animated textures with far less geometric detail than is indicated by what appears to be rotating complex chunks.


Smoking cigarettes in ashtray. While a coarse grained effect these each ring is only one quad with an animated texture to simulate evolution. This effect is slightly overdone and is not entirely realistic.


Bullet hits steam gas pipe in slowmo. First is spark impact of bullet going through steel with two types of spark particles. Again what looks like many sparks in the shape of a star is likely just one single quad with an animated flipbook texture. Note the long lasting leaking steam trail with hints of geometric complexity added as texture that simulates turbulent flow. This complexity is all fake as there is no such fluid simulation occurring**.

Destruction of computer monitor via bullet. First there is a large bright apparent explosion. This looks like 3-4 fireball quads with color animations moving from white to dark red. There is also a dynamic light (vertex lighting) that brightens the entire space at the moment of destruction. The electric sparking animation hints at a short circuit both during and after the destruction. 


Bullets fired into glass until glass breaks with fragments on floor. The bullet hole impact on the glass is simply a decal but fragment ejection is clearly multiple independent particles. The broken glass falling is a flipbook animation with a delayed glass decal for the floor. The falling animation is repeated in reverse for the bouncing glass shards.  


Bottle explodes due to bullet impact. The glass fragments are simply particle quads with a flipbook animation to give the appearance of tumbling reflecting pieces. A nice touch is the fluid droplets exploding and dissipating. A fake wet-patch decal is unfortunately absent. 


Highly realistic candle flame effect. There is an lack of overall lighting flicker but this is likely due to limitations in either light count or baked light map. 


Launched grenade exposing. This is very similar to the effect with the monitor if one replaces the electric effect with the grey fragments present here. The hovering black dust cloud is an effect that dissipates over a few seconds. The grey fragments show geometric complexity via a texture that is obviously not present in a single quad.


General Criticism

While obviously phenomenal these effects could still be improved upon**.

  • The larger particle quads clip the ground in a visual unpleasant and unrealistic fashion. Soft clipping is normally implemented by reading the depth buffer which is not possible here. It might be possible to achieve soft clipping by CPU side manipulation of the particle quads that clip the ground plane. It might also be possible to do a ground plane representation in the pixel/vertex shader such that near plane quads fade out completely before touching the ground surface.
  • The particles do not interact with the environment at all. This is pretty common for particle systems in general. However there are situations where a few of these particles could have benefitted from a simple path trace of the static geometry. Given that the game is all about tracing bullets through the air this was definitely possible. There would be a limit on how many particles could do this but that could depend the dynamic scenario.
  • Finally the timing for decals to appear and the manner in which they appear is slightly offset from what is correct. This could be due to frame latencies in the engine itself but considering the excessive usage of slowmo in the title some timing cleanup would be beneficial.


Lighting

Max Payne used prebaked lightmaps for static geometry.  This means static geometry has an entirely separate texture layer that corresponds to the sum incoming irradiance.  The reason why this is separate and not simply baked into the texture of static objects is because the high resolution albedo textures are reused everywhere in a scene. Each usage may have a different lighting condition which means they need to correspond to different parts of a texture.  Since the light map uniquely covers the entire visible scene the texel density is quite low.  It should also be noted that for Max Payne this appears to only be a light map and apparently not a Radiosity map with indirect reflections**.

Light mapping shadow from shower wall. The low density results in very soft shadows and unfortunately light leaking and lack of proper contact shadows. Future rendering techniques would resolve these issues with capabilities not available in 2001. 




The soft lighting from the softdrink machine does not generate any shadows for dynamic props (like this shotgun).  Dynamic shadow maps are probably out of the question and so are modern screen space AO techniques. However it was still possible that a contact blob decal could have been used. This would have required quite a bit of effort given the anisotropic nature of this object but would still have been possible. 





Fantastic use of lightmaps to simulation emissive luminance of a monitor. 


Striations of bilinear filtering are visible here for two reasons. One the local intrinsic informational density exceeds the Nyquist limit (aka the shadow map texture is too low res). And second the wall texture does not cover or obscure these striations as it is made up of only high frequency bumps. 


Detail textures

Detail textures modulate the albedo of surface to simulate micro surface features that cannot be represented in the texture due to strict memory constraints. They are simply a way to realize high resolution textures without an overhead that would be unacceptable circa 2001. These textures do not have any color information and are usually represented with a single 8 bit 'red' channel. 





General Criticism 

This is a great technique and was used in games before 2001. Its usage here is a bit inconsistent with some surfaces having no detail textures and others having clearly the wrong detail texture applied to the surface. It is not clear how this could be improved without increased polygons and increased number detail textures.


Fake Geometry

Modern AAA games use high quality polygonal models to represent 3D object details.  Even in the case of surface (2D) detail the complexity is represented with heightfields or bump maps so the surface can react correctly to different lighting conditions.  In 2001 both of these techniques were simply not feasible for this title.  In Max Payne both surface and 3D details are baked directly into the albedo texture of the object.  Baking this information directly into the albedo texture is perfectly correct for a single perspective.  The trick is doing this in a way that it looks acceptable for the all the perspectives that are common.  


This looks like a highly detailed object



Note this is not prebaked into the shadow map. This shadow is prebaked into the albedo of the texture itself. 


A closeup of a candlestick holder with lit candles. The image suggests detailed geometry



The actual geometry of this candlestick holder is a flat polygon. The the simulated geometry is simply a texture with an alpha threshold.  Not the perspectives show in this screenshot are captured by free camera and cannot be viewed like this in the normal game. 

Note the prebaked doorknob shadow might be passible but the wood detail texture ruins the effect. There is also a complete absence of any shadowmap on the toilet which causes it to appear to float without contacting the floor.


Same as with the others, the hanging towels are simply a texture with alpha transparency on top of a single polygon. 






This technique used here is borderline experimental.


This scene probably has fewer than 50 triangles in the camera frustum.

General Criticism


This technique works very well in most circumstances but really could have been supplemented by a proper Level of Detail (LOD) system. Even a simple system that added a few parallax semi transparent planes would at least contribute some depth to these geometries. 



Fake Reflections

This section is nearly identical to the previous section on fake geometry but with a specific focus on reflections and specular highlights. Max Payne has no environment maps. Even it could afford an environment map texture sample the game also has no normal maps. To prevent the game from looking like a Lambertian alternative dimension the reflections and highlights were also tastefully baked directly into the albedo texture. This technique is quite hit or miss as in reality specular highlights are highly view dependent. (Reflection map is an old term and a more modern term might be something like incoming irradiance)


An example of where baked reflections tend to shine. The highlights suggest a reflection to the light but in reality this texture is used on the seats in the dark background as well. Without the shadow map to dim these highlights this technique would be quite off-putting and noticeably inaccurate. 

The gun on the ground lacks any kind of lighting and as such the metal reflections dont seem linked in any way to the environment. A simple planar AO technique would help the human visual system perceive this as an object in contact with the ground.  This technique could have been done at the vertex lighting level or as a constant in the pixel shader.




Note its not just fixtures that have baked highlights but the walls and the molding.





General Criticism

As with other techniques in this game the primary issue here is consistency. Many of the objects have great baked specular highlights but they do not fit quite right with the rest objects in the scene. A bit more effort in terms of technical artistry was required to make the specular reflections fit perfectly with each unique usage of the object or texture. Care needs to be taken in the approach as many older titles perfected this technique by unfortunately creating repetitive chunks of common geometry.


Tricks

This section just contains a menagerie of different techniques that contribute to an overall impression of increased rendering fidelity.

Bullet impact causes painting to fall to the floor. This trick is purely a one-off hand-crafted as there is no real generic physics engine in the game. 


Max Payne character leaving footprints in the snow. This trick is extremely simple it just adds a decal to the plane below the feet of the main character at a specific keyframe in animation. While subtle it does at least add some dynamism to what can be a rather static world.



Dynamic Ambient Occlusion blob for character feet. These blobs help ground the character and tells the user how close each foot is to the ground. These AO blobs are implemented as something akin to a dynamic decal with low frequency alpha modulation.


Ambient Occlusion drop blob. Asymmetry in placement suggests that this blob is not well aligned with actual animation foot data.




The clock in the station actually ticks.



Geometric reflection trick to produce planar reflective surfaces. Here the static geometry is replicated beneath a semitransparent floor. The duplicated geometry is mathematically reflected in the plane. The result is an apparent planar reflection that one might see in a raytrace. This rendering trick is quite cheap despite partial replication of geometry. 



This reflection trick is not applied the npc characters. This could be in order to reduce polycount or limitations in the vertex shader. It could also not have been done for purely aesthetic reasons.



General Criticism

Although not covered here specifically the general outline of the decals in the game look quite poor specifically when they involve opacity. It would have been nicer to see crisper outlines on things like graffiti or a different art style to blend them into the walls. In terms of the planar reflection trick, it would have been nice to see this trick used in a few more situations throughout the game. Specifically, there are a handful of mirrors in the game. Simple planar reflections in these cases would have made for a more dynamic rendering impression.


Scenes

In this final section we shall look at a screenshots from a few key scenes to get a sense of how all these techniques come together to produce a single compelling image.











Conclusion

With a larger investment and perhaps different technical choices Max Payne could possibly have looked even better than it did in 2001. However the graphical result produced at that time was still far and away better than other titles in this period. The rendering quality of this game was not seen in other titles for several years. This game stands as a remarkable technical accomplishment and a significant entry in the history of progression in realtime rendering. 




* All screenshots of all games were taken by the author and are presented here for the intent purpose of review and criticism (technical and aesthetic)

** All 'claims' here are in the form of opinions made based on the author's industry experience and not on detailed inspection of source code or on secret non-public knowledge

Highlighted references: 

https://en.wikipedia.org/wiki/Max_Payne_(video_game)

https://store.steampowered.com/app/12140/Max_Payne/

https://www.nvidia.com/en-us/geforce/graphics-cards/rtx-2080/

https://hardwaresecrets.com/directx-versions/

https://cdn.cloudflare.steamstatic.com/apps/valve/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf

https://developer.valvesoftware.com/wiki/$detail

https://learnopengl.com/Advanced-OpenGL/Cubemaps

https://en.wikipedia.org/wiki/Lambertian_reflectance

Wednesday 13 February 2019

Visual progress report 2: on Bulk Triangle Dynamics, a Lagrangian Finite Element Method Approach


Simple Wheeled Cart Scene demonstrates the new multi-layer feature. Elements live only in a single layer but vertices can connect across layers. This enables the effective simulation of many complex mechanical systems. For our scene; a two dimensional wheel requires an axle connection from an independent layer.

Per element material is also critical for this Cart demonstration . The wheel treading is a soft but non-plastic high friction material which contrasts the axle and inner wheel's hard and low friction material.


Simple Cart and slope: View switches from material view to connective view for the two layers present.
















Plastic Cart and Steep Slope: Materials for the cart and wheel and cargo all have low plastic yield strength. Thus they deform on a high velocity impact with the wall on the right.

Monday 21 January 2019

Visual progress report on Bulk Triangle Dynamics, a Finite Element Method approach





Mechanical one way latch. Toothed pendulum swings one way but when it swings the other way the latch kicks in and prevents further motion. 



Grid of solid circles of the same material. Material is has a high degree of restitution energy dissipation as well as a high surface friction coefficient. 



Early scene to prove out possible toothed gear simulation. Effective force propagates from the toothed pendulum to the final gear.  Moderate gear play and latency is observed.



Materials impacted with solid hard circle. Materials all have the same young's modulus but different von mises energy criteria for plastic deformation.    In the "deviatoric energy" view one can see the max deviatoric energy reached in each scenario.






Early example of material variation. Here only the youngs' modulus of the material varies for each of the tubes. (multicolor triangle view shows underlying simulation triangle description)





Triangle connectivity view for scene involving the falling of a rubberized rope.  Surface contact is dynamically updated and can easily be seen between rope folds.




























Early test involving a tube rolling down an incline with gravity. This view shows us the darker connective triangles and the lighter solid object triangles interacting at various surfaces



Simple bearing simulation.This scenario demonstrates the robust nature of  continuous contact FEM.