## Re: [Algorithms] Projecting SH into the Half life 2 basis

 Re: [Algorithms] Projecting SH into the Half life 2 basis From: Matt Pharr - 2008-05-20 17:24:23 Attachments: Message as HTML In general, conversion of coefficients in one basis can be converted to another with a matrix multiplication of the sort that Peter-Pike showed in that paper. Here is the general idea: Assume you have a function f(x) represented in a basis b_i(x) with coefficients a_i: f(x) = \sum_i a_i b_i(x) And say you want to represent it in a new basis c_i(x) with coefficients d_i. Assuming an orthonormal basis, etc, you project by integrating the function to be projected with the basis functions c_i(x): d_i = \int c_i(x) f(x) dx If you expand f(x) out, you get: d_i = \int c_i(x) (\sum_j a_j b_j(x)) dx You can interchange the integral and the sum and pull the constants a_j out of the integral: d_i = \sum_j a_j \int c_i(x) b_j(x) dx And voila, you can see that the integral can be precomputed given the pair of basis functions you care about and then represented as a matrix; this matrix times the a_j column vector gives the new coefficients d_i. Hope this helps. (And hope I didn't mess up the math at this early hour of the day.) -matt -- Matt Pharr http://pharr.org/matt On May 20, 2008, at 12:03 AM, Rowan Wyborn (2K Australia) wrote: > Howdy, > > The paper “Normal Mapping for Precomputed Radiance Transfer” (http://www.ppsloan.org/publications/ > ) contains a handy matrix to project 3rd order SH into the half life > 2 basis. I was just wondering if anyone (or P.P.S if he’s still on > this list J) had any insights into how this matrix is derived? > > Additionally I wonder whether its possible to generalize this > solution to an arbitrarily oriented set of basis vectors? Its not > clear to me whether the results in this paper for the HL2 basis are > achieved by: > a) rotating the SH lighting into each vertex’s basis > orientation and projecting using the given matrix > or > b) by generating the projection matrix on the fly for each > vertex’s basis orientation. > > Anyone got any ideas? > > Thanks, > Rowan > > > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________ > GDAlgorithms-list mailing list > GDAlgorithms-list@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list 

 [Algorithms] Projecting SH into the Half life 2 basis From: Rowan Wyborn (2K Australia) - 2008-05-20 07:03:41 Attachments: Message as HTML Howdy, The paper "Normal Mapping for Precomputed Radiance Transfer" (http://www.ppsloan.org/publications/) contains a handy matrix to project 3rd order SH into the half life 2 basis. I was just wondering if anyone (or P.P.S if he's still on this list J) had any insights into how this matrix is derived? Additionally I wonder whether its possible to generalize this solution to an arbitrarily oriented set of basis vectors? Its not clear to me whether the results in this paper for the HL2 basis are achieved by: a) rotating the SH lighting into each vertex's basis orientation and projecting using the given matrix or b) by generating the projection matrix on the fly for each vertex's basis orientation. Anyone got any ideas? Thanks, Rowan 
 Re: [Algorithms] Projecting SH into the Half life 2 basis From: Matt Pharr - 2008-05-20 17:24:23 Attachments: Message as HTML In general, conversion of coefficients in one basis can be converted to another with a matrix multiplication of the sort that Peter-Pike showed in that paper. Here is the general idea: Assume you have a function f(x) represented in a basis b_i(x) with coefficients a_i: f(x) = \sum_i a_i b_i(x) And say you want to represent it in a new basis c_i(x) with coefficients d_i. Assuming an orthonormal basis, etc, you project by integrating the function to be projected with the basis functions c_i(x): d_i = \int c_i(x) f(x) dx If you expand f(x) out, you get: d_i = \int c_i(x) (\sum_j a_j b_j(x)) dx You can interchange the integral and the sum and pull the constants a_j out of the integral: d_i = \sum_j a_j \int c_i(x) b_j(x) dx And voila, you can see that the integral can be precomputed given the pair of basis functions you care about and then represented as a matrix; this matrix times the a_j column vector gives the new coefficients d_i. Hope this helps. (And hope I didn't mess up the math at this early hour of the day.) -matt -- Matt Pharr http://pharr.org/matt On May 20, 2008, at 12:03 AM, Rowan Wyborn (2K Australia) wrote: > Howdy, > > The paper “Normal Mapping for Precomputed Radiance Transfer” (http://www.ppsloan.org/publications/ > ) contains a handy matrix to project 3rd order SH into the half life > 2 basis. I was just wondering if anyone (or P.P.S if he’s still on > this list J) had any insights into how this matrix is derived? > > Additionally I wonder whether its possible to generalize this > solution to an arbitrarily oriented set of basis vectors? Its not > clear to me whether the results in this paper for the HL2 basis are > achieved by: > a) rotating the SH lighting into each vertex’s basis > orientation and projecting using the given matrix > or > b) by generating the projection matrix on the fly for each > vertex’s basis orientation. > > Anyone got any ideas? > > Thanks, > Rowan > > > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________ > GDAlgorithms-list mailing list > GDAlgorithms-list@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list 
 Re: [Algorithms] Projecting SH into the Half life 2 basis From: Bruce Woodard - 2008-05-20 17:33:30 Attachments: Message as HTML IIRC, Peter went over the derivation on this mailing list. Might be worth a troll through the archives. Also, FWIW (realizing that Peter will likely groan with disgust) for Warhawk I simply did a standard SH lookup per basis vector (spun into world-space) in my vertex shader. I used this as a way to mix my ambient volume lighting and point lights for a constant per-pixel (HL2 lookup) cost. ---bruce ________________________________ From: gdalgorithms-list-bounces@... [mailto:gdalgorithms-list-bounces@...] On Behalf Of Rowan Wyborn (2K Australia) Sent: Tuesday, May 20, 2008 1:04 AM To: gdalgorithms-list@... Subject: [Algorithms] Projecting SH into the Half life 2 basis Howdy, The paper "Normal Mapping for Precomputed Radiance Transfer" (http://www.ppsloan.org/publications/) contains a handy matrix to project 3rd order SH into the half life 2 basis. I was just wondering if anyone (or P.P.S if he's still on this list :-)) had any insights into how this matrix is derived? Additionally I wonder whether its possible to generalize this solution to an arbitrarily oriented set of basis vectors? Its not clear to me whether the results in this paper for the HL2 basis are achieved by: a) rotating the SH lighting into each vertex's basis orientation and projecting using the given matrix or b) by generating the projection matrix on the fly for each vertex's basis orientation. Anyone got any ideas? Thanks, Rowan 
 Re: [Algorithms] Projecting SH into the Half life 2 basis From: Jon Watte - 2008-05-20 18:58:38 Bruce Woodard wrote: > > IIRC, Peter went over the derivation on this mailing list. Might be > worth a troll through the archives. > > > "Trawl." You want to do a trawl through the archives. "Trolling" and "trawling" are two very different activities. Sorry, pet peeve. We now return to our regularly scheduled math-heavy, grammar-lite content. Sincerely, jw 
 Re: [Algorithms] Projecting SH into the Half life 2 basis From: Rowan Wyborn (2K Australia) - 2008-05-21 05:38:15 Attachments: Message as HTML Hi Bruce, Yeah I'm not sure I follow why in your case its incorrect to do a standard cosine lobe SH lookup per basis vector (ala irradiance env mapping). Afterall that's exactly what the HL2 basis stores, the cosine weighted incident lighting along each basis vector. I was thinking about trying to encode the actual PRT transfer SH with a non clamped HL2 basis (which needs a proper basis projection)... I'm yet to sit down and try and wade through the maths thou if anyone has any thoughts J Also thanks matt for the basis change derivation, explains things perfectly. Thanks, Rowan From: gdalgorithms-list-bounces@... [mailto:gdalgorithms-list-bounces@...] On Behalf Of Bruce Woodard Sent: Wednesday, 21 May 2008 3:32 AM To: Game Development Algorithms Subject: Re: [Algorithms] Projecting SH into the Half life 2 basis IIRC, Peter went over the derivation on this mailing list. Might be worth a troll through the archives. Also, FWIW (realizing that Peter will likely groan with disgust) for Warhawk I simply did a standard SH lookup per basis vector (spun into world-space) in my vertex shader. I used this as a way to mix my ambient volume lighting and point lights for a constant per-pixel (HL2 lookup) cost. ---bruce ________________________________ From: gdalgorithms-list-bounces@... [mailto:gdalgorithms-list-bounces@...] On Behalf Of Rowan Wyborn (2K Australia) Sent: Tuesday, May 20, 2008 1:04 AM To: gdalgorithms-list@... Subject: [Algorithms] Projecting SH into the Half life 2 basis Howdy, The paper "Normal Mapping for Precomputed Radiance Transfer" (http://www.ppsloan.org/publications/) contains a handy matrix to project 3rd order SH into the half life 2 basis. I was just wondering if anyone (or P.P.S if he's still on this list J) had any insights into how this matrix is derived? Additionally I wonder whether its possible to generalize this solution to an arbitrarily oriented set of basis vectors? Its not clear to me whether the results in this paper for the HL2 basis are achieved by: a) rotating the SH lighting into each vertex's basis orientation and projecting using the given matrix or b) by generating the projection matrix on the fly for each vertex's basis orientation. Anyone got any ideas? Thanks, Rowan 
 Re: [Algorithms] Projecting SH into the Half life 2 basis From: Bruce Woodard - 2008-05-21 21:03:57 Attachments: Message as HTML "Yeah I'm not sure I follow why in your case its incorrect to do a standard cosine lobe SH lookup per basis vector (ala irradiance env mapping). Afterall that's exactly what the HL2 basis stores, the cosine weighted incident lighting along each basis vector." It's conceivable that my approach was correct, however it was based on an intuition rather than a derivation. ---bruce ________________________________ From: gdalgorithms-list-bounces@... [mailto:gdalgorithms-list-bounces@...] On Behalf Of Rowan Wyborn (2K Australia) Sent: Tuesday, May 20, 2008 11:38 PM To: Game Development Algorithms Subject: Re: [Algorithms] Projecting SH into the Half life 2 basis Hi Bruce, Yeah I'm not sure I follow why in your case its incorrect to do a standard cosine lobe SH lookup per basis vector (ala irradiance env mapping). Afterall that's exactly what the HL2 basis stores, the cosine weighted incident lighting along each basis vector. I was thinking about trying to encode the actual PRT transfer SH with a non clamped HL2 basis (which needs a proper basis projection)... I'm yet to sit down and try and wade through the maths thou if anyone has any thoughts :-) Also thanks matt for the basis change derivation, explains things perfectly. Thanks, Rowan From: gdalgorithms-list-bounces@... [mailto:gdalgorithms-list-bounces@...] On Behalf Of Bruce Woodard Sent: Wednesday, 21 May 2008 3:32 AM To: Game Development Algorithms Subject: Re: [Algorithms] Projecting SH into the Half life 2 basis IIRC, Peter went over the derivation on this mailing list. Might be worth a troll through the archives. Also, FWIW (realizing that Peter will likely groan with disgust) for Warhawk I simply did a standard SH lookup per basis vector (spun into world-space) in my vertex shader. I used this as a way to mix my ambient volume lighting and point lights for a constant per-pixel (HL2 lookup) cost. ---bruce ________________________________ From: gdalgorithms-list-bounces@... [mailto:gdalgorithms-list-bounces@...] On Behalf Of Rowan Wyborn (2K Australia) Sent: Tuesday, May 20, 2008 1:04 AM To: gdalgorithms-list@... Subject: [Algorithms] Projecting SH into the Half life 2 basis Howdy, The paper "Normal Mapping for Precomputed Radiance Transfer" (http://www.ppsloan.org/publications/) contains a handy matrix to project 3rd order SH into the half life 2 basis. I was just wondering if anyone (or P.P.S if he's still on this list :-)) had any insights into how this matrix is derived? Additionally I wonder whether its possible to generalize this solution to an arbitrarily oriented set of basis vectors? Its not clear to me whether the results in this paper for the HL2 basis are achieved by: a) rotating the SH lighting into each vertex's basis orientation and projecting using the given matrix or b) by generating the projection matrix on the fly for each vertex's basis orientation. Anyone got any ideas? Thanks, Rowan 
 [Algorithms] "Search Inside" From: Eric Haines - 2008-06-02 15:29:59 Catching up on GD Algorithms and reading about the Half-Life 2 basis, I thought I'd pass on a link, since it might be handy: http://www.amazon.com/Real-Time-Rendering-Tomas-MOller/dp/1568814240/realtimerenderin/ Though our new edition's not out yet (it's slated for SIGGRAPH), the cool thing is that you can "Search Inside" right now, and so can get a little bit of starting info on various topics (including the HL 2 basis, though many of you are well beyond the intro we have). Now what I'd really like is an "extended edition" online, perhaps 5000 pages long, that also distilled all of this mailing list down to the useful bits - sorry, we didn't have the time to write that version. I'm hoping for (in an alternate universe) a compendium by Jon Watte, Tom Forsyth, et al. of you. Though maybe the archives *is* the book, in a sense (but needs an editor, in that case). Eric