# Precalculate lightmap and specular reflection?

This topic is 1136 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm new to computer graphics and I got some questions about lightmap.

This is the rendering equation,

[attachment=29030:render.png]

and if I use BRDF with

[attachment=29031:render (1).png]

I got,

[attachment=29032:render (2).png]

From my understanding, the diffuse part [attachment=29033:render (3).png] is view independent, so it could be precalculated.

But the specular part [attachment=29034:render (4).png] is view dependent, IBL could be used to handle indirect specular(https://seblagarde.wordpress.com/2011/08/17/hello-world/), but how about direct specular. could they be precomputed in practice?

Here lists some of my ideas.

1. The lightmap could store indirect light, all the direct light are computed from punctual light sources at runtime.

2. Store main light direction in the lightmap, use that direction to calulate specular reflection.

3. Store  light source in the cubemap(IBL), not sure how to do that.

##### Share on other sites

All 3 of these things are already done, though for the most part (99%+) it's that first one more or less.

##### Share on other sites
For 1/3, you can use Spherical Harmonics, the H-basis, the Half-Life 2 basis, etc..

These all store a very compressed/blurry "IBL" for each texel in the lightmap.

2 is very simple and pretty cheap, it's basically just a normal-map alongside your lightmap. It has some subtle artefacts around shadows where the dominant direction suddenly changes, but does allow simple specular to be present.

Alternatively, use full IBL probes instead. You can try and merge them with the lightmaps by finding the average color of the IBL probe, dividing all it's pixels by that value (resulting cubemap will be very bland/grey), and then multiplying it by a value stored in your lightmap.

##### Share on other sites

For 1/3, you can use Spherical Harmonics, the H-basis, the Half-Life 2 basis, etc..

These all store a very compressed/blurry "IBL" for each texel in the lightmap.

2 is very simple and pretty cheap, it's basically just a normal-map alongside your lightmap. It has some subtle artefacts around shadows where the dominant direction suddenly changes, but does allow simple specular to be present.

Alternatively, use full IBL probes instead. You can try and merge them with the lightmaps by finding the average color of the IBL probe, dividing all it's pixels by that value (resulting cubemap will be very bland/grey), and then multiplying it by a value stored in your lightmap.

2. It seems Unity stores the specular direction in lightmap. For UnrealEngine, I'm not sure now.

3. I'm more interest in the IBL approach, Call of Duty uses the merge method(http://blog.selfshadow.com/publications/s2013-shading-course/), but that is used for indirect light. I don't understand why the lightmap luminance could affect the specular hightlight, which is view dependent.

Edited by lostyzd

##### Share on other sites

For 1/3, you can use Spherical Harmonics, the H-basis, the Half-Life 2 basis, etc..

These all store a very compressed/blurry "IBL" for each texel in the lightmap.

2 is very simple and pretty cheap, it's basically just a normal-map alongside your lightmap. It has some subtle artefacts around shadows where the dominant direction suddenly changes, but does allow simple specular to be present.

Alternatively, use full IBL probes instead. You can try and merge them with the lightmaps by finding the average color of the IBL probe, dividing all it's pixels by that value (resulting cubemap will be very bland/grey), and then multiplying it by a value stored in your lightmap.

2. It seems Unity stores the specular direction in lightmap. For UnrealEngine, I'm not sure now.

3. I'm more interest in the IBL approach, Call of Duty uses the merge method(http://blog.selfshadow.com/publications/s2013-shading-course/), but that is used for indirect light. I don't understand why the lightmap luminance could affect the specular hightlight, which is view dependent.

Spherical harmonics: https://www.cg.tuwien.ac.at/research/publications/2010/Habel-2010-EIN/ and more recently Spherical guassians: http://www.readyatdawn.com/presentations/ (Advanced Lighting) Give you lightmaps with directional information at each point. Originally this was used for getting normal mapping and such correct lighting while keeping lightmap texel density low, but now EX the Call of Duty paper you can also use it to modify specular.

Edited by Frenetic Pony

##### Share on other sites

It's also quite usual to use ssao to darken specular reflections. Some use straight AO * specular but there are also some better approximations that try to take account view dependency and roughness.

like: lerp(1.0, ao, roughness * (1.0 - nDotV))

or:  saturate(pow(nDotV + ao, roughness*roughness) - 1.0 + ao)

1. 1
2. 2
Rutin
25
3. 3
4. 4
5. 5

• 10
• 10
• 13
• 20
• 14
• ### Forum Statistics

• Total Topics
632949
• Total Posts
3009368
• ### Who's Online (See full list)

There are no registered users currently online

×