• FEATURED

View more

View more

View more

Image of the Day Submit

IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

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.

7 replies to this topic

#1Relfos  Members

Posted 04 February 2014 - 12:49 PM

I'm implementing radiosity into my level editor.

I found a sample online that did it in a very simple way, so I tried to adapt it to my engine.

The current version is somehow limited, in the sense that it generates a lightmap texture per triangle.

The algoritm is simple, for each pixel in each triangle render the scene from the point of view of the pixel.

Repeat it 8 times, to accumulate light.

There are some things that are puzzling me, why doing the acumulation requires 8 passes?

I tried with less passes, the scene was too dark.

I tried with more passes (12 I think), and now, the whole scene was white.

Shouldn't the scene colors converge to a certain value instead of getting full white?

Either I am not understanding this correctly, or there is a bug in this implementation maybe?

#2aregee  Members

Posted 04 February 2014 - 08:21 PM

I remember a good source on this subject many years ago, but I never exactly remember the name.  It was a long name, like Arty Fancy Chunky Pixel Ray Tracing Page or something like that.  I did however find a document that is heavily based on that page:

(At least all the illustration from that page is taken from that site.)

On page 11, you see different examples on how a scene looks after different passes.  Here is a quote from that page:

"The radiosity process slowly converges on a solution. Each pass is a little less different than the last, until eventually it becomes stable. Depending on the complexity of the scene, and the lightness of the surfaces, it may take a few, or a few thousand passes. It's really up to you when to stop it, and call it done."

In other words, it should converge, but I guess that if you illuminate a scene enough, you might be able to produce a scene that converges to completely white too, so it is hard to tell.

Edit: Found the original page: http://freespace.virgin.net/hugo.elias/  -- The name was: "The good-looking textured light-sourced bouncy fun smart and stretchy page" -- So much for memory...

Edited by aregee, 04 February 2014 - 08:33 PM.

#3MJP  Moderators

Posted 05 February 2014 - 01:01 AM

Shouldn't the scene colors converge to a certain value instead of getting full white?

Yes, it should definitely converge if you're doing it right. I would suspect that you have a bug, or that you're integrating incorrectly. Are you doing hemicube rendering?

#4Relfos  Members

Posted 05 February 2014 - 06:36 AM

I don't know much about radiosity yet. I just read about hemicube rendering, it says it requires rendering the scene to 5 viewports, no I am not doing that.

I render the scene from each patch point of view once, with a FOV of 90º

From what I've seen in my code, in each pass I render the scene for each patch, and add the resulting color to the patch current color.

This of course means that with enough passes, the color will accumulate to white. Maybe this is the incorrect way of doing it?

#5MJP  Moderators

Posted 05 February 2014 - 04:59 PM

To compute diffuse irradiance, you need to integrate all incoming lighting for a hemisphere around a point. A 90 degree perspective projection doesn't cover the entire hemisphere, which is why you need to render multiple times if you're using a perspective projection to capture the incoming lighting. However that should still be *mostly* okay, it just means you'd be missing lighting from grazing angles.

I'd suspect that your real problem is in the integration. What exactly are you doing with your data after you've rendered from the point of view of the patch? Like I said above, to get the correct irradiance you need to integrate the incoming lighting with the clamped cosine function. I would suggest reading the link that aregee posted above, or the page which it was based on.

#6Relfos  Members

Posted 05 February 2014 - 06:32 PM

I am using the following to calculate the integration:

For i:=0 to 31 do
For j:=0 to 31 do
_formFactor[i,j] := 0.5 + 0.5 * Sin(i*3.14/(_RadW-1) ) * Sin( j*3.14/(_RadH-1) );

When rendering a patch I am using 32x32 as viewport dimensions

#7Krypt0n  Members

Posted 06 February 2014 - 09:04 AM

Shouldn't the scene colors converge to a certain value instead of getting full white?

Yes, it should definitely converge if you're doing it right. I would suspect that you have a bug, or that you're integrating incorrectly. Are you doing hemicube rendering?

it doesn't have to be a bug, it can converge to something that is just brighter than what represents 'white' in that particular case. in every pass energy gets distributed further, but energy doesn't 'leak' anywhere, that's why everything just can get brighter or stay the same.

I would suggest to

1. switch to floats (halfs) lightmaps for the generation time.

2. tonemap those to LDR if you want to use LDR lightmaps for visualization (you might even do that per lightmap and save the mid tone value so you could 'reconstruct' the actual brightness for HDR rendering)

3. calculate the average brightness in every pass and output it, see if the step size of 'brightening' reduces every pass, then you could even estimate how long till the error reduces to a value you want (this might be very scene dependent, sometimes 5 passes, sometimes 50 passes).

#8Relfos  Members

Posted 06 February 2014 - 09:13 AM

Thanks for the suggestion, I'm currently using unsigned chars for the lightmap, changing to floats might help.

And the idea of checking the brightness in each pass is good, with that I might be able to automatically decide when is enough to stop doing passes

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.