Notifications
Clear all

[Closed] How 3dsmax use back-face culling ?

I work on an exporter to 3D real time (using OpenGL) and i have some problem with some mirrored objects.
I need to know if there is a node property that give which of ccw or cw is used on a node to make the mesh visible or not.

For example :

  I made a cube and mirror it on axe X so     cube.scale = [-1,-1,-1] and cube.controller.scale = [-1,1,1] . 
  But if i use resetScale on this cube any scale properties goes to [1,1,1] so i don't know if the face visibility is in ccw or cw. The only solution i found is to compare the normal of the mesh to the visibility vector ... 
  Is there an other solution ???
5 Replies

Ok i found how 3ds max use the back-face culling. In fact in 3dsmax the mesh normal define which mesh is visible. This is different from opengl which use drawing sens of vertex (ccw/cw). So in opengl the normal can be in the opposite direction of the visible face.

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

No, this is not different, because the direction of the normal in both Max and OGL is dependent on the CW/CCW order. The normal always points in the direction that has the vertices in CCW order. This is because the face normal is calculated on the fly using the cross product of two edges, and the resulting perpendicular vector always points in the direction that sees the operands running in CCW direction.

On a side note, NEVER EVER use the Mirror tool or even the scale tool in the toolbar to mirror/scale objects in Max at the node level.
(In Max up to R3, there was a long warning issued every time you would try to apply scaling at object level. It was removed by advanced user’s request, but newbies tend to use it till now).

Either apply an XForm modifier and scale the mesh before it reaches node transforms, or use the Reset XForm Utility to fix the negative scaling (which again applies an XForm to compensate the node transforms and resets rotation and scaling at object level) prior to exporting.
You can apply Reset XForm through MAXScript using the resetXForm method in Max 6 and higher.

Thanks a lot for your help,

I’m not 3dsmax modeler, i develop script export so i would say to the modeler not to use those toolbar tools, but it will be hard for him to change ^^.

For the back face cull problem, i’m not sure to understand with you.
Let me explain why : in openGL we can easily make a mesh that “visibility vector” is opposed to the mesh normal.

what i named “visibility vector” (perhaps not the good name) is
what you named : “the resulting perpendicular vector always points in the direction that sees the operands”.

In fact OpenGL make a difference between the mesh normal and his visibility vector.
Visibility vector is used to apply back face culling. And normal is not used for back face culling but just for the mesh illlumation.

So my theory is that 3dsmax hide to users this back face culling method and automaticaly align the visibility vector with the normal vector in changing ccw for cw.

If i made mistakes said it to me. I’m new on using 3dsmax and OpenGL together.

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

I think you are right, Max uses the face normals to determine the backface culling.
You should remember that originally Max was not OpenGL capable at all, so the viewport system was designed to use Heidi. OpenGL and Direct3D were added later and I assume their backface culling capabilities were used (which might explain why Direct3D was always so bad at backface culling ;)). But I don’t know what happens under the hood.

Normally, there is no reason to flip ccw and cw. If you look at the normal’s Z component in the view coordinate system (the viewport or camera always looks at the scene with the -Z axis), then if the Z coordinate of the normal vector is < 0, the normal is facing away from the camera and the face should not be drawn.

The example script found in the MAXScript Reference 7.0 > Frequently Asked Questions > How Do I Get Faces with Normals Facing Away? implements a simple scripted version of a backface culling algorithm which yields identical results to the actual viewport culling.

So, the real solution of all those problems in 3D graphics would be to have a real standardization of 3D engines and 3D formats… but it sounds like a dream ^^