Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UE5 Opaque Interior Mapping Shader

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 View (Night scenario with procedural window occupancy and randomized lighting)

Day View (Day scenario showing simulated reflections on opaque geometry)

⚡ Key Features

  • Opaque Optimization: Fully functional on Opaque material 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=1 and Mip-Maps.
  • Procedural Randomization: Features a Triple-Hash algorithm that generates deterministic randomness for:
    1. Light Toggle (On/Off)
    2. Interior Color Temperature (Warm/Cool)
    3. Intensity Variation
  • Correct Perspective: Solves the "pancake room" effect by calculating View Vector in Local Space with depth correction.

🛠 Technical Breakdown

1. The Algorithm

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

2. Solving Artifacts (The "Stripe" Fix)

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));

3. Mip-Map & Reflection Handling

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.

About

Interior mapping in HLSL — faked building interiors from a single shader pass.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages