My blog post about reflective materials in Block Game is out now! Read all about how I abused matcaps to make dirt cheap reflective materials with reflections that'll run on a potato

enikofox.com/posts/reflective-

Note! Any public or quiet public/unlisted replies to this toot will be shown as comments on the blog. If you don't want that please use followers only or private mention when replying

Reflective materials in Block Game

Over the holidays I implemented a system for reflective materials in Block Game. Here I’ll go over roughly how it works. I originally intended for this post to be a deep dive, but then I realized that the nitty gritty on this one just isn’t that interesting. Or at least, I’m just not that interested in doing a deep dive on it so this one will stay fairly high level.Anyway, it all started when I got introduced to matcaps over on Mastodon. Matcaps are a neat way to add texture to a model without texturing it. You obtain, via photograph, 3D render, or even freehand painting, a spherical map of a material. Then, you apply it to an object by sampling the sphere based on where the normal is pointing using the view space x and y coordinates. And that, I thought, was pretty rad.Matcap example from the matcaps library github.com/nidorx/matcapsThis works because when you look at an object in view space, none of the normals will be pointing away. They’ll either be pointing sideways or nominally at the camera. So half a sphere is all you need.And I thought to myself: hey, I’ve used the spherize filter in Photoshop to make spheres out of squares. And I also thought to myself: hey, if I flip the camera around and render the scene with a high field of view into a square texture, then I could spherize that and use it as a matcap for reflective materials!Is this the right way to do reflective materials? Absolutely not. Does it work? Yes, sometimes very well and occasionally not so good.

enikofox.com · Eniko does bad things to code

0
0
0

If you have a fediverse account, you can quote this note from your own instance. Search https://mastodon.gamedev.place/users/eniko/statuses/115939236388295786 on your instance and quote it. (Note that quoting is not supported in Mastodon.)