Results 1 to 3 of 3

Thread: basic lighting

  1. #1
    Senior Member Regular Contributor
    Join Date
    Feb 2001
    Posts
    108

    basic lighting

    hi

    ive played around a bit with a light source in OpenGL and am a bit confused by its behavior. I position the source with

    litepos = { 0.0, -1.0, 0.0, 0.0 }; // directional source
    glLightfv(GL_LIGHT0, GL_POSITION, litepos);

    the light is also transformed by the modelview mmtrix each frame.
    if im not mistaken, this should create a light beaming straight down onto my scenery.
    however, it doesn t, the objects are illuminated from below instead. ive checked the normal vectors but they are absolutely correct. okay, so maybe swapping the sign of the light vector solves the problem, but i dont want to hack around here. could it be that GL_POSITION is somehow multiplied with the inverse modelview matrix, like glSpotlight?

    thx
    eik

  2. #2
    Member Newbie
    Join Date
    Mar 2001
    Location
    New Zealand
    Posts
    39

    Re: basic lighting

    I haven't used gl's lighting much yet but your code:

    litepos = { 0.0, -1.0, 0.0, 0.0 }; // directional source

    the parameters for it are (x, Y, z, and something which escapes me)

    You have set the light position below the origin which is why it why you object is lit from below, you told it too.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Jun 2000
    Location
    B.C., Canada
    Posts
    367

    Re: basic lighting

    The vector for a directional light indicates the direction it is coming from, not the direction it is shining in.

    j

Similar Threads

  1. Basic lighting not working
    By Elijah1920 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-09-2017, 02:44 AM
  2. Help with basic lighting in shader
    By davoring in forum OpenGL: GLSL
    Replies: 3
    Last Post: 12-30-2014, 07:35 AM
  3. Lighting issues (very basic)
    By davoring in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 08-15-2014, 12:49 PM
  4. Basic Lighting for CAD
    By tomahawkins in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 09-08-2009, 04:35 PM
  5. basic lighting question
    By ewans2 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-21-2003, 01:32 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