- Home /
Making windows using renderqueues?
Hi All!
I'm working on a building game that will involve dynamically placing windows in walls. The way I want it to work, the window object is placed in the walls, and allows the player to see straight through it. I've currently cobbled together a setup that changes the walls render queue to 3000 and the windows queue to 2999 (this allows the skybox to still be visible). However, a problem I quickly encountered was that looking through the window to a different wall will result in the other wall being invisible too.
Here's a screenshot of my struggle:
As you can see, the windows properly make sections of the walls see through, BUT it also makes the wall behind it invisible too! I've been banging my head on this for a while now to no avail. Does anyone have any suggestions on what I could do to make the wall behind the window render but not the wall the window is in? Any ideas would be greatly appreciated!
Here's the scripts I've been working with:
Wall Render Queue Changer:
[SerializeField]
protected int[] m_queues = new int[] { 3000 };
protected void Awake()
{
Material[] materials = GetComponent<Renderer>().materials;
for (int i = 0; i < materials.Length && i < m_queues.Length; ++i)
{
materials[i].renderQueue = m_queues[i];
}
}
Window shader:
SubShader{
Tags{ "Queue" = "Transparent-1" }
// Don't draw in the RGBA channels; just the depth buffer
ColorMask 0
ZWrite On
// Do nothing specific in the pass:
Pass{}
}