Hi! As in the title, I want to create an x-ray effect for my character, I want to have a skeleton inside and be visible through the character mesh.
I m not good enough with post-process materials and other material effects.
If you know a way or even an asset that can help me, I would appreciate it!!
Your character will need to have a translucent material in order for this to work, as it’s the only way to evaluate depth with interior objects also being lit properly without custom engine code.
This code compares the scene depth (the depth without transparency) to the pixel depth (the depth with transparency). If there is a difference between the two but it is less than the size of the mesh, then the object must be inside the mesh and therefore the mesh’s transparency must be 0 to allow it to be seen through.
You will need to adjust the B number by the general size of the character. This is also only starter code, as getting the actual full effect will take a lot more work. Likely, you’ll need to use a postprocess with custom depth evaluations to re-sort the assets and make sure only the object inside the character is seen.
Good luck with this. Definitely not an easy effect to achieve.
Thanks for the reply!!
The problem now is that the translucent object will be visible through other objects, even if they don’t have Render Custom Depth Pass on.
Your character will need to have a translucent material with the code I sent above.
The sphere will need to be set to “Render Custom Depth”
There is no postprocess material needed.
Custom depth is an additional depth pass- it does not replace the default depth pass unless you overwrite it. There are a few reasons you need to do this within the actual character material:
You have found the main issue, which is that there is no way to specify which objects to see through. Technically, there is probably a way around this with Custom Stencils, but it would be very messy.
Any method other than the one I sent leads to the interior sphere appearing as a blob of color, like you’re seeing now. This is because of the character is opaque, no light or color information can pass through to the sphere- only the shape. If you want a full detailed mesh to pass through, the character needs to have translucency.