How to make everything inside a 3D box visible and outside of 3D box invisible

Hmmm. If you want it to be a physical object visible in your scene with only a portion of it revealed, post-processing is not a great option.

Knowing what you’re doing, I’d recommend a material directly on the minimap mesh. Assuming you’re fine with actually invisible and not just black. Make it masked- we can still get the full benefits of transparency through dithering but without the performance overhead. Here’s a material that I threw together:

The result:




This is the effect with the opacity mask shoved into emissive just to show what’s happening.

The mesh moves so the visible part is always in the same location

Though this can’t be rotated with how it’s setup currently, it can be scaled.




To hook this up to the player, you have to first change the material to a dynamic one at runtime like so:

Next, update the parameters every frame. You can likely optimize this by only doing so if the minimap is in view and if the player has moved since last check, but I’ll leave that to you. This is how you can update the parameters:


Make sure the parameter names match exactly with what you’ve named the parameters in the material itself.

The “Get -1->1 progress in bounds” macro is a custom one that takes the position as well as the highest and lowest possible values. This should be the highest and lowest possible position (X,Y,Z ignoring the Z since it’s height). And this is the macro itself that uses said values:

2 Likes