-
Junior Member
Regular Contributor
shader front/back face and ccw ,cw
I created a front/back shader and I use two pass one front and one back with the correct culling.
The problem is that i find some models(sketchup) that i suppose have both ccw meshes and cw meshes.
In this case I get wrong results.
Is possible to convert all faces in cw or in ccw?
How?
thanks.
ps.
I think that the trick is the sign of the normal, may be?
If the normal is positive then i'm in a cw(or ccw , i don't know) else if the normal is negative in ccw.
Then in my importer i have a method that creates the triangles, i can test if the normal is negative ,then rebuilt the indexes else ok and i does nothing else that create the triangle wit the existing indexes.
But how i test if the normal go outside (positive?) or inside (negative?) with the opengl axis system.
sorry for my english
thanks
-
Senior Member
OpenGL Pro
Re: shader front/back face and ccw ,cw
I think the answer is to pick a convention and ensure all faces use the same.
-
Re: shader front/back face and ccw ,cw
Depending on your shader you may use the glsl built-in variable gl_FrontFacing and reduce to a one-pass shader.
You can swap the OpenGL interpretation of front and back with glFrontFace(GL_CW) or GL_CCW.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules