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

## Recommended Posts

Hello! I am having some problems with my radiosity renderer. See image below for shooting energy from the top patch only in one direction. The code for computing form factors seems to be wrong. I want the light to be in a more circular shape. Why is it so quadratic? This is the code I am using:
// Precalculate form factors between patches
_radiosityFormFactors = new NScalar[size * size];
for (int i = 0; i < size; i++)
{

for (int j = 0; j < size; j++)
{
if (i == j)
{
continue;
}
index = i * size + j;

diff = patch1->_center.sub(patch0->_center);
diffLen = diff.getLength();
diffLen2 = diffLen * diffLen;
dir = diff.normalize();
dotPatch0 = patch0->_normal.dotProduct(dir);
dotPatch1 = -(patch1->_normal.dotProduct(dir));

if (dotPatch0 <= 0 || dotPatch1 <= 0)
{
continue;
}

formFactor = ((dotPatch0*dotPatch1) / (NMath3DUtility::_PI * diffLen2)) * patch0->_area;
}
}


The other problem I have is how to get rid of the seam clearly visible between the two triangles making up the bottom quad. I have a border around the textures so tiling quads will not produce seams due to filtering. But there is no border around the edge between the triangles so the black color in the texture is filtered with the whiter pixels. How can I fix this?

##### Share on other sites

Have I given too little information?

##### Share on other sites
Quote:
 Have I given too little information?

No, its just an extremely specific topic and not very many people have actually implemented radiosity from start to finish, so its no wonder that you havent received any replies so far.

Whenever you are posting screenshots regarding radiosity, disable texturing, so we can see the actual lightmap that has been calculated. From your current image its hard to tell whats going on, since the base material texture is of very high contrast, thus completely killing any radiosity effect.
Disable also any filtering, so we can see actual patches (texels).

As for border between triangles, you must make sure that you calculated also few texels behind the edge so that it gets filtered correctly.
Do you offset UV coords at vertices by half-texel ? Thats what must be done to prevent filtering with background of the lightmap texture (usually black).

Is the room regular box, i.e. walls have the same height as is the width ? Cant tell from black walls. If so, there are mistakes, because thats definitely not how it should look like after first shooting.

##### Share on other sites
Thanks for the input.

I fixed the problem with the visible seam between the triangles making up a quad.

You are right, the screen shots should only show the actual patches.

The box is a cube, the walls have the same height as the width. The screen shot also only shows ONE side of the hemicube, the downward direction. Shooting in the other four directions works correctly.

Unfortunately I still have the error with rectangular shape of the light.
If I lower the shooting patch so it's located just above the floor, the light is much brighter in the center of the floor and gets darker moving away of the center just as a normally light would do.

Maybe I have to put in some attenuation calculation into the form factor calculation...

##### Share on other sites
Post the screenshot with the patches visible (i.e. no texture filtering and no material texture selected - just lightmap). Its impossible to tell whats going on since we dont see the actual patches.

As for the attenuation, you are already doing this - through following part of the equation : "/ (NMath3DUtility::_PI * diffLen2)"
At quick glance it seems you have the equation right. Are all your patches of the same size ?

If you raise the position of the light up, does it affect patches on side walls, or do only 1-2 bottom rows of patches get lighted ?

Try creating much bigger box with many more patches, or make your patch size much smaller - this way youll be able to tell (by slowly raising the light position) if it behaves correctly from the start (as it seems to be the case), or it creates those quadratic shapes.
In this case, it could be an error/issue with the Exposure -i.e. the light gets clamped to white, so it seems quadratic, since there arent any more patches in the distance that would show the slow light attenuation.
Which means you could get the same effect by lowering your light intensity, or by adjusting the exposure coefficients.
Notice, that the smaller the patches are, the darker the scene is (assuming light patch has same area as all other patches) - this is taken care of in the Form-Factor equation by multiplying by the Patch Area.
Try all above options and let me know the outcome through screenshots.

##### Share on other sites
Now I am starting to get somewhere!

I found another stupid mistake. I did not setup the view correctly. The window was too small so only 4x4 patches were visible for receiving light everytime I shot from the hemicube sides.

Now I can go from here! Thanks for the inputs!

##### Share on other sites
It looks correct to me. I assume this is after first shooting pass, since the top wall is black. Could you try to post the same scene after, say, 100/1000 passes ? Id recommend to create 2 functions - first shall be for previews (1 pass per each light), second shall stop shooting after a threshold percentage of energy has been shot throughout the scene (so that you wont have to manually try several different amount of passes when youd like to have a nicely lit scene).

Did you try shadows already ? What do you use for visibility testing ?
EDIT: Rated you up for getting that far with radiosity ;-) Congrats !

##### Share on other sites
I draw the world 5 times from the shooting patch for the 5 hemicube sides (resolution 128), call glReadPixels to find visible patches (each patch has a unique color identifing it) and calculate the correct radiosity. Visibility will come for free since occluded patches will not be drawn to the screen buffer.

The screen shot shows 100 passes.

• 33
• 12
• 10
• 9
• 9
• ### Forum Statistics

• Total Topics
631354
• Total Posts
2999490
×

## Important Information

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!