Hi,
I’m using a texture to draw grid lines for my strategy game. The material that uses the texture is placed on a large quad/plane object that spans the entire playable map. What I would like to do, is when a colored quad (or similar) moves over the grid, I would like the quads color to be draw to the gridlines that overlap the quad. See the attached image to explain what I’m trying to achieve (I’ve labelled it ‘final result’). I’ve also attached a screenshot from the game Galactic Civilization 3 which is what I’m ultimately trying to achieve with this effect.
I have been trying to use a shader with a stencil buffer to do this (in Shader Forge asset). I can’t seem to get it working (I’m not sure I’m even approaching this the right way). I basically want to only draw the gridlines to the stencill buffer, but the shader seems to write both the white gridlines and the black infill sections, so when the quad moves over, everything gets colored within the quads overlapping area.
So my questions are:
- How do I only write the white gridlines to the stencil buffer, and not the black infill sections?
- Is the stencil buffer approach the correct way to approach this problem?
- Can anyone suggest a way to achieve what I’m trying to do?
Thanks guys.
Aaron.

