Exploring SculptrVR’s efficient lighting solution for the Oculus Quest

The simple default lit shader that just takes a color and drags it into Base Color is hundreds of operations. Even with “fully rough” checked, a default lit Material can only afford to render about 50,000 triangles on screen on the Quest. This was not enough to get a good experience sculpting.
So, instead of using the default UE4 lighting, I built my own phong lighting by using unlit Emissive Materials. This Material looks expensive, but is only 17 operations.

Let’s go through what’s happening here:
First, notice that three different Material types are supported: clay, metal, and glowing. Clay is emulating a fully rough Material, metal is shiny and reflective, and glowing is clay plus a constant glow amount. The Material type is encoded in the 8-bit ambient channel of each vertex color.
The world is lit by a single directional light and an ambient skybox (the skybox in SculptrVR is actually using the same ambient section code, but with slightly different constants). I am using Blinn-Phong lighting to get diffuse lighting with a specular highlight, and to that I’m adding ambient light from the analytical skybox.
The result of this gets multiplied by a vertex color and a per-vertex ambient occlusion (AO) term. The AO term is computed on the CPU for each vertex using a custom variant of voxel cone tracing.
Let’s go through each of the lighting components:
Diffuse:

Specular:

Ambient:

Emissive:

Total Lighting:

Adjusting the Parameters for a Dynamic Sky
The Sun Position, Sun Color, Zenith Color, Horizon Color, and Ground Color are all dynamically changed as you move around the sun as seen below The colors are all stored in curve tables based purely on the z-component of the sun’s direction. Those tables were hand tuned to provide good brightness and contrast with SculptrVR’s color palette.
In SculptrVR, every single Material is emissive and uses this Material function to multiply in lighting. Some Materials/models use vertex colors, some are textured, but they all get consistent lighting.
I hope you found this useful and can either make use of it directly or make your own variant with this as a starting point. Thanks for reading.