Re: Pick dominant light from sh coeffs
Peter-Pike Sloan <[email protected]> Thu, 2 Feb 2012 17:21:51 -0700
| Newsgroups | gmane.games.devel.algorithms |
|---|---|
| Message-ID | <[email protected]> |
--===============7659306289747085365== Content-Type: multipart/alternative; boundary="_df1176eb-17f2-45d9-aa4d-0dcef5a3cbdd_" --_df1176eb-17f2-45d9-aa4d-0dcef5a3cbdd_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable This is actually quite straightforward. The optimal linear direction is -L[3]=2C-L[1]=2CL[3] - assuming the usual s= ign conventions=2C storage=2C etc. where in your case L could be the luminance of the RGB SH vectors. If you are using the coefficients from appendix 10=2C it turns out to be ev= en simpler - it is just the .xyz coefficients after doing a luminance weigh= ting of cAr/cAg/cAb. That give you the direction.=20 To generate the color of the light=2C you can simply evaluate the outgoing = radiance using the above direction (as in the shader code in the appendix)= =2C and that's the color for the light (if illuminating a white material th= at 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 S= H" on a technique to solve for both a colored directional light and an ambi= ent light given SH coefficients=2C but if you are using the storage in appe= ndix 10 it's a bit trickier since the DC term has been "polluted" by part o= f the quadratic ZH function to make evaluation faster. You would have to re= construct the original vector to do the math... Peter-Pike Sloan Date: Fri=2C 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=2C 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 supp= osedly in this paper http://research.microsoft.com/en-us/um/people/johnsny/= papers/ldprt.pdf=2C however I can't see it. Worse still=2C if it is in ther= e=2C 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=2C SharePoint=2C SQL - plus HTML5=2C CSS3=2C = MVC3=2C Metro Style Apps=2C 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=3Dgdalgorithms-list= = --_df1176eb-17f2-45d9-aa4d-0dcef5a3cbdd_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <html> <head> <style><!-- .hmmessage P { margin:0px=3B padding:0px } body.hmmessage { font-size: 10pt=3B font-family:Tahoma } --></style></head> <body class=3D'hmmessage'><div dir=3D'ltr'> This is actually quite straightforward.<div><br></div><div>The optimal line= ar direction is -L[3]=2C-L[1]=2CL[3] - assuming the usual sign conventions= =2C storage=2C etc.</div><div><br></div><div>where in your case L could be = the luminance of the RGB SH vectors.</div><div><br></div><div>If you are us= ing the coefficients from appendix 10=2C it turns out to be even simpler - = it is just the .xyz coefficients after doing a luminance weighting of cAr/c= Ag/cAb.</div><div><br></div><div>That give you the direction. =3B</div>= <div><br></div><div>To generate the color of the light=2C you can simply ev= aluate the outgoing radiance using the above direction (as in the shader co= de in the appendix)=2C 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 Conventional Lights from SH" = on a technique to solve for both a colored directional light and an ambient= light given SH coefficients=2C but if you are using the storage in appendi= x 10 it's a bit trickier since the DC term has been "polluted" by part of t= he quadratic ZH function to make evaluation faster. You would have to recon= struct the original vector to do the math...</div><div><br></div><div>Peter= -Pike Sloan</div><div><br></div><div><br><div><div id=3D"SkyDrivePlaceholde= r"></div><hr id=3D"stopSpelling">Date: Fri=2C 3 Feb 2012 09:22:21 +1000<br>= From: [email protected]<br>To: [email protected]= t<br>Subject: [Algorithms] Pick dominant light from sh coeffs<br><br><div>I= have =3B9 red=2C 9 green and 9 blue sh coefficients (packed using the = method in appendix 10 of =3B<a href=3D"http://www.ppsloan.org/publicati= ons/StupidSH36.pdf" target=3D"_blank">http://www.ppsloan.org/publications/S= tupidSH36.pdf</a>).</div><div> <br></div>I want to pick a single =3Bdominant =3Blight to use for s= pecular. How would I go about efficiently extracting the direction and colo= r of that light from the coefficients?<div><br></div><div>Looks like I need= to calculate the "optimal linear direction" which is supposedly in this pa= per =3B<a href=3D"http://research.microsoft.com/en-us/um/people/johnsny= /papers/ldprt.pdf" target=3D"_blank">http://research.microsoft.com/en-us/um= /people/johnsny/papers/ldprt.pdf</a>=2C =3Bhowever I can't see it. = =3BWorse still=2C if it is in there=2C it is probably an integral that I wi= ll struggle to turn into code!</div> <div><br></div><div>Thanks</div><div><br></div><div>Dan</div><div><div><br>= </div><div><br></div></div> <br>-----------------------------------------------------------------------= ------- Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio=2C SharePoint=2C SQL - plus HTML5=2C CSS3=2C = MVC3=2C Metro Style Apps=2C more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d<br>____________________________________= ___________ GDAlgorithms-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=3Dgdalgorithms-list= </div></div> </div></body> </html>= --_df1176eb-17f2-45d9-aa4d-0dcef5a3cbdd_-- --===============7659306289747085365== 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 --===============7659306289747085365== 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 --===============7659306289747085365==--