This is part of 'Lustrous Learnings', a series of posts about Lustrous Spirit which is a game I've spent the last four years making. Lustrous Learnings focuses on game development concepts I've stumbled into which aren't often discussed.
Reflections
Reflections in games kinda suck ass. If you've ever dealt with reflection probes, jank screen space reflections, or ugly specular highlights, you probably agree. They're one of those phenomena that involve light rays bouncing around which is just too difficult to simulate, so we come up with hacky solutions instead. Anyway, I am here to propose some more hacky solutions.
Reflections can be quite pretty and eye-catching, but they can also be distracting. Reflections can tell us how rough or smooth something is, whether it's wet or dry, clean or dirty. They're pretty important! What if we could control how they look?
There are a lotta things that determine how highlights look, and whether they'll appear. Basically for you to see a highlight, light has to come from a light source, bounch off of some object (or objects), and then hit your eye. This means that the appearance of highlights depends on:
a) the position of the light source(s)
b) the geometry of whatever object the light is bouncing off of
c) the position of the player camera
These factors have to align for a highlight to appear at all. Then there are factors in the reflecting object's material that also affect the appearance of the reflection. Roughness scatters light effectively blurring highlights, with smooth materials having small & concentrated highlights and rougher ones having large soft highlights. Metallicness concentrates reflections even more, allowing for mirrorlike reflections at low roughness.
So yeah there are a lot of factors at play when it comes to reflections. Any one of these changing seriously affects a reflection. So if you want a reflection to look a certain way, you have to change other things in the scene that you might not necessarily want to change. In this post I'd like to talk about how to create beautiful fake reflections that you can control more directly without having to change your lighting n stuff.
clickbaity image here lmao jk just put some cool art idk
Reflection textures
Basically we're gonna fake our reflections through the shader and its emissive output. This means that our fake reflections will be emitting extra light that comes from nowhere (not realistic) but really who cares. It feels real.
The key to fake reflections is the reflection vector - this is the direction that a ray fired from the camera's view would bounce off once it hits some geometry. The reflection vector is pretty easy to calculate include link/image of how to calculate here and might be available by default as a node in some game/render engines.
Take the reflection vector, and use it to drive the UV coordinates for some texture in your shader. Since the reflection vector has three dimensions (a reflection can bounce in the x, y, or z direction) and UV coords are 2 dimensional you'll need to throw away one of the reflection channels. i am not sure which is best, should do a lil research. Then watch as your reflection texture warps around objects like an actual reflection!
There are a lotta things you can do with reflection-driven textures, but right now we're mostly going to see how they can fake highlights by feeding them into the emissive output.
Super shiny metal
In my game Lustrous Spirit I've put fake reflections to good use. One of the simplest applications of fake reflections is making metal appear shiny regardless of lighting conditions. This helped some mercury puddles which I recently added stand out.
Anyone who's practiced drawing metal knows you gotta include some nice reflections in order to make it look metallic. this hack ensures that your metals always look very shiny and sexy. hell yeah.
Basically just take any texture you like, drive its UVs with the reflection vector, and output it through the emissive channel of your metallic material. For metals in particular it's nice to use fake reflections using cubemap textures since metals actually reflect a lot more clearly what's around them instead of just a specular highlight. You can also use all 3 x/y/z channels from the reflection vector which looks nice.
This method of faking reflections is similar to baking reflection probes with some pros and cons.
Pros:
- You don't have to go through the process of baking and then re-baking your reflections
- You have lots of control over the color, brightness, and general appearance of the reflections
Cons:
- Your objects will not reflect the actual scene around them
Basically you can use this technique to make your metals look shinier, although it won't help you accurately reflect the surrounding environment.
Below is the setup for my shiny mercury, where I drive the fake reflections using a random sky cubemap + recolor them based on the ambient light color - a technique you can read more about here.
bla bla images go here
Roughness and normals in your fake reflections
Fake depth, refraction, and holographics - slowing your highlights down
ok chat. what are we doin here?
driving textures using reflection vector + emissive
showing how fake reflections can be used
holographics using reflection vector
slowing down reflection movement by LERPing with normal
how to make em look nice
how i use reflections in lustrous spirit
using normal maps w/ reflection vector
x