Sign in to follow this  

Precalculate lightmap and specular reflection?

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
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.

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.

Edited by lostyzd

Share this post


Link to post
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.

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.

Edited by Frenetic Pony

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this