Archives for February 2017

February 18, 2017 - Comments Off on Mantra Rounded Edges shader

Mantra Rounded Edges shader

Here's my latest attempt at shader writing in Mantra. Using a white paper from MentalImages, I took the same concept and applied my own recipe. The shader adds micro fillets or rounded edges without changing the geo. Unfortunately Mantra has no access to specific geometry once it's started. So you can't call primatives or edges etc. So in this case you need to use a brute force Raytrace approach.

In short, for every pixel sample or rayhit from the eye/camera. Mantra traces 6 or more rays above the below the surface. Perpendicular is the key. The hits are weighted by distance and averaged. Hit normals are also collected and averaged. Then the normals are bent using the resulting solution.

As with anything there is a catch. Small bevels are fine, large ones start to become a bit more flaky, as you are not adding geo, so the effect is limiting a high radius. Also sharp corners of a cube are challenging. You get better results with more samples, but it slows the render down.


Any way, it was a fun exercise, and hopefully I can re-purpose the technique for other things.