Re: [Algorithms] Extracting Lights from a Dynamic SH Light Environment From: Willem de Boer - 2007-03-01 17:17:00 ```Hi there - Spherical harmonics are inherently very bad at representing directional lig= hts. When you visualise at the approximated radiance function you'll see horribl= e ringing artefacts. Here's one thing I don't understand: "But when we move closer to e.g. the red light, we're suddenly extracting two red lights from the direction of the red light." How is it possible to move 'closer' to a directional lightsource? Surely this assumption of being able to move closer must have something to do with you getting the maths mixed up? One question to you though. Since you are trying to extract directional lig= ht- sources from an SH projection that you've generated from the directional light sources yourself, is it not possible to retain these original lightso= urces instead of trying to extract them? It would save you a great amount of hassle that way. -----Original Message----- From: gdalgorithms-list-bounces@... [mailto:gdalgorithms-= list-bounces@...] On Behalf Of Martin Ecker Sent: 01 March 2007 17:02 To: gdalgorithms-list@... Subject: [Algorithms] Extracting Lights from a Dynamic SH Light Environment Hi, I have a question about the mathematics involved in extracting directional lights from a lighting environment represented in a spherical harmonics basis. We want to use this to light our in-game characters. Every couple of frames the lights affecting a character in the scene are collected. They are each projected into spherical harmonics (for this we simply treat them all as directional lights, so the projection is simply SH(normalized_direction) * intensity) and the resulting coefficients are added up to create a low-frequency approximation of the lighting environment around the character. Now, we'd like to extract a few directional lights from that lighting environment, which we use to do regular phong shading, and the remaining light environment could be used in e.g. the vertex shader to do SH diffuse lighting. Currently, we're doing this by determining the maximum light intensity direction in SH, which will be the light direction vector of our directional light. Now we evaluate our SH light environment using that direction vector in order to get the light intensity, i.e. intensity =3D Dot(light_environment_sh, SH(normalized_light_direction)). So now that we have the direction vector and intensity of our directional light, we extract it from the SH light environment by projecting that directional light into the SH basis and subtracting it from the light environment. Apparently, somewhere along the line we're getting our math wrong, because when we extract the first directional light it doesn't have the expected intensity. As an example, imagine a character standing in between two directional lights, a green light from the left and a red light from the right. When we stand in the middle of the two lights everything looks okay, i.e. the character is lit half green and half red. But when we move closer to e.g. the red light, we're suddenly extracting two red lights from the direction of the red light. When extracting the first red light from such a lighting environment I would expect most of the red intensity to go into that first red light and then the second extracted light would have a kind of grayish ambient color, which starts fading into green the closer we get to the green light. If anyone has done something similar, we'd appreciate any insights. Also, does anyone know of any good tricks to get rid of or at least hide the lighting discontinuities we get due to the sometimes harsh direction changes of the extracted lights? Thanks, Martin Ecker ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share you= r opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3DDE= VDEV _______________________________________________ GDAlgorithms-list mailing list GDAlgorithms-list@... https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=3D6188 ```
 [Algorithms] Extracting Lights from a Dynamic SH Light Environment From: Martin Ecker - 2007-03-01 17:01:40 ```Hi, I have a question about the mathematics involved in extracting directional lights from a lighting environment represented in a spherical harmonics basis. We want to use this to light our in-game characters. Every couple of frames the lights affecting a character in the scene are collected. They are each projected into spherical harmonics (for this we simply treat them all as directional lights, so the projection is simply SH(normalized_direction) * intensity) and the resulting coefficients are added up to create a low-frequency approximation of the lighting environment around the character. Now, we'd like to extract a few directional lights from that lighting environment, which we use to do regular phong shading, and the remaining light environment could be used in e.g. the vertex shader to do SH diffuse lighting. Currently, we're doing this by determining the maximum light intensity direction in SH, which will be the light direction vector of our directional light. Now we evaluate our SH light environment using that direction vector in order to get the light intensity, i.e. intensity =3D Dot(light_environment_sh, SH(normalized_light_direction)). So now that we have the direction vector and intensity of our directional light, we extract it from the SH light environment by projecting that directional light into the SH basis and subtracting it from the light environment. Apparently, somewhere along the line we're getting our math wrong, because when we extract the first directional light it doesn't have the expected intensity. As an example, imagine a character standing in between two directional lights, a green light from the left and a red light from the right. When we stand in the middle of the two lights everything looks okay, i.e. the character is lit half green and half red. But when we move closer to e.g. the red light, we're suddenly extracting two red lights from the direction of the red light. When extracting the first red light from such a lighting environment I would expect most of the red intensity to go into that first red light and then the second extracted light would have a kind of grayish ambient color, which starts fading into green the closer we get to the green light. If anyone has done something similar, we'd appreciate any insights. Also, does anyone know of any good tricks to get rid of or at least hide the lighting discontinuities we get due to the sometimes harsh direction changes of the extracted lights?=20 Thanks, Martin Ecker ```
 Re: [Algorithms] Extracting Lights from a Dynamic SH Light Environment From: Willem de Boer - 2007-03-01 17:17:00 ```Hi there - Spherical harmonics are inherently very bad at representing directional lig= hts. When you visualise at the approximated radiance function you'll see horribl= e ringing artefacts. Here's one thing I don't understand: "But when we move closer to e.g. the red light, we're suddenly extracting two red lights from the direction of the red light." How is it possible to move 'closer' to a directional lightsource? Surely this assumption of being able to move closer must have something to do with you getting the maths mixed up? One question to you though. Since you are trying to extract directional lig= ht- sources from an SH projection that you've generated from the directional light sources yourself, is it not possible to retain these original lightso= urces instead of trying to extract them? It would save you a great amount of hassle that way. -----Original Message----- From: gdalgorithms-list-bounces@... [mailto:gdalgorithms-= list-bounces@...] On Behalf Of Martin Ecker Sent: 01 March 2007 17:02 To: gdalgorithms-list@... Subject: [Algorithms] Extracting Lights from a Dynamic SH Light Environment Hi, I have a question about the mathematics involved in extracting directional lights from a lighting environment represented in a spherical harmonics basis. We want to use this to light our in-game characters. Every couple of frames the lights affecting a character in the scene are collected. They are each projected into spherical harmonics (for this we simply treat them all as directional lights, so the projection is simply SH(normalized_direction) * intensity) and the resulting coefficients are added up to create a low-frequency approximation of the lighting environment around the character. Now, we'd like to extract a few directional lights from that lighting environment, which we use to do regular phong shading, and the remaining light environment could be used in e.g. the vertex shader to do SH diffuse lighting. Currently, we're doing this by determining the maximum light intensity direction in SH, which will be the light direction vector of our directional light. Now we evaluate our SH light environment using that direction vector in order to get the light intensity, i.e. intensity =3D Dot(light_environment_sh, SH(normalized_light_direction)). So now that we have the direction vector and intensity of our directional light, we extract it from the SH light environment by projecting that directional light into the SH basis and subtracting it from the light environment. Apparently, somewhere along the line we're getting our math wrong, because when we extract the first directional light it doesn't have the expected intensity. As an example, imagine a character standing in between two directional lights, a green light from the left and a red light from the right. When we stand in the middle of the two lights everything looks okay, i.e. the character is lit half green and half red. But when we move closer to e.g. the red light, we're suddenly extracting two red lights from the direction of the red light. When extracting the first red light from such a lighting environment I would expect most of the red intensity to go into that first red light and then the second extracted light would have a kind of grayish ambient color, which starts fading into green the closer we get to the green light. If anyone has done something similar, we'd appreciate any insights. Also, does anyone know of any good tricks to get rid of or at least hide the lighting discontinuities we get due to the sometimes harsh direction changes of the extracted lights? Thanks, Martin Ecker ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share you= r opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3DDE= VDEV _______________________________________________ GDAlgorithms-list mailing list GDAlgorithms-list@... https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=3D6188 ```