Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Approximating Subsurface Scattering With Spherical Gaussians #7

Open
utterances-bot opened this issue Mar 29, 2021 · 2 comments
Open

Comments

@utterances-bot
Copy link

Approximating Subsurface Scattering With Spherical Gaussians

https://therealmjp.github.io/posts/sss-sg/

Copy link

Hi Matt, thank you for your great writeup. I have a little issue with the section of "Applying To Ambient Lighting", I'm wondering how to generate SH coefficients for a spherical gaussian in runtime? I mean how to do the integral of a diffusion profile(represented by spherical gaussian) and SH probe?
Could you explain more about it? Thank you so much.

Copy link
Owner

Hey there! I have not any extensive work in terms of figuring out a good fit or approximation to generate SH coefficients from an arbitrary SG lobe. In the article I suggested following Ravi's work for approximating a Torrance-Sparrow NDF as SH coefficients using an exponential, which is probably a good start for approximating the normalized SG lobe that you would use for sub-surface scattering. Once you've done that, you can convolve it with your SH probe lighting with a simple multiply.

I would try something like this to start:

float3 l0Scatter = 1.0f;
float3 l1Scatter = exp(-Square(ScatterAmt * 1.0f));
float3 l2Scatter = exp(-Square(ScatterAmt * 2.0f));

SH9Color ambientSH = SampleSHProbe();
ambientSH.c[0] *= l0Scatter;
ambientSH.c[1] *= l1Scatter;
ambientSH.c[2] *= l1Scatter;
ambientSH.c[3] *= l1Scatter;
ambientSH.c[4] *= l2Scatter;
ambientSH.c[5] *= l2Scatter;
ambientSH.c[6] *= l2Scatter;
ambientSH.c[7] *= l2Scatter;
ambientSH.c[8] *= l2Scatter;

// Do the usual SH diffuse calculations 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants