MatCap textures can very simplistically be described as an all-in-one shader condensed down to a single texture. They typically contain lighting and colour information. MatCap textures are applied to geometry using a UV map generated from a function of the object’s vertex (or pixel) normals and the direction of the camera. There are a number of pro’s and con’s to using MatCap textures:

Pro's

  • Cheap due to the simplicity of the shader and the texture can be small (typically less than 256px)
  • Quick to implement as the geometry doesn't require custom UVs
  • Textures are straightforward to generate

Con's

  • Lighting and reflections are not accurate
  • MatCap textures can look poor up-close unless a high resolution version is used
  • Doesn't work with rolling cameras (VR) due to the way UVs are generated
  • Do not work with flat geometry

The problem...

A while ago I thought about using MatCap textures in a VR project simply because they are a very cheap option that could run well even on the Meta Quest. What could go wrong?

Well, they just don’t play nicely with the HMD’s rolling camera. Because of the way the UVs are generated for the MatCap texture, any headroll results in the texture rotating to match the orientation of the HMD.

The solution...

I decided to create my own shader which would generate matcap UVs without factoring in camera roll. This was achieved by transforming the vertex normals by the XY direction from the camera to the object.

Conclusion

As the below video demonstrates, the VR matcap material function eliminates the problem of camera roll rotating the matcap UVs.