How to make shader being applied to all meshes, except a specific one?
Asked Answered
C

3

0

Hello! I'm still working on my first 3D game and I just created a simple outline shader that is affecting all meshes in the root node. However, I want to avoid this shader being applied to my player mesh node that is inside the root node too. Is it possible? Any clue?

Cryobiology answered 5/2, 2022 at 15:39 Comment(0)
S
0

By design, a screen-space shader will affect the whole viewport. There are a few ways to prevent specific objects from being modified by the screen-space shader, but there is no "one size fits all" way to do this.

For instance, for shaders that use the depth buffer, you can configure the mesh's material to not write to the depth buffer by enabling alpha-blended transparency (even if the material is fully opaque). This will prevent it from casting shadows, so you will have to duplicate the MeshInstance and set the second MeshInstance's Cast Shadow property to Shadows Only if you still want it to cast shadows.

Saporous answered 5/2, 2022 at 18:5 Comment(0)
C
0

I will try that, @Calinou. Thanks.

Cryobiology answered 6/2, 2022 at 2:23 Comment(0)
S
0

You can use 2 viewports, but I find this to be not a great solution, as it makes editing the project difficult. In general, though, full screen shaders affect everything. So the outline will be on everything.

Singularity answered 6/2, 2022 at 7:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.