Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: More than one lightmap

  1. #1
    Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Arlon, Belgium
    Posts
    486

    More than one lightmap

    Hi,

    I've a question :

    How do you when you have more than one lightmap on a polygon ?

    I've tryed to render the 2 lightmaps but only one is displayed. If I display the number 1 or 2 alone, no problem.

    I'm almost sure that's is because I use only 1 texture unit and the same one for rendering each lightmap.

    So, how do you do for rendering more than one lightmap ?

    So, if I've 6 lightmap, should I use 6 texture units ? It has no sense, not ?


    Thanks,


    LEYDER Dylan


    [This message has been edited by Leyder Dylan (edited 10-23-2003).]

  2. #2
    Junior Member Regular Contributor
    Join Date
    Jan 2003
    Posts
    146

    Re: More than one lightmap

    If I understand your question, it's either single-pass multi-texturing if you have the
    hardware to do it, or multi-pass multi-texturing if you don't.

    This will tell you how many texture units your card has:

    #include <GL/glext.h>

    INT max_texture_units;
    glGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &max_texture_units );

    But I'm sure you already know all of this? It is a very basic mult-texturing question.


    [This message has been edited by gator (edited 10-23-2003).]

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Aug 2001
    Location
    Italy
    Posts
    628

    Re: More than one lightmap

    Originally posted by Leyder Dylan:
    ...
    So, how do you do for rendering more than one lightmap ?

    So, if I've 6 lightmap, should I use 6 texture units ? It has no sense, not ?
    ...
    Lightmaps are usually melt togheter at compile time by adding them. So for example, each light which is static is combined in the same lightmap, each light which pulsates at a certain rithm is another lightmap (which also contains all the other lights with the same rithm) and so go on.

    Now, what you do really depends from the architecture of your engine and from the target machine. Fragment programming facilities are somewhat helpful here but keeping on the topic...

    First point is to accumulate all the lights. In standard multitexturing this will take a tex unit foreach lightmap. Every other lightmap is added. After every lightmap has been added, it's just time to multiply. Sounds easy? It's not.
    In case you don't have so much texture units (but I guess you can do interesting things with just 5 lightmaps and a 3 base textures and some cards will let you do that) I'm afraid you will have to use the so-dreaded multipass rendering using blendfuncs. Ack.
    Some time ago, I took in consideration the idea to do ping-pong rendering using a special texture. It turns out that context switching is so expensive that it really kills **a lot** of performance so it does not pay so much if you're running low resolution.

  4. #4
    Junior Member Regular Contributor
    Join Date
    Jan 2003
    Posts
    146

    Re: More than one lightmap

    Ah, if he means putting multiple OpenGL lights in a scene, then that is a different question altogether.

  5. #5
    Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Arlon, Belgium
    Posts
    486

    Re: More than one lightmap

    Hi,

    Here's a screenshot, you'll understand :
    http://users.skynet.be/fa550206/Slug...p/Lightmap.jpg

    Sorry but the forum doesn't include the image in the message, don't know why.

    Yes I'm using Multitexturing and my GeForce 4 Ti 4200 has only 4 texture units. Damned ...

    First point is to accumulate all the lights
    Is it possible, for static lightmap to create only one texture with all lightmaps ?

    What about the fragment program ?



    [This message has been edited by Leyder Dylan (edited 10-23-2003).]

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,704

    Re: More than one lightmap

    This only barely qualifies as "advanced" and only barely qualifies as "OpenGL," but what the hey. There is no "basic rendering questions" board that I know of, except flipcode/gamedev...

    Here's one way of doing arbitrary numbers of light maps with a simple diffuse color texture per object:

    1) clear framebuffer to ambient light color
    2) Enable(BLEND); BlendFunc(ONE,ONE);
    3) for each lightmap
    3.1) for each object within radius of that light
    3.1.1) render the object with the light map
    4) BlendFunc(ZERO,SRC_COLOR);
    5) for each object
    5.1) render the object with full-bright diffuse color map
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

  7. #7
    Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Arlon, Belgium
    Posts
    486

    Re: More than one lightmap

    I can render the lightmap. My question was : How can I render more than one lightmap if I only use one texture unit with ARB multitexturing.

    I can do that with the polygon offset ? How it's a wrong way ... ?

  8. #8
    Advanced Member Frequent Contributor
    Join Date
    Apr 2000
    Posts
    748

    Re: More than one lightmap

    This is confusing as hell. Why would you want more than one lightmap per triangle ? Unless you are working with advanced hybrid techniques, more than one lightmap per triangle is not needed...

    How can I render more than one lightmap if I only use one texture unit with ARB multitexturing.
    Sorry ? You're not making any sense at all here. If you only use one texture unit... you're not doing any MULTItexturing at all.

    Y.


    [This message has been edited by Ysaneya (edited 10-24-2003).]

  9. #9
    Advanced Member Frequent Contributor
    Join Date
    Oct 2000
    Location
    Belgium
    Posts
    857

    Re: More than one lightmap

    Originally posted by Ysaneya:
    This is confusing as hell. Why would you want more than one lightmap per triangle ? Unless you are working with advanced hybrid techniques, more than one lightmap per triangle is not needed...
    I recall from one of his previous posts that he uses the term "(dynamic) lightmapping" to describe what is actually attenuation mapping.

    The answer to the problem is exactly what jwatte posted. Also note that the very first pass should not use blending, because that one will need to lay down the Z-buffer. You also need to switch to DepthMask(FALSE) and DepthFunc(GL_EQUAL) after the first pass.

    -- Tom

  10. #10
    Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Arlon, Belgium
    Posts
    486

    Re: More than one lightmap

    Oups, sorry jwatte to haven't followed your advice.

    Kick my ass.

    That's work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •