Results 1 to 3 of 3

Thread: Normal to a surface

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2004
    Bangalore, Karnataka,India

    Normal to a surface

    Hi all,
    I have some basic questions.
    1) Why normal is used for lighting. Is there any place where I can get information about selecting a normal for a surface to be used for lighting ?

    2) I have a set of points/vertices. I can guarantee that these are the verices of a plane. Is there any way to get normal with length 1.0 for plane with the n(defined) number of vertices ?

    Thanks in advance
    Deek**** M

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Feb 2004
    Long Island, New York

    Re: Normal to a surface

    There's a lot of information online about computing the normal to a surface.

    A surface normal is a vector perpendicular to the surface at a given point. It is used in computing the amount of light reflected off of a surface. The smaller the angle between the surface normal and the light ray normal, the brighter the surface will appear.

    You can get a normal with length 1.0 by "normalizing" your surface normal.

    suppose you have a surface normal defined by some x,y,z.

    first you find the length of the surface normal: length = sqrt(x*x+y*y+z*z);
    where x,y,z are the components of the surface normal.

    then you divide each component of the surface normal vector by the length:

    x /= length, y/=length, z/=length.

    you can always call glEnable(GL_AUTO_NORMAL) and have OpenGL generate normals for you, but this won't always give you the best results. If you're a beginner to OpenGL i suggest just enabling GL_AUTO_NORMAL and getting familiar with more of the basics before worrying too much about generating your own normals.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2004
    Bangalore, Karnataka,India

    Re: Normal to a surface

    Actaully I was planning to do a project on 3D home walkthrough. Where we construct house using rectangles and triangles (only). So, to enable proper lighting I need to set the normal properly. But I have the following doubt.

    1) How to calculate normal for a rectangle and a triangle.
    2)Do I need to specify normal for each vertex of the rectangle.

Similar Threads

  1. have problem to calc normal to surface
    By lonibabi in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-13-2013, 05:06 PM
  2. Surface Normal Function - Not really sure...
    By MightyLampshade in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 11-17-2010, 01:40 PM
  3. Replies: 5
    Last Post: 09-15-2010, 10:17 AM
  4. How to rotate a surface so it has a given normal?
    By Tavio in forum OpenGL: General
    Replies: 2
    Last Post: 09-23-2009, 08:32 PM
  5. determining surface normal
    By akashiraffee in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-05-2009, 02:10 PM

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