Is it possible in current Shader Graph state to create a shader, that would highlight intersecting geometry?
To elaborate: the shader would go on a sphere, and would highlight any surface it touches.
It can use either the mesh of the sphere itself, or a SphereMask.
I’ve tried everything, but can’t seem to get anywhere close.
@nikefootbag Thank you for replying!
Sadly both of the solutions are a bit different still. First one uses the position of the sphere inside the shader, which means, I must have all shaders in my scene have that logic, which is not ideal.
What I’m looking is sort of an omnidirectional decal. The object that projects color/image to any surface, not just the ones with built-in logic.
@romanpapush ah I see, goodluck in finding a solution!
I just realised I follow you on youtube and twitter, your tutorials are great (and also real funny), keep it up!
Hello! Which SRP are you using? Also, would it always be on a sphere or other simple mesh?
So long as you have access to scene depth (deffered or forward rendering with the flag checked for depth buffer) and are doing simple shapes I can think of a few ways to achieve this.
Unfortunately that would not be as simple to implement, as the reason the shader works is it’s checking the distance in the depth buffer from the center of the sphere in order to know where to draw.
Kind of on a similar vein, how would one go about making something like this in Shader Graph? I’ve been struggling with it. It’s essentially a decal shader for URP, would be nice to be able to hook something up like this for shader graph so you can tweak and do scrolling effects and such.
@LandonTownsend Thank you so much for your answer, this is exactly what I was looking and it is working wonderfully!
But I can’t seem to make it work with transparent objects as well. I’ve tried writing them to the depth buffer through Renderer Features, but with no luck. Can it be achieved with the current setup?
Once again, a million thanks for the shader graph solution you posted above
Hi! I’ve actually resorted to rendering another material with a spherical mask on top of my objects using URP’s Renderer Features material override. Did the trick for my case. Cheers!
Just use the shader above and the method you described.
But the problem with this is that whenever the camera position changes, the overlap of the stationary red sphere is not constant.
In my opinion, this method prioritizes the rendering order (zbuffer) of objects with a specific layer in the camera.
I don’t think this has anything to do with the surface changing whenever the camera position changes, isn’t it?
Have you checked your “Depth > Write depth” checkbox settings on your sphere vs the rest of the objects in your Render Objects Renderer Feature?
And if you’re using newer versions of Shader Graph there’s a Depth Test setting in Graph Settings you might want to check also for your shaders.
I don’t know how your scene is set up, but to a lesser extent double check if you’re excluding layers from Filtering setting (in Universal Render Data) which you are manually rendering with Render Objects feature. Also changing the event to, say, “AfterRenderingSkyBox”, might solve the issue if your objects are using transparent materials and being rendered after the highlight object.