Precalculate lightmap and specular reflection?

Started by
5 comments, last by kalle_h 8 years, 7 months ago

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.

Advertisement

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

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.

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.

Thanks for reply~

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.

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.

Thanks for reply~

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.

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.


The reason they do this is that IBL probes are typically very sparse, due to their large memory footprint. When your sample points are very sparse, you end up with a lot of error when that probe is used by a surface that's relatively far away from the sample position. This typically manifests as occlusion problems: the probe has visibility to a bright surface that shouldn't be visible from the surface being shaded, and so you see the reflections even though they should have been occluded. On the other hand, 2D lightmap samples tend to be much higher density since they store less data per texel. So the idea behind normalization is that you try to make use of the higher-frequency visibility data baked into lightmap by combining it with the IBL probes. It can introduce lots of new errors, but it can still be an overall improvement since lack of occlusion can be very noticable.

On a related note, this was a major motivation for using Spherical Gaussians in The Order, since the SG lightmaps have high spatial density but still allow for low-to-mid frequency specular.

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)

This topic is closed to new replies.

Advertisement