How can i check if the quad is backface on camera?
I want to detect if my quad mesh is back turned to camera. I think renderer.isVisible won't work for this(because i couldn't). thanks for your advices
Comment
Best Answer
Answer by Hellium · Apr 20, 2021 at 08:55 AM
Vector3 normal = ...; // The normal of your quad. You may need to loop through the mesh normals https://docs.unity3d.com/ScriptReference/Mesh-normals.html
Vector3 cameraForward = ...; // Camera.main.transform.forward for instance
bool isNormalFacingCamera = Vector3.Dot(normal, cameraForward) > 0;
This only works while you don't move the object or camera because it just base on rotations do you have any solution for that? Thank you.
I can't remember whether the normals of the mesh are expressed in local or global space.
If they are expressed in local space:
normal = meshfilterTransform.TransformDirection(normal);
// where meshfilterTransform is the transform of the mesh filter whose normals have been "extracted" from