Day/Night Texture Baking - Material Mask Reveal

I have a pretty cool question… Is there a setup or way that I can take two baked (Day/Night) textures and have one reveal the other? For instance, it is nighttime in the first bake and I want the daytime texture bake to reveal itself in the direction Im facing with a flashlight. Mind you, the daytime texture is only revealed where the flashlight is being projected off in the distance and hitting that surface. It seems possible given the fact that mask are used to reveal, hide or override a texture with another texture or “Layer”. But then again, I really couldnt find the best way to ask this question. Thanks in advance!

It’s not technically impossible but the engine doesn’t have a way of doing it by default. Currently you can only build one set of lightmaps for a map, and there’s no easy way to use multiple sets. Getting day/night lightmaps aren’t the only challenge in what you want to do, but it’s the first step.

This would be easy enough for a generic day/night cycling map, because you could easily drive the lerp for everything via blueprint, and using a material parameter collection to pass in the light vector. See the BP_SkySphere in the engine folder for an example as to how this is done. But for having a flash light reveal daytime textures… that will be very hard.

You’ll have to do a LOT of the Math in a blueprint, then pass that to the material editor as part of the Pixel Shader. The only way I can think of doing it is tracing a cone from the light source out into the world, then calculating where that cone intersects with geometry somehow. For each object it hits you’ll have to procedurally generate a mask based on the intersections and send that to the shader. You won’t be able to do any per-pixel operations in Blueprint without some pretty extensive C++ code, so you’ll have to create a lot of LUT’s. The downside of this is, it’ll perform like **** because you’ll be doing a render-to-texture for every object your light touches, and performance will depend on how many objects you’re hitting.

Another way perhaps, would be to generate a mathematical cone-shape in the materials themselves, and rotate/move that cone in world-space to follow the flashlights location, again passed in through blueprint. Still relatively expensive I imagine, but probably easier and safer to implement than the other method. Either way this isn’t an easy task, you if you’re new to either of the tools or technical art in general it’ll be a struggle!