I want to make a material that, when applied to a model, will only render a flat-color cross section of the model as it intersects with other geometry.
After a while. If U r only interested in intersection and not hidden areas U can use just depthfade node and then invert it. U will get nice gradient along collisions.
I looked through the tutorials and they don’t really get into any depth as far as the implementation goes, which is what I’m still trying to learn.
I suppose a way I could accomplish it would be to do two render passes, one where the object renders normally, and one where the object renders only when occluded. Then take the two render passes and cull everything other than where they intersect. Though like I said, I’m not familiar enough with shader creation to know what I’d need to be able to do this.
hey bud, no need to set up multiple render passes for this.
Depending on your primitives - ie if it’s just a sphere or box you need - it’s fairly simple to do in a shader.
I can’t upload a txt doc with the shader network but it’s this:
Make sure you only transform if its absolutely necessary as it can add expense. if you are just using a sphere you are fine to not transform.
I would think that most primitives here would translate pretty well with this, keeping in mind you’re only going to be drawing on world positions, http://mercury.sexy/hg_sdf/
Where P in those functions is, in the image, SphereMask(A). I’m only using the sphere mask as a convenience function to tweak distance fields.
Whoa it works! Awesome! I wish I better understood how it works, but this is plenty for me to work with.
The only error I’m noticing is if you’re inside the object, the results switch from rendering inside the object to outside of it. Any way to fix that or do I just have to deal with it?
Hi everyone, I know this thread is kind of old, but I was wondering if you could help with a problem I had. I am trying to highlight the itersection between 3D solids and a plane, like the image here.
Does anyone know if some sort of depthfade code could make this work? Very new to UE4.
There’s a node in Unreal’s material editor called “Depth Fade”. cghow is suggesting you use this and then run the result of that through a 1-x node, which will give you the opposite of it’s default functionality
Thanks so much, we got depthfade running with fresnels involved and it turned out like this. Now our difficulty is how to implement this on a transparent material? Is this possible.
We are attempting to use the Allow Custom Depth Writes setting but it is still not working when we make the solids transparent.
Hi! Thank you so much for all your help btw im the other partner working on this project. What we are trying to do is have the shape and the plane be transparent and have the intersection of the two show in an opaque color (essentially just like the “cross section” earlier in the thread). We have pretty much that exact blueprint in our plane except with another lerp modifying the transparency of the plane. We’re having trouble making the intersecting object transparent except for the plane of intersection.