Results 1 to 3 of 3

Thread: shader front/back face and ccw ,cw

  1. #1
    Senior Member Regular Contributor
    Join Date
    Aug 2008

    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?
    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


  2. #2
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    UK, London

    Re: shader front/back face and ccw ,cw

    I think the answer is to pick a convention and ensure all faces use the same.

  3. #3
    Member Contributor
    Join Date
    Aug 2009

    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.

Similar Threads

  1. Linear interpolation of depth value between front and back face depth values
    By RealtimeSlave in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 05-16-2016, 05:39 AM
  2. changing back face to front face in vertex shader
    By hoschie211 in forum OpenGL: GLSL
    Replies: 1
    Last Post: 11-03-2009, 12:36 AM
  3. Front and back face with diferent colors using index arrays?
    By billy in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 04-11-2003, 07:59 AM
  4. Front and Back Face???
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-09-2003, 02:44 AM
  5. Distinct front and back face material properties
    By Phaedrus in forum OpenGL: Advanced Coding
    Replies: 8
    Last Post: 04-30-2002, 11:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean