Right now i’m trying to get better results with reflections for my archviz scene, and the best i did was using a scene capture cube into a reflection vector, but it still isn’t perfect. The last thing i need to make it better is to offset the reflection to match with the surroundings. The first print is the result, the second is the simplified material i used first and the fird is what i tried to do to make the offset work but it didn’t.
Feel free to give other solutions to make better reflections. I also tried using box/sphere reflection captures, planar reflections and interior cubemap, but for now this is the best solution i found.
Cubemaps will never match perfectly unless the player camera is in the exact same spot as the capture was.
“Parallax corrected cubemaps” are a concept that is meant to reduce the perception of the issues by fixing the reflections in space (often a bounding box or sphere) rather than projecting them to infinity but there will still be mismatches. Ultimately this is why raytracing is so important.
Like i said before, i tried using interior cubemap to get the parallax efect but it didn’t work in my case. The main reasons are: i’m using this to get a reflection and the room inside the mirror doesn’t get inverted; i can’t figure out how to offset this projection inside the mirror, i can scale it but its center is not in the center of the mirror.
The interior cubemap node is for a a completely different purpose (faking interior spaces through building windows) and is not meant for parallax correcting reflections. There is a built in node (I think called distance limited reflections) that parallax corrects to a sphere, but even that won’t look perfect.
Perspective correct mirror reflections on mobile are not really feasible without raytracing and thus not considered possible on mobile - although very creative shader tricks could improve things.
Your best bet is probably an axis aligned bounding box to project the cubemap onto. You can even combine multiple boxes to form more complex shapes. This is how Half Life Alyx did their parallax corrected cubemaps.
I went ahead and made an example of an axis aligned bounding box parallax correction example in case the “Distance Limited Reflections” node isn’t good enough for you. (It wasn’t for me, either)
float ffd = max(tMin.x, max(tMin.y, tMin.z)); // Front face distance
float bfd = min(tMax.x, min(tMax.y, tMax.z)); // Back face distance
// Check if the ray hits the box within a valid range
if (ffd <= bfd && bfd >= 0.0)
{
return (ffd > 0) ? bfd : ffd; // Return second intersection distance
}
return -1.0; // No intersection
The custom node basically mathematically defines a fake cube (in world space), and in this case, returns a depth value to its inner surfaces, which allows us to easily calculate the world position of this imaginary box. This then allows you to project a cubemap back into this fake 3d space, giving it parallax. You can see I simply mirrored the X and Y here to imitate a reflection.
Well, i tried this material and in the preview it works just fine but when i assign it to the mirror it stops working.
I don’t know if i messed up in the material or it is something that i’m missing completely.
The box min and box max are world space coordinates. They represent the corners of a cube in world space. You’ll want it to set it to a size and position that roughly encompass the room in world space (world position where it would be in the mirror, not of the actual room in unmirrored space). I just used 125 in the example, because that is slightly smaller than the default material cube.
I was messing arround with each value of this box min and max but neither of them changed the reflection that appeared on the mirror on the print before.
Imagine the mirror in your scene is a portal to another dimension with a duplicate of your room. The box min and box max should be set to the bounding corners of this imaginary room in real world space.
So you will need to take note of how large the room is and where it is in space to accurately position and size the box min and max. It can not look correct in the material editor once it is in the right position for the real scene. This is because it is in world space and the material cube is not in the same world position as your scene/room.
Consider temporarily assigning the material to a giant cube to make it easier to position. In the example, the cube would be at the center of the world and be 250x250x250. Your room is probably not in this spot, nor this size. So you must adjust it properly to see the desired effect.