Jump to content
  • Advertisement
Sign in to follow this  
neoragex

Spherical interpolation for multi transfer basis

This topic is 939 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Recently I encounted a problem about how to quickly interpolate the transfer basis values for any spherical direction when I was doing some PRT works.

 

Here is my question:

To say I have got the 6 irradiances along 6 different dir basis (for example, 6 dirs for a cubemap) . The irradiances may be irregulate, namely, they come from some HDR lighting sources and huge differences may exist between their values. HOW can I get the reasonable interpolated irradiance along any dirs from these available basis in the unit sphere?

 

Any suggestion would be much appreciated. :)

Edited by neoragex

Share this post


Link to post
Share on other sites
Advertisement

I'm not quite sure some of your words mean, never really used spherical harmonics (?). But what I've done successfully is use 6 directions and their radiances and interpolate it on every direction.

inline half3 EnvLight(fixed3 normalWorld, half3 up, half3 down, half3 left, half3 right, half3 forward, half3 back) {
	half d = dot(fixed3(0,1,0), normalWorld);
	half d2 = -d;
	d = max(d,0);
	d2 = max(d2,0);
	half3 e = up * d * d + down * d2 * d2;
	
	half d3 = dot(fixed3(-1,0,0), normalWorld);
	half d4 = -d3;
	d3 = max(d3,0);
	d4 = max(d4,0);
	e += left * d3 * d3 + right * d4 * d4;
	
	half d5 = dot(fixed3(0,0,1), normalWorld);
	half d6 = -d5;
	d5 = max(d5,0);
	d6 = max(d6,0);
	e += forward * d5 * d5 + back * d6 * d6;
	
	return e;
}

I think that was in linear space, not quite sure how well it performs on hdr values though. It's been a while I wrote that. Maybe it helps.

Share this post


Link to post
Share on other sites

Thanks for your kindly reply @danybittel :)  I recognized my bad description for the question... :unsure:  so I have modified my thread to make it more clear. What I really want to do is to improve the quality of my diffuse indirect-lighting.

 

I am wondering that your answer is exactly a Half-life 2's ambient cube interpolation (aka HL2 basis interpolation), isn't it? I found some illustrations for its result. I'm not quite satisfied with its quality, and I am also not quite sure how well it performs on HDR lighting situation....But what surprises me is that Tom Clancy's The Division (by UBI, 2016) has also adopted this method to interpolate their indirect-irradiance cubes.... Could anybody give some comments on this?

Edited by neoragex

Share this post


Link to post
Share on other sites

Ok, I did not know HL2 used this. I figured the algorithm out myself actually. It is really simple, it just weights each 6 direction by the dot product. And needs a pow of 2, because "it's on a sphere". :-)

It should perform well with HDR values, if you look at the code it just adds them together.

The algorithm is also faster than using Spherical harmonics with the same number of coefficients (6), in my opinion quality is similar (I think unity uses 6 coefficients as far as I can remember)

 

If you want better / more subtle changes on the diffuse you need more coefficients. Which is more data, more complex calculation.

 

I decided against it, in my opinion it's better to have more positions (in the world) where you define the lighting than have more coefficients.

Share this post


Link to post
Share on other sites

The downside of HL2 ambient cube is that the coefficients directions are hardcoded, while Spherical Harmonics are rotationally invariant.
In practice that means SH can capture the main direction to a bright light (sun) independent of its position,
while ambient cube produces differing results depending on how close the light direction matches one of the pricipial axis.

It's not clear to me if you want your 6 directions to be axis aligned, or if you want to point them to arbitary 'most important' directions.
In the latter case summing by dot product is not possible because they are not orthonormal.
Would it work to find the 3 closest directions and interpolate with barycentric coords from their spherical triangle?


Edit: Nonsense and terrible nonsense :)

 

You might wanna look up Spherical Gaussians as well...

Edited by JoeJ

Share this post


Link to post
Share on other sites

Thanks @JoeJ! Your explanation for HL2 ambient cube is pretty clear.

What I really want to do is to improve the quality of my irradiance-volume. So I have to find some transfer basis solution to represent (and compress) the irradiance cubes. I have implemented it with SH3 by now. But I’m quite worry about the ‘negative ringing artifacts’ and the ‘low-band filtered directionless property’ of SH under HDR lighting, just like MJP had said in another thread.

And I also found the quality of my irr-vols is hard to improve, even though I have got some not-really-bad results (see the attachment). It's hard to adjust, very sensitve to vol position, and with a lot of light-leaks and banding artifacts.

I haven’t implement any raytracing or lightmap solution by now. Is it possible to get some proper diffuse indirect-lightings ONLY BY irr-vols baking (with some fancy transfer-basis solution)? Or I MUST implement some lightmap solutions such as radiosity or raytracing to get that?

 

Any suggestion?

Edited by neoragex

Share this post


Link to post
Share on other sites

In case you want more volume density, Remedys paper about Quantum Break covers the usage of trees with a branching factor of 16.

The also talk about how they store the lighting env in different ways (handling sunlight seperated etc.)

 

Some older work with less compexity and good results in this blog: http://copypastepixel.blogspot.co.at/

 

Did you think about  6*4 texel cubemaps? No SH issues and the resolution should be good enough to overcome the ambient cube limit.

More memory, but if you reduce density in empty space it might be a robust option.

Share this post


Link to post
Share on other sites

@JoyJ and @Frenetic Pony: Thanks! Your suggestion would be very helpful. I will take a look at it and have some tries.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!