A high-performance HLSL implementation of Interior Mapping for Unreal Engine 5. Designed to simulate volumetric 3D interiors on flat surfaces using Opaque Materials, avoiding the heavy rendering cost of Translucency.
Perfect for skyscrapers and large-scale city environments.
(Night scenario with procedural window occupancy and randomized lighting)
(Day scenario showing simulated reflections on opaque geometry)
- Opaque Optimization: Fully functional on
Opaquematerial domains using Emissive simulation. Zero overdraw cost compared to Translucent glass. - Singularity Protection (v8): Custom Ray-Box intersection logic with a bias fix (
1e-6) to prevent "horizon line" artifacts and division-by-zero errors at glancing angles. - Fake Reflections: Implements a Fresnel-based reflection layer directly in the shader to simulate glass properties without artifacts associated with
Metallic=1and Mip-Maps. - Procedural Randomization: Features a Triple-Hash algorithm that generates deterministic randomness for:
- Light Toggle (On/Off)
- Interior Color Temperature (Warm/Cool)
- Intensity Variation
- Correct Perspective: Solves the "pancake room" effect by calculating View Vector in Local Space with depth correction.
The shader performs Ray Marching in Tangent/Local space to find the intersection point within a unit cube [0,1].
Unlike standard implementations, this version calculates the view vector manually from AbsoluteWorldPosition to ensure stability across different mesh scales:
// Stability Fix: Calculating View Vector in Local Space float3 V = normalize(PixPos - CamPos); float3 dir = V; dir.x /= max(0.01, RoomDepth); // Depth correction
Standard interior mapping often breaks when the camera view is parallel to the floor/ceiling. I implemented a robust inverse direction calculation: code Hlsl // Singularity Protection float3 invDir = 1.0 / (sign(dir) * max(abs(dir), 1e-6));
To avoid texture bleeding at the edges of the "room" (where UVs jump from 0 to 1), the material graph utilizes explicit Mip-Level control (MipValueMode: Level -> 0). Reflections are simulated via Emissive Injection controlled by Fresnel, allowing for deep interiors that vanish into reflections at oblique angles.