How can I avoid seeing the inside faces of a semitransparent object in 3D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Nohack
:warning: Old Version Published before Godot 3 was released.

I posted this question on blender stackexchange earlier and got no good answers. My goal is ultimately to make this work in godot, so I figured I’d ask here to.

So what I want is to just make the object/mesh transparent as a “filter” instead of giving it a transparent material which will show the inside/behind faces.

This is currently what I’m getting:

This is what I want to get (done using post editing)

All of this is demonstrated using blender, but the exact same thing happens in godot, so I don’t feel the need to upload a sample project, I can provide one if needed.

In Godot, the result you are getting is obtained by having the double sided option enabled on the material, so I think you have to disable it. If materials are directly in the mesh however, I’m not sure how you can do this, maybe something in Blender to prevent backfaces from being rendered, or add a material override in Godot.

However that doesn’t fixes all cases, I tried with Suzanne (the monkey from Blender) and you can see outside faces through the model. In theory, there is nothing wrong with it, because you can see through the model (because it’s transparent) and outside faces are supposed to be seen. What you want (judging by your screenshot), is to not be able to see anything of this model through itself… I don’t see any option in Godot to do that, unfortunately :frowning:
I think there are ways, of course, but not as simple as setting flags in a material.
It has to do with the depth buffer, like, drawing the mesh as if it was opaque, but the result must be made transparent. Maybe use a render-to-texture? (but may come with drawbacks).

If anyone knows, correct me if I’m wrong, because I’m not experienced yet in the 3D side of Godot 2.x ^^"

However if disabling double sided is enough for you, I might move this comment as answer.

Zylann | 2017-02-08 23:57

:bust_in_silhouette: Reply From: guppy42

It looks like your normals are messed up ( hit ctrl+n to have blender normalize them ).

But even with that the bits that goes inside it ( eyes / mouth ) will have an interior wall visible - grab a glass and look at it from the side, you will still be able to see the inside wall facing you.

You can still achieve the look in the 2nd picture by doing more or less the same in godot that you did in post by doing RTT + billboarding.

First render the model to a seperate viewport and then for the rendering pass replace the model with a billboard ( a quad that always faces the camera ) this billboard you give opacity.

Being new to godot I may have the terminology wrong, but you can find an example of RTT (render to texture) in the examples viewport/3d_in_2d/ - they use the resulting texture in 2d but there is no reason you can’t use it as a texture.

Note: with this trick the rending will look correct but remember that your billboard needs to have the collision box from the actual model or it wont collide properly ( which given it’s ghost like appearance may be what you want :wink: )