#Draw grid only on top of game objects in a specific layer (3D)

1 messages · Page 1 of 1 (latest)

wind rampart
#

I am working on a 3D level editor. For the grid visualization, I have created a Grid shadergraph.
To further help with visualizing where the player can actually build things, I want to restrict the Grid shader to only render the Grid if there is an object within the "Floor" layer below it. There are two GameObjects within this layer: The "blueprint" plane, which represents the total potential build area, and "floor objects" which the player can place in the scene.
I won't implement it in this milestone, but I eventually want to implement multiple levels, so you can eventually place floors on top of other floors (and leave gaps in between), so I can't just only render the grid when there is a raycast hit from the camera to a floor object with the grid rendering plane in between.
The grid currently is being rendered using a GridStencilWrapper, and the URPipeline Renderer has a custom render feature called "StencilWriteFloor", which I have also added in the screenshots. If you guys wanna see the shader classes, I'll add them as well, but you can only write so many characters in this.
No matter what I do however, the stencil does not seem to be working and the grid continues to be rendered in its entirety (as seen in the second screenshot; you should only see the grid lines on top of the light gray "floor" tiles). What is my issue here outside of a skill one? I'm honestly at my wit's end.

tight dust
#

Stencils should work but they would render through the walls too if they are on the same layer

#

Otherwise you could try world UVs and a specific shader you would apply on top (second pass) that only draw where a normal points up and stuff like that