#URP id buffer

1 messages · Page 1 of 1 (latest)

wide mica
#

You'd likely want to look into creating a custom renderer feature, to render these objects. I'm not sure there's much resources out there for it though. Might be a bit complicated, but I'll try to give some info/tips.

This might provide an example : https://gist.github.com/Cyanilux/d16dbfec869dbfb690426c837745679c
It doesn't use any IDs, basically just renders objects into a temporary buffer for masking a glitch effect I made. It's also a bit outdated, may want to look into switching RenderTargetHandle out for a newer RTHandle (which you'd generate using RenderingUtils.ReAllocateIfNeeded(ref temp, desc, name: "_TempTexture");, rather than the cmd.GetTemporaryRT).

I probably would store the ID in a property or vertex colours, rather than trying to use layers - as they aren't accessible in the shader. You could do a separate context.DrawRenderers for each layer but that's not very efficient.

The example code I have above uses overrideMaterial instead which would work if you store the ID in the Mesh.colors.
Otherwise can try changing it to overrideShader (new to 2022.2+ I think?) which works similar to the Replacement Shader for Built-in RP. That should allow properties to carry over from the shader it used before, so if both have an _ID property for example, that should allow you to set an id per material.

Would also want to change _TempGlitch to whatever global texture reference you want to sample in other shaders. And probably don't need the blit part either.

#

@velvet lintel (ping just to make sure you find/see this, not sure if creating a thread does that automatically)

velvet lintel
#

thanks, i will take a read of the code and see if i can understand it. These new pipelines are way more complicated than the old built in stuff 😦

velvet lintel
#

hmm maybe there is an easier way @wide mica is it possible to just have 2 depth textures but for specific layers rather than the whole scene

wide mica
velvet lintel
#

do you think that is what they are doing here for this vfx:

#

because they some how know the frags are after a object of a certain height from the main camera but with respect to the npc's view

#

im thinking two depth textures because i can get the world position from that

#

some one said stencil but i can't see how stencil works from the main camera's pov

wide mica
# velvet lintel do you think that is what they are doing here for this vfx:

The way I'd probably tackle something like this is a script calculating the appropriate field of view / line of sight meshes, similar to this : https://www.youtube.com/watch?v=rQG9aUWarwE (for green part, and an inverted version for the blue section you've circled)

In this miniseries (2 episodes) we create a system to detect which targets are in our unit's field of view. This is useful for stealth games and the like.

Source code + starting file:
https://github.com/SebLague/Field-of-View

Support the creation of more tutorials:
https://www.patreon.com/SebastianLague
https://www.paypal.me/SebastianLague

â–¶ Play video
#

It does look like the blue lined section is projecting onto the walls at the side though, so I'd probably say the line-of-sight meshes are more 3D and project onto objects similar to decals.

velvet lintel
#

i tried his method first but his method is using ray casts to change the mesh but that isn't very accurate without a lot of rays and is costly

#

my idea was depth texture from npc then clip where depth is before the npc's view mesh but with two depths i can change the alpha for waist height obstacles versus full on walls

wide mica
velvet lintel
#

yeah i know but shadow tactics use shaders as i have their source code they dont use the ray - mesh method like sebastian did

wide mica
#

You could also look into how shadowmapping for point lights work, that uses depth textures so might be a good reference.

velvet lintel
#

ive tried to find a good tutorial on shadow mapping but its all very low level since unity does it all for you that no one has covered the topic much =/

#

renderdoc shows them using stencil:

#

but i just don't see how that works for changing the alpha of the fragment

wide mica
#

With stencils you have a comparison function that discards fragments. That's why the line-of-sight effect isn't showing over certain objects (coloured white in this stencil buffer image)

#

That won't help with making it turn from green -> blue where an object is in the way though

velvet lintel
#

yeah but it also becomes fainter green after its behind the object unless its a full on wall in which case its occluded

#

how would they have done that 🤔

wide mica
#

I'm not sure, the only way I can think of is what I explained above with a script calculating line-of-sight meshes.