•      Sign In
• Create Account

## [solved]Irradiance cube map rendering

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1LM-Crashy  Members

582
Like
0Likes
Like

Posted 28 March 2014 - 05:40 AM

[EDIT]Nevermind, I've found the answer by reading one more time the linked paper.

Hi Gamedev,

I'm currently implementing ambient lighting using spherical harmonics, inspired by this paper, and I'm looking for some details.
Basically, I don't understand how they do the real time relighting stuff described in slides 7 to 10

Right now I'm rendering a bunch of environment cube maps with my scene rendered with only the textures color, no lighting at all.

Then I compute the spherical harmonics for the cube maps, and the final lighting shader looks like this:


//final lighting code
float4 finalColor = irradiance*texture + NDotL * shadows * texture;

This gives nice results but I don't think this is the right way to do it, and I should render my scene with full shadowing, using something like:


//cubemap render code
float4 color = NDotL * shadows * texture;

Which seems to be a better way, as lit zones will "generate" more irradiance than unlit ones.
And then change the final lighting equation to something like that:


//final lighting code
float4 finalColor = texture+irradiance+NDotL * shadows * texture;

But this bothers me because if the light direction changes, I need to recompute all the cube maps, which is not "real time friendly".
So what am I missing ?

Thank you very much for any help !

### #2Javier Meseguer de Paz  Members

375
Like
0Likes
Like

Posted 28 March 2014 - 07:15 AM

Here Hodgman provided an explanation of Far Cry's algorithm that you might find useful: http://www.gamedev.net/topic/649604-what-on-earth-is-far-cry-3s-deferred-radiance-transfer/

“We should forget about small efficiencies, say about 97% of the time; premature optimization is the root of all evil” -  Donald E. Knuth, Structured Programming with go to Statements

"First you learn the value of abstraction, then you learn the cost of abstraction, then you're ready to engineer" - Ken Beck, Twitter

### #3LM-Crashy  Members

582
Like
0Likes
Like

Posted 28 March 2014 - 07:16 AM

Thank you, I'm reading it !

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.