Meaning I dont want the outer parts of my dungeon walls to be affected by light. Now I know this is posible if the object itslef is created with 2 materials that way I can make the back material solid black. But I was wondering if there is a easy way to achieve this with a shader.
I know of two main techniques to achieve this, which most games use with some variation between them:
1) Procedural or voxelized "filler" mesh.
- Model your walls as simple 1-sided "planes". By design, 1-sided surfaces can only be seen through one side, as faces with opposite normal are ignored in render. Optionally, but highly recommended, is making these in modular sections.
- Fill the space behind the walls with procedural meshing of some sort, either as "roof" (plane) along the top of the walls, or as solid.
- Depending on the look&feel you want to achieve, you can give this filler a solid opaque color (IE pitch black), or have it with a material similar to the walls, to "blend in".
2) Make your lighting work with the "wall" meshes and the procedural nature of the game by design.
- Make your "wall" meshes like in the first technique; meaning one-sided, and preferably modular.
- Don't use global illumination at all. Instead, make lighting be localized to the player, and/or enemies, and/or proceduraly-generated together with the walls, in pieces. Make it never be generated above the top of the walls. And make each light never exceed the "thickness" of it's own section (two corridors running side-by-side shouldn't "bleed" lighting to each-other).
- Profit. The game gives a "dark theme" to the spaces outside the walls by design.