Re: Pick dominant light from sh coeffs
Dan Treble <[email protected]> Fri, 3 Feb 2012 11:28:09 +1000
| Newsgroups | gmane.games.devel.algorithms |
|---|---|
| Message-ID | <CADbTRxjeLKKPjnYZhpMbxX3hOeyy_=VXDwNWYwwz1jdXnC77yA@mail.gmail.com> |
--===============7022789606516625887== Content-Type: multipart/alternative; boundary=14dae934093fb84a7404b8053971 --14dae934093fb84a7404b8053971 Content-Type: text/plain; charset=ISO-8859-1 So in layman's terms I am using these three http://imgur.com/oOddh coefficients to derive the direction of the strongest light. Makes sense now. That is much easier than I expected, thank you for taking the time to explain it. On Fri, Feb 3, 2012 at 10:21 AM, Peter-Pike Sloan < [email protected]> wrote: > This is actually quite straightforward. > > The optimal linear direction is -L[3],-L[1],L[3] - assuming the usual sign > conventions, storage, etc. > > where in your case L could be the luminance of the RGB SH vectors. > > If you are using the coefficients from appendix 10, it turns out to be > even simpler - it is just the .xyz coefficients after doing a luminance > weighting of cAr/cAg/cAb. > > That give you the direction. > > To generate the color of the light, you can simply evaluate the outgoing > radiance using the above direction (as in the shader code in the appendix), > and that's the color for the light (if illuminating a white material that > is the light in the given direction that would give you the same diffuse > response as the SH probe.) > > See the section of the paper titled: "Extracting Conventional Lights from > SH" on a technique to solve for both a colored directional light and an > ambient light given SH coefficients, but if you are using the storage in > appendix 10 it's a bit trickier since the DC term has been "polluted" by > part of the quadratic ZH function to make evaluation faster. You would have > to reconstruct the original vector to do the math... > > Peter-Pike Sloan > > > ------------------------------ > Date: Fri, 3 Feb 2012 09:22:21 +1000 > From: [email protected] > > To: [email protected] > Subject: [Algorithms] Pick dominant light from sh coeffs > > I have 9 red, 9 green and 9 blue sh coefficients (packed using the method > in appendix 10 of http://www.ppsloan.org/publications/StupidSH36.pdf). > > I want to pick a single dominant light to use for specular. How would I go > about efficiently extracting the direction and color of that light from the > coefficients? > > Looks like I need to calculate the "optimal linear direction" which is > supposedly in this paper > http://research.microsoft.com/en-us/um/people/johnsny/papers/ldprt.pdf, however > I can't see it. Worse still, if it is in there, it is probably an integral > that I will struggle to turn into code! > > Thanks > > Dan > > > > ------------------------------------------------------------------------------ > Keep Your Developer Skills Current with LearnDevNow! The most comprehensive > online learning library for Microsoft developers is just $99.99! Visual > Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. > Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnow-d2d > _______________________________________________ GDAlgorithms-list mailing > list [email protected] > https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list > > > ------------------------------------------------------------------------------ > Try before you buy = See our experts in action! > The most comprehensive online learning library for Microsoft developers > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, > Metro Style Apps, more. Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnow-dev2 > _______________________________________________ > GDAlgorithms-list mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list > --14dae934093fb84a7404b8053971 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div>So in=A0layman's terms I am using these three=A0<a href=3D"http://= imgur.com/oOddh">http://imgur.com/oOddh</a>=A0coefficients to derive the di= rection of the strongest light. Makes sense now.<div><br></div><div>That is= much easier than I expected, thank you for taking the time to explain it.<= /div> <br><div class=3D"gmail_quote">On Fri, Feb 3, 2012 at 10:21 AM, Peter-Pike = Sloan <span dir=3D"ltr"><<a href=3D"mailto:[email protected]"= >[email protected]</a>></span> wrote:<br><blockquote class=3D= "gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding= -left:1ex"> <div><div dir=3D"ltr"> This is actually quite straightforward.<div><br></div><div>The optimal line= ar direction is -L[3],-L[1],L[3] - assuming the usual sign conventions, sto= rage, etc.</div><div><br></div><div>where in your case L could be the lumin= ance of the RGB SH vectors.</div> <div><br></div><div>If you are using the coefficients from appendix 10, it = turns out to be even simpler - it is just the .xyz coefficients after doing= a luminance weighting of cAr/cAg/cAb.</div><div><br></div><div>That give y= ou the direction.=A0</div> <div><br></div><div>To generate the color of the light, you can simply eval= uate the outgoing radiance using the above direction (as in the shader code= in the appendix), and that's the color for the light (if illuminating = a white material that is the light in the given direction that would give y= ou the same diffuse response as the SH probe.)</div> <div><br></div><div>See the section of the paper titled: "Extracting C= onventional Lights from SH" on a technique to solve for both a colored= directional light and an ambient light given SH coefficients, but if you a= re using the storage in appendix 10 it's a bit trickier since the DC te= rm has been "polluted" by part of the quadratic ZH function to ma= ke evaluation faster. You would have to reconstruct the original vector to = do the math...</div> <div><br></div><div>Peter-Pike Sloan</div><div><br></div><div><br><div><div= ></div><hr>Date: Fri, 3 Feb 2012 09:22:21 +1000<br>From: <a href=3D"mailto:= [email protected]" target=3D"_blank">[email protected]</a><div = class=3D"im"> <br>To: <a href=3D"mailto:[email protected]" target= =3D"_blank">[email protected]</a><br>Subject: [Algori= thms] Pick dominant light from sh coeffs<br><br></div><div><div></div><div = class=3D"h5"> <div>I have=A09 red, 9 green and 9 blue sh coefficients (packed using the m= ethod in appendix 10 of=A0<a href=3D"http://www.ppsloan.org/publications/St= upidSH36.pdf" target=3D"_blank">http://www.ppsloan.org/publications/StupidS= H36.pdf</a>).</div> <div> <br></div>I want to pick a single=A0dominant=A0light to use for specular. H= ow would I go about efficiently extracting the direction and color of that = light from the coefficients?<div><br></div><div>Looks like I need to calcul= ate the "optimal linear direction" which is supposedly in this pa= per=A0<a href=3D"http://research.microsoft.com/en-us/um/people/johnsny/pape= rs/ldprt.pdf" target=3D"_blank">http://research.microsoft.com/en-us/um/peop= le/johnsny/papers/ldprt.pdf</a>,=A0however I can't see it.=A0Worse stil= l, if it is in there, it is probably an integral that I will struggle to tu= rn into code!</div> <div><br></div><div>Thanks</div><div><br></div><div>Dan</div><div><div><br>= </div><div><br></div></div> <br></div></div>-----------------------------------------------------------= ------------------- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! <a href=3D"http://p.sf.net/sfu/learndevnow-d2d" target=3D"_blank">http://p.= sf.net/sfu/learndevnow-d2d</a><br>_________________________________________= ______ GDAlgorithms-list mailing list <a href=3D"mailto:[email protected]" target=3D"_blank= ">[email protected]</a> <a href=3D"https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list" = target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/gdalgorithms= -list</a> Archives: <a href=3D"http://sourceforge.net/mailarchive/forum.php?forum_name=3Dgdalgo= rithms-list" target=3D"_blank">http://sourceforge.net/mailarchive/forum.php= ?forum_name=3Dgdalgorithms-list</a></div></div> </div></div> <br>-----------------------------------------------------------------------= -------<br> Try before you buy =3D See our experts in action!<br> The most comprehensive online learning library for Microsoft developers<br> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,<br= > Metro Style Apps, more. Free future releases when you subscribe now!<br> <a href=3D"http://p.sf.net/sfu/learndevnow-dev2" target=3D"_blank">http://p= .sf.net/sfu/learndevnow-dev2</a><br>_______________________________________= ________<br> GDAlgorithms-list mailing list<br> <a href=3D"mailto:[email protected]">GDAlgorithms-lis= [email protected]</a><br> <a href=3D"https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list" = target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/gdalgorithms= -list</a><br> Archives:<br> <a href=3D"http://sourceforge.net/mailarchive/forum.php?forum_name=3Dgdalgo= rithms-list" target=3D"_blank">http://sourceforge.net/mailarchive/forum.php= ?forum_name=3Dgdalgorithms-list</a><br></blockquote></div><br></div> --14dae934093fb84a7404b8053971-- --===============7022789606516625887== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 --===============7022789606516625887== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ GDAlgorithms-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list --===============7022789606516625887==--