PDA

View Full Version : Reflection maps

LaBasX2
10-03-2002, 05:27 AM
The standard lighting equation for perpixel lighting is:

ambient + SumAllLights(diffuse + specular)

What I want to add to this equation now is a reflection map (cubic environment map). But I'm not quite sure what's the best way. Originally I had the reflection map within the diffuse term. But this is physically wrong because you can also see an image in a mirror if the mirror is not directly lighted by a light source. So the reflection map must depend more on the ambient term I guess...

Any ideas?

Thanks!
LaBasX2

PH
10-03-2002, 05:32 AM
You could do Specular+ReflectionMap. Specular is really just a reflection of the light.

jwatte
10-03-2002, 01:42 PM
The term is more like:

ambient * ambientmap
+ all_lights( diffuse * diffusemap )
+ all_lights( specular * specularmap )
+ reflectivitymap * environmentmap

Most people use the same map for ambientmap and diffusemap, and you often see "white" used for specularmap and some level of "gray" used for reflectivitymap.

Note that while specular can be thought of as "the light reflected in the object" it's more of a diffuse kind of reflection (plastic, not metal) whereas environment map is more of a sharp kind of reflection (metal, not plastic).

Note that you probably don't want lots of specular when you have high reflectivity, and vice versa. And if you use specular with high reflectivity, you probably want a very high specular exponent.

V-man
10-03-2002, 05:54 PM
Nope, if you want reflectivity, you should have a reflectivity factor.

In raytracing the equation is more realistic, but for GL you will need to patch it up for specular.

(1-reflectivity) * (diffuse) + (reflectivity) * reflectionmap + specular

You can just have reflectivity in your alpha and use modulation. The you just map it properly on your surface.

PS: ambient map?

V-man

LaBasX2
10-04-2002, 12:58 PM
I'll try out your equations to see what's best for what I need. Might be it is even possible to use the specular map as reflectivity-map, so things won't become so complicated for the artists making textures http://www.opengl.org/discussion_boards/ubb/wink.gif

davepermen
10-04-2002, 01:37 PM
specularitymap and reflectaritymap are the same (i use those fancy names to make sure no one comes with u_used_the_wrong_word http://www.opengl.org/discussion_boards/ubb/biggrin.gif)

specular is the reflection of the light. if you render your cubemap, and draw there the lights as fat billboards, you don't even need to calc specular theoretically. practically cubemaps don't reflect perfect, so doing the specular perfect is more accurate..

V-man
10-04-2002, 03:01 PM
Originally posted by davepermen:

specular is the reflection of the light. if you render your cubemap, and draw there the lights as fat billboards, you don't even need to calc specular theoretically. practically cubemaps don't reflect perfect, so doing the specular perfect is more accurate..

Yes, I suppose you can do that, but if he is using GL lights (and not a texture trick), might as well make use of specular lighting.

V-man

LaBasX2
10-05-2002, 12:36 AM
Thanks Dave!
I had the same idea with the billborads. If you don't use them, it is probably fully correct to use reflections in combination with specular highlights.
Taking into account what V-man suggested, this could be a nice equation:

ambient*DiffuseMap + LuminanceMap + reflectivity*ReflectionMap*SpecularMap + Sum((1-reflectivity)*diffuse*DiffuseMap + specular*SpecularMap)

If think that should be a pretty realistic and powerful lighting equation. The reflectivity can be stored as alpha channel of the specular map.

The only problem that still remains here IMHO is handling transparency? Any ideas how this is best done?

Thanks
LaBasX2

jwatte
10-05-2002, 02:59 PM
There should be no 1- in any term. Light is purely additive (although there's gamma problems in most current rasterization pipelines). It's up to your artists to generate materials that don't actually ADD light to the world (unless they mean to :-)

There are materials that are both highly reflective, highly specular, and highly diffuse. Clear-coat metallic car paints come to mind.

The next step up after point/directional lighting comes from using diffuse/ambient maps (which at this point turn into the same term). These can be applied as cube maps in NORMAL_MAP form, or can be simulated without texturing in a few shader ops (google for "spherical harmonics").

V-man
10-05-2002, 03:53 PM
>>>>There are materials that are both highly reflective, highly specular, and highly diffuse. Clear-coat metallic car paints come to mind.<<<<

In this case, you are talking about some artificial material that you would like to simulate on your machine. In the real world, there is specular vs diffuse (a few other things to but anyway).

Specular and diffuse are opposites. Clear coat is just that, a clear coat. You paint a surface with a mat color, then you apply the clear coat. Using a paint that has some metallic particles embedded in it gives that cool look to your hot rod http://www.opengl.org/discussion_boards/ubb/smile.gif

Labas, multiplying the reflectionmap with specularmap can give an interesting clear coat effect actually. Is that your goal?

Your equation seems overly complicated. Can you explain the "Sum" part? and why do ambient*DiffuseMap?

ambient*DiffuseMap + LuminanceMap + reflectivity*ReflectionMap*SpecularMap + Sum((1-reflectivity)*diffuse*DiffuseMap + specular*SpecularMap)

V-man

LaBasX2
10-06-2002, 01:51 AM
Thanks again!
V-man, actually I don't want to achieve any special effect but a model that is most realistic and most flexible to get all sorts of cool effects.
With the Sum part I mean "for every lightsource do".
With ambient here, I mean the ambient intensity. This could for example be looked up in a cubemap as John Carmack proposes (probably in Doom4 http://www.opengl.org/discussion_boards/ubb/wink.gif ). DiffuseMap is used as the ambient color.
I was thinking about the (1-reflectivity) part again and somehow it seems logical. A real mirror for example doesn't have diffuse lighting IMHO but on the other hand, it is possible as jwatte says that the artist could just use a black diffuseMap to get the same effect. That is even more flexible and makes the equation a bit simpler. http://www.opengl.org/discussion_boards/ubb/smile.gif

LaBasX2

Korval
10-06-2002, 02:32 AM
In the real world, there is specular vs diffuse (a few other things to but anyway).

Time for a lesson in quantum mechanics.

The concepts of specular and diffuse reflectance are based in quantum mechanics and the wave-particle duality of matter (in this case, light).

A quantum of light, known as a photon, is diffusely reflected if it is absorbed by the material and emitted. This uses the wave properties of light. Because it is a wave, the direction in which it is emitted is indeterminate. In essence, the photon is emitted in all directions. Hence, a diffuse reflection does not depend on the angle of view; the same quantity of energy is emitted in all directions, so the view direction is unimportant.

Because the photon is absorbed and reemitted, the photon is emitted with a different wavelength (color) than the one that was absorbed. Technically, many photons of varying wavelength are emitted. The particular wavelengths of photons emitted depend on the properties of the material. What we see as the color of the material are the wavelengths of the color that are being emitted by the surface. Note that not all of these wavelengths are in the visible range, even if the incident light was in the visible range.

Specular illumination comes from a different interaction. Rather than being absorbed and emitted, a specular reflection comes from a photon literally bouncing off of the material. Now, some materials (metals in particular) do have some effect on the color of specularly reflected photons. But, in general, the color of a specular reflection is based on the color of the incident light.

Note that the presence of one does not necessitate the lack of the other. These are independent concepts that have effects in independent ways.

The "texture" of a surface (roughness) determines ultimately how mirror-like the surface is (the dot(N, H) ^ k term tends to take this into account for Phong illumination). There are other factors that determine the strength of the specular reflection (typically taken into account by the OpenGL specular color of the material).

A surface cannot be described simply by giving a percent diffuse, and therefore the percent specular is 100 - that percent diffuse. It is just not that simple.

A surface that is prone to diffuse reflection can still have specular interactions. In fact, most surfaces that you see as being purely diffuse have quite a bit of specular characteristic to them, which is one reason why lots of rendered surfaces (especially in games) look very fake. Though it may be hard to consciously see the specular reflections, you expect them, and miss them when you don't see them. The specular characteristic to human skill is one of the reasons that making rendered humans is so hard.

Lastly, these two interactions are all you need to determine how a surface interacts with light. The diffuse term is pretty trivial; the standard OpenGL diffuse works just fine. It's the specular term that's the horrible pain. I've seen very large equations that only give approximations (good enough to get movie-quality graphics, but still approximate) to reality.

davepermen
10-06-2002, 03:35 AM
Originally posted by Korval:
Time for a lesson in quantum mechanics.

The concepts of specular and diffuse reflectance are based in quantum mechanics and the wave-particle duality of matter (in this case, light).

A quantum of light, known as a photon, is diffusely reflected if it is absorbed by the material and emitted. This uses the wave properties of light. Because it is a wave, the direction in which it is emitted is indeterminate. In essence, the photon is emitted in all directions. Hence, a diffuse reflection does not depend on the angle of view; the same quantity of energy is emitted in all directions, so the view direction is unimportant.

Because the photon is absorbed and reemitted, the photon is emitted with a different wavelength (color) than the one that was absorbed. Technically, many photons of varying wavelength are emitted. The particular wavelengths of photons emitted depend on the properties of the material. What we see as the color of the material are the wavelengths of the color that are being emitted by the surface. Note that not all of these wavelengths are in the visible range, even if the incident light was in the visible range.

Specular illumination comes from a different interaction. Rather than being absorbed and emitted, a specular reflection comes from a photon literally bouncing off of the material. Now, some materials (metals in particular) do have some effect on the color of specularly reflected photons. But, in general, the color of a specular reflection is based on the color of the incident light.

Note that the presence of one does not necessitate the lack of the other. These are independent concepts that have effects in independent ways.

The "texture" of a surface (roughness) determines ultimately how mirror-like the surface is (the dot(N, H) ^ k term tends to take this into account for Phong illumination). There are other factors that determine the strength of the specular reflection (typically taken into account by the OpenGL specular color of the material).

A surface cannot be described simply by giving a percent diffuse, and therefore the percent specular is 100 - that percent diffuse. It is just not that simple.

A surface that is prone to diffuse reflection can still have specular interactions. In fact, most surfaces that you see as being purely diffuse have quite a bit of specular characteristic to them, which is one reason why lots of rendered surfaces (especially in games) look very fake. Though it may be hard to consciously see the specular reflections, you expect them, and miss them when you don't see them. The specular characteristic to human skill is one of the reasons that making rendered humans is so hard.

Lastly, these two interactions are all you need to determine how a surface interacts with light. The diffuse term is pretty trivial; the standard OpenGL diffuse works just fine. It's the specular term that's the horrible pain. I've seen very large equations that only give approximations (good enough to get movie-quality graphics, but still approximate) to reality.

i don't agree with your thing, while it sounds cool, i don't think it works that easy.

say you have 100 lightparticles coming to hit your surface, and 20 of them get reflected by your quantummechanics. how much are left to do the diffuse absorbtion and resending? exactly, the other 80.

that means you prove with your statement that diffuse == 1-specular.

next, you describe how a lightparticle can interact with an atom: bounce off or dive into. while that is true, it does not map directly to the billions-of-billions realworld. it explains why light takes partially the color of the material (it just looses some energy => changes wavelength), but it does not explain diffuse and specular and reflections directly. a surface is terribly bumpy, resulting in reflections in all directions all the time. that in the molecular view at least. that results in much more complex behaviour than simply diffuse and specular in our marcospace.
brdf's are needed to integrate over a tiny bit of surface, and can only be really done statistically (as you just can't hit a single atom with your single lightparticle.. think about that raytracing time... and the huge precicion floats would need.. or would we use fixedpoint then? would be bether i think..)

your statements are not wrong (well, some are not correct, the % part at least is by your description right, and you state its wrong), but they don't fit into macrospace that easily.

V-man
10-06-2002, 12:47 PM
>>>Specular illumination comes from a different interaction. Rather than being absorbed and emitted, a specular reflection comes from a photon literally bouncing off of the material. Now, some materials (metals in particular) do have some effect on the color of specularly reflected photons. But, in general, the color of a specular reflection is based on the color of the incident light.<<<<<

You are saying that some materials, like metals have an effect on the color of specular reflected photons. Perhaps you are correct, so please explain this phenomenon.

>>>Note that the presence of one does not necessitate the lack of the other. These are independent concepts that have effects in independent ways.<<<

I dont agree with this and Dave wrote the reason. That is why I put then reflectivity_factor in the equation.

More physics: The interaction of light with materials depends on the depth they reach. This gives rise to color effects on the specular highlights. For example, a glass coated with gold (super thin) and typically used in the visors of astronauts, appears green when you look trough it, yet we all know that gold is "suppose" to look yellow. Some colors get absorbed more than others, some colors get reflected (specular) more than others.
So that means you need to have reflectivity as a function of wavelength. In our case, you need one for each color component. This would require another Texture Unit. You load tex0 (reflection_map), then tex1 (reflectivity_map) and you modulate them.

V-man

V-man
10-06-2002, 12:51 PM
Ah crap!

I knew I made a mistake. Better make that reflectivity_map into a secondary color. Or just keep it as a 1x1 texture, whichever is best.

V-man

[This message has been edited by V-man (edited 10-06-2002).]