Home Unreal Engine

Rendering an object's silhouette, behind a translucend material.

Hello there. I have a question regarding a specific material effect.
First of all here is an image to illustrate my question/problem


l3GfFlt.png

Basically I want to render the faces (or better, the surface) of the object behind the blue translucent material, as a flat color. Like a silhouette. The player has to see it from different angles too. Also only the object that is near to the Material should be seen as a silhouette. Objects that are placed further away shouldn't be seen, or at least should not have the same color.
I have no idea how to do this inside the Material editor, or even if it is possible :(
As a sidenote, mesh 2 has a different material than mesh 1.


I hope you can help me out there :)


-Sandro

Replies

  • amartinez
    Options
    Offline / Send Message
    amartinez polycounter lvl 8
    Hi!
    I have not used Unreal Engine properly, but the idea should be the same. Sounds like a Stencil Buffer friendly solution to your problem.
    I'm assuming the bottom right screenshot is the desired result right?

    You could try something like this:
    - Check if the materials, shaders or 'object renderer' have control over Stencil Buffer.

    If you want your object to be silouhetted only when it's 'inside' the ring:
    - Be sure to clear your back buffer to zero.
    - Render your middle object (the one to be 'silhouetted')
    - Render your double sided ring with: always pass stencil, front face stencil increment, back face stencil decrement.
    - Render a 2nd time your middle object, but with a flat color material and with stencil 'pass' only if the stencil is equal or greater than 1. (I say the first object, but it could actually be any geometry, a box the size of the bounding box of your object should be enough, as long as it has a material that checks for the stencil value).

    If you want 'everything' behind the ring to be silhouetted no matter what do not 'decrement stencil on backfacing triangles'.

    There might be many many ways to do this, maybe there is a way to not duplicate objects and materials...

    With post-processing you could have more options/freedom for the 'flat color', but might be slower and more complicated.
Sign In or Register to comment.