TheRealMJP / TheRealMJP.github.io

Backing repo for my blog
16 stars 1 forks source link

Radiosity, DX11 Style #6

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

Radiosity, DX11 Style

https://therealmjp.github.io/posts/radiosity-dx11-style/

limztudio commented 3 years ago

Thank you for sharing your knowledge of Radiosity, SH and others! It was really helpful.
But on your source code, I think there's a small mistake which is the calculating summation weight of SH.

MeshBaker.cpp Line 205:

weightSum *= 6.0f;

Because the pseudo code written in the paper Stupid Spherical Harmonics (SH) Tricks, it assumed to project 6 faces of cube, but on your source code, it projects 5 faces of hemicube.
So I think the code is more proper when it multiplies 3 rather than 6. like,

weightSum *= 3.0f;

So, how do you think? I want to hear your opinion.
Hope you have a wonderful day and sorry for my bad English.

TheRealMJP commented 3 years ago

Hey there, thanks for looking into this! It's been so long since I wrote this code, I had to take some time to refresh my memory!

So I think that what I have there is still producing the correct result, since it's the weighting you would use if you still had 6 faces but the "bottom half" all had values of 0. If you were to set it up so that you restricted the domain to only the "top half" then I think you would indeed multiply by 3.0 instead of 6.0, but you would also want to change the PDF so that it uses the area of a hemisphere (2 Pi) rather than the area of a sphere (4 pi). And in that case the factor of two cancels out, and you would end up with exactly the same final weight. I agree though that it would probably make more sense in terms of code clarity to use the hemispherical integral instead of the full spherical integral.