Results 1 to 2 of 2

Thread: Light mapping

  1. #1
    Senior Member Regular Contributor fenris's Avatar
    Join Date
    Mar 2000
    Cincinnati, Ohio USA

    Light mapping

    Ok. Here's the situation. I have a surface and a point. The point represents a light. The light has a radius, color and intensity value. The intensity value of the light is anywhere from 1 to 0, 1 being full intensity, 0 beign totaly dimmed. The color is just an RGB val used to multiply color components of the light map. My question is, how can I determine the light's point of impact on the surface's plane, and generate a radial lightmap based on the distance of the light from the surface, the radius and the intensity values? I beleive the point of impact is (in pseudo-code):

    impactx=light.origin.x - plane.normal.x*dist
    impacty=light.origin.y - plane.normal.y*dist
    impactz=light.origin.z - plane.normal.z*dist

    where dist is:


    But I think this may be TOTALY wrong, but it seems right. Anyone have any ideas? Any online docs explaining the same, or near the same situation? Any help on this would be great!

  2. #2
    Member Newbie
    Join Date
    Mar 2000

    Re: Light mapping

    I'm not sure exactly what you mean, but this is the way that I'd do it:

    Get the values a, b, and c that describe your polygon, for the equation below:

    0 = a*pointOnPoly.x + b*pointOnPoly.y
    + c*pointOnPoly.z

    Then get the minimum distance to the plane using these values (I couldn't fit the z dimensions in the text box ):

    MinDist = a*light.ori.x + b*light.ori.y ...
    a*norm.x + b*norm.y ...

    It's then pretty easy to get the coordinates of the closest point on the polygon if you need it (assuming your normals are normalised):

    impactPos.x = light.ori.x + norm.x * MinDist

    Presumably, you want to reduce the problem to a 2D one (so that you can get the distance from the light, based on the radial distance on the surface from the impactPos, and the surface normal.)

    For large distances you can say (approximately):
    lightNorm = radialDist/minDist
    lightDist = minDist

    And for small distances (or full accuracy) you can say:
    lightNorm = inverseTan(radialDist/minDist)
    lightDist = sqrRt(minDist^2 + radialDist^2)

    I hope that I've explained this properly (besides which, you probably had the right idea yourself anyhow...)

Similar Threads

  1. Shadow mapping a spot light
    By Kerndog73 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 01-18-2017, 09:05 PM
  2. Light Position&Textures Mapping
    By Sam Kovalev in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 11-17-2004, 11:21 AM
  3. Light & Texture Mapping
    By mekron in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 07-11-2004, 09:34 PM
  4. 21.100 How can I perform light mapping?
    By lobstah in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 04-19-2001, 04:56 PM
  5. Shadow/light Mapping
    By DPalomo in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 09-13-2000, 12:18 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