Interior mapping implementation in Unity. The projects features an object space interior mapping shader, with some additional features detailed below. The implementation uses the technique explained in this document.
The basic interior mapping works on objects with the same scale on x and z axis, such as a cube, but that can be scaled on the y axis. Objects with a different scale on x and z axis will technically work, but the shader will use the same values for both axis, which can make one of them look stretched. The Unity's native cube has one of its face with inverted UV y axis, so the project includes a simple script that generates a mesh with a UV mapping fitting the mapping.
The walls can handle any number of rooms, whether it's even or odd, or different for the width and height. The roof will work fine only when the same value is used.
Walls texturing works with a sprite sheet (imported as a 2DArray). The shaders randomly samples a texture from the sheet and applies it to walls. Same goes for floors and ceilings.
Windows are textures that are applied to the mesh faces, scaling the UV using the desired rooms count. Windows may be transparent textures, so they require a mask to know where the glass is: when displaying the window, if the sampled pixel is transparent, then the mask is checked: if it's the glass part of the window, then the room interior is drawn, else, the outside wall is drawn instead.
Windows are discarded on roof, and can also be discarded on how many floors as desired, starting from the bottom one.
Shutters can be added to windows. Shutters can either be fully closed using a slider to control the amount of shutters that should be closed, or they can close gradually, using another slider to control the closing percentage across the object. Both sliders can work together.
For rooms with shutters closing gradually, when the shutter is getting fully closed, the rooms gets darker.
Rooms interior can be lit using a given color. This color is HDR, meaning the color can work well with bloom effects. The amount of rooms with lighting is controled by a slider.
Interior lighting works fine with shutters, although rooms that are lit will not get darker according the their shutters opening state (this can be changed if needed, it's been implemented like so as I found this visually more pleasing).
Window glasses can be tinted, and a fake refraction effect can be applied on window glasses. The effect simply offsets the interior mapping raycast randomly for each pixel, which makes the effect very noisy, but working pretty fine with a small refraction intensity.





