I can see through surface inside objet

hello ,

in my scene i ve an object which is a ground and when i m inside/under the ground i can see all object which are above ground .

on some mesh i ve got solution ( can’t see through what i does wish ) when i set backface culling at false , but on other mesh i have to set backface culling to true so i can see through .

question : when mesh have backface culling set to true how can i do, to avoid to see through mesh when i am inside object ( an other way is to ask how to do light don’t go through a mesh when backface culling is set to true )


You seem to have almost answered your own question. The renderer only renders a single side of each triangle but you can change that by making a material double sided.

If you are in the position that you want to not render an object from one side but ALSO not see beyond it, then that’s actually not a situation I’ve found myself in before! But I can think of a couple of things to try - but it raises some questions: If you want to NOT see the reverse side of the object, AND not see what’s beyond - what is it exactly that you DO want to see?

the main goal is the light must not go through a mesh which has backface culling set to true .

why i try to get this goal ? because lot of object in my scene like building have a part inside the ground , and when the sun is under horizon , light can go through mesh , a part of building near ground is luminous while it is the night . an other probleme, is to simulate water i use plane which has a part inside ground and this part can catch light coming from artificial light behing a bump ground ( see green light reflexion , it should not be here )

hmm, Well there’s a couple of ways you can rig the scene around that, if you are using a shadowMap you could create a clone object, set it’s side to backface only and apply the THREE.ShadowMaterial - which is an invisible material that casts shadows.

Alternatively for something like water you could place a directional light at the height of the water and cast negative light from it, so anything below that altitude gets light removed.

Usually for this kind of thing I’m already deep inside a custom fragmentShader, lighting is where the true art of game dev is - faking things in efficient ways!