Discussion:
[Algorithms] Pick dominant light from sh coeffs
Dan Treble
2012-02-02 23:22:21 UTC
Permalink
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
David Neubelt
2012-02-02 23:54:11 UTC
Permalink
Looks like you want to normalize the 3d vector made from the basis
coefficients (-f[1,1], -f[1,-1], f[1,0]). Section 3.3 ZH Error Analysis
paragraph 2.



-= Dave



From: Dan Treble [mailto:***@gmail.com]
Sent: Thursday, February 02, 2012 3:22 PM
To: gdalgorithms-***@lists.sourceforge.net
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
Peter-Pike Sloan
2012-02-03 00:21:51 UTC
Permalink
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: ***@gmail.com
To: gdalgorithms-***@lists.sourceforge.net
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
GDAlgorithms-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list
Dan Treble
2012-02-03 01:28:09 UTC
Permalink
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 <
Post by Peter-Pike Sloan
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
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
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
https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list
http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list
Loading...