|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
This might not be the best possible place to ask this, but at least it is
related to computer graphics (and there are lots of programmers here), and
I don't feel like subscribing to yet another random online forum.
This is something I really should know, but I don't. And, more
surprisingly, I just can't find this info even though it should be
something that's trivial to find. It just doesn't seem to be. I was
wondering if someone with more experience on this subject could illuminate
me a bit.
Light mapping is a common efficient method for lighting static scenes,
especially in older 3D games. I had always assumed that light maps could
both make the underlying texture darker *and* brighter (from complete black
to completely overexposed white where the lighting is the strongest, and
then of course an unmodified texture in between the two extremes).
However, after searching info online about how to use light maps with
OpenGL, this possibility is actually not clear at all. There are tons and
tons of tutorials online (most of them dealing with how to *create* light
maps, which is not what I'm looking for rather than how to *use* them in
OpenGL). Whether the same light map can both make the underlying texture
darker and brighter (than the original texture) is inconclusive after my
extensive search. Some example images seem to indicate that it is possible,
but the details of *how* it's done are sketchy at best.
When I tried to search information on how exactly do this with OpenGL,
I just can't find it. You can make the light map modulate (ie. multiply)
the underlying texture, which can only make the texture darker, or you
can make the light map add to the underlying texture, which can only make
the texture brighter, but I can't find the info of how to make it do both,
or whether it's actually possible at all.
I am almost certain that in many games light maps do both. However,
trying to search for examples has also proven difficult. For example
screenshots of Quake 2 (which is a perfect example of a game using
light mapping) are inconclusive. It's difficult to say whether the
light maps are brightening the textures besides darkening them, or
whether they are only darkening them. I was pretty sure that they do
both, but I can't find conclusive screenshots demonstrating this.
(One possibility could perhaps be layering *two* light maps on top
of the textures, one for darkening and another for brightening. However,
it seems that at least vanilla OpenGL does not easily support layering
more than two textures at a time.)
Could someone more knowledgeable about the subject shed some light on it?
(Pun very much intended.)
--
- Warp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> This might not be the best possible place to ask this, but at least it is
> related to computer graphics (and there are lots of programmers here), and
> I don't feel like subscribing to yet another random online forum.
>
> This is something I really should know, but I don't. And, more
> surprisingly, I just can't find this info even though it should be
> something that's trivial to find. It just doesn't seem to be. I was
> wondering if someone with more experience on this subject could illuminate
> me a bit.
>
> Light mapping is a common efficient method for lighting static scenes,
> especially in older 3D games. I had always assumed that light maps could
> both make the underlying texture darker *and* brighter (from complete black
> to completely overexposed white where the lighting is the strongest, and
> then of course an unmodified texture in between the two extremes).
>
> However, after searching info online about how to use light maps with
> OpenGL, this possibility is actually not clear at all. There are tons and
> tons of tutorials online (most of them dealing with how to *create* light
> maps, which is not what I'm looking for rather than how to *use* them in
> OpenGL). Whether the same light map can both make the underlying texture
> darker and brighter (than the original texture) is inconclusive after my
> extensive search. Some example images seem to indicate that it is possible,
> but the details of *how* it's done are sketchy at best.
>
> When I tried to search information on how exactly do this with OpenGL,
> I just can't find it. You can make the light map modulate (ie. multiply)
> the underlying texture, which can only make the texture darker, or you
> can make the light map add to the underlying texture, which can only make
> the texture brighter, but I can't find the info of how to make it do both,
> or whether it's actually possible at all.
>
> I am almost certain that in many games light maps do both. However,
> trying to search for examples has also proven difficult. For example
> screenshots of Quake 2 (which is a perfect example of a game using
> light mapping) are inconclusive. It's difficult to say whether the
> light maps are brightening the textures besides darkening them, or
> whether they are only darkening them. I was pretty sure that they do
> both, but I can't find conclusive screenshots demonstrating this.
>
> (One possibility could perhaps be layering *two* light maps on top
> of the textures, one for darkening and another for brightening. However,
> it seems that at least vanilla OpenGL does not easily support layering
> more than two textures at a time.)
>
> Could someone more knowledgeable about the subject shed some light on it?
> (Pun very much intended.)
>
If you multiply with a map whose values go from 0 to 10, values under 1
will darken, while values larger than 1 will brighten. It's just a
question of applying some offset or stretching the range of your light map.
Same with addition, here, you need negative values to darken things.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Light mapping is a common efficient method for lighting static
scenes, especially in older 3D games. I had always assumed that light
maps could both make the underlying texture darker *and* brighter (from
complete black to completely overexposed white where the lighting is the
strongest, and then of course an unmodified texture in between the two
extremes).
If you write your own shader, you can simply take the light map texture,
multiply it by the texture, and multiply the result by 2 or whatever
constant you want, thus essentially scaling the brightness to any range.
(You'll start to run into precision issues with high values if you're
not using HDR textures, of course.)
You seem to know of a way to render two textures at once, multiplying
them together. I wasn't aware of that feature, so I'm not sure if I'm
just misunderstanding. If you do have a way to do that, you can simply
use vertex colors of rgb(2,2,2), and make sure you have vertex color
clamping turned off (with glClampColorARB I think). Even if you can't
render the light map and the texture at the same time, this trick might
still be useful for a different solution.
- Slime
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 5/19/2011 4:43 PM, Warp wrote:
> Could someone more knowledgeable about the subject shed some light on it?
> (Pun very much intended.)
I'm far from knowledgeable concerning OpenGL, but as Slime mentioned, a
shader might be the way to go. I think with older pixel shaders (<2) you
could blend textures in a few different ways (multiply, add, etc.). With
current GLSL implementations you can write entire functions from scratch
and do tons of other cool things.
Give GLSL a shot if you aren't worried about your program not working on
older hardware~
Sam
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Alain <aze### [at] qwertyorg> wrote:
> If you multiply with a map whose values go from 0 to 10, values under 1
> will darken, while values larger than 1 will brighten. It's just a
> question of applying some offset or stretching the range of your light map.
> Same with addition, here, you need negative values to darken things.
This assumes that the lightmap texel components are floating point values.
It is completely unclear to me whether OpenGL and rendering hardware supports
floating point components in textures. There are some indications that at
least some don't. (You can give OpenGL a texture in floating point format,
but it will be internally converted to an 8-bits-per-component bitmap,
clamping all values to the range [0.0-1.0] and multiplying by 255.)
--
- Warp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
stbenge <"egnebts <-inverted"@hotmail.com> wrote:
> I'm far from knowledgeable concerning OpenGL, but as Slime mentioned, a
> shader might be the way to go.
I was more interested in the traditional (pre-pixel-shaders) way of
doing light mapping.
--
- Warp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 5/20/2011 2:37 PM, Warp wrote:
> Alain<aze### [at] qwertyorg> wrote:
>> If you multiply with a map whose values go from 0 to 10, values under 1
>> will darken, while values larger than 1 will brighten. It's just a
>> question of applying some offset or stretching the range of your light map.
>
>> Same with addition, here, you need negative values to darken things.
>
> This assumes that the lightmap texel components are floating point values.
> It is completely unclear to me whether OpenGL and rendering hardware supports
> floating point components in textures. There are some indications that at
> least some don't. (You can give OpenGL a texture in floating point format,
> but it will be internally converted to an 8-bits-per-component bitmap,
> clamping all values to the range [0.0-1.0] and multiplying by 255.)
If the GLGraphics library for Processing is any indication, then yes,
OpenGL supports floats. But are they supported by hardware? It depends
on your card.
I've got a 7600GS, and was rendering hi-ish res floating point precision
continuous cellular automata at exceptionally high frame rates, almost
nearly as fast as 8-bit surfaces. I'm 100% sure it wasn't running in
8-bit mode because of the behavior (with CCA, it is often readily
apparent). But when I switched to double precision surfaces, I
experienced a dramatic decrease in performance, which probably means
that at that point it could only operate in software mode, since my card
can't handle higher bit depths (I haven't actually looked it up, but
it's what I'm assuming).
Sam
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I'm not quite sure whether i understand your question but afaik lightmaps are
traditionally used as
finalColor = (ambientColor+lightMapColor)*textureColor
Using a Shaderprogram you can of course use it in any way you want.
Regards Roman
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> I was more interested in the traditional (pre-pixel-shaders) way of
> doing light mapping.
>
I remember hearing about something called 2X multiply, or Modulate2x
that multiplies the texture by 2. After a little searching for that, it
looks like this might be the way to do it in opengl:
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE, 2.0)
I also saw GL_RGB_SCALE_ARB, so it might be part of an extension. Of
course, this has to be combined with multitexturing.
- Slime
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|