Jump to content

  • Log In with Google      Sign In   
  • Create Account

mauro78

Member Since 14 Dec 2008
Offline Last Active Dec 10 2013 12:25 PM

Posts I've Made

In Topic: Spherical Harminics: Need Help :-(

05 November 2013 - 03:23 PM

Mauro, that sounds like the correct approach. About storing the irradiance with SH, what is unclear about the description I wrote in my previous post ? To recap, given a probe and a light, the radiance from the light to the probe has an analytical formula and you can calculate directly the corresponding SH coefficients.

well almoust clear...working on this...hope to post reusults soon...also exploring "shooting" rays from the probe to get incoming radiance....

 

I get the key point after reading the paper "Stupid SH Tricks": for my own goal the best solution would be compute the incoming radiance from a VPL from all the possible directions over a sphere. This is just the integral over a surface. Of course I was aware that storing this was impossible for real time solution.
 
So I reading the paper I had sort of enlightment: SH will allow me to express the above integral using SH basis and original fuction samples. SH basis simple express the sampling direction....of course we've some degree of detail here....second order SH is just a raw solution....high order SH can better approximate the spherical function...
 
This will awill allow me to reconstruct original (approximated) function later on shading phase....Very similar to Fourier series for 1D case.

 

back on work now....

 

EDIT: the bad news is that I'll probably not go throught Light Propagation Volume but stick with Irradiance Volume...mostly becouse LPV requires DX11 hardware to be efficently implemented (even if volume textures can be handled in DX9 using some tricky code)


In Topic: Spherical Harminics: Need Help :-(

04 November 2013 - 02:39 PM

I've read more on SH during this weekend and I'm even more conviced that is the right solution for my goal. To summarize right know with RSM (and associated Virtual Lights)  I'm doing this:
 
for every shaded pixel
  compute "irradiance" between the pixel and the i-th Virtual Light
 
This is very slow of course....so a potential solution using SH is:
 
teake some probes on the scene and for every probe compute incoming radiance and store it using SH. 
 
Then at runtime the shading pass will be:
for every shaded pixel
  compute the interpolated irradiance reading the nearest probe using the pixel normal as index into SH
 
BTW...I'm struggling storing and reading back the irradiance into SH :-(

In Topic: Spherical Harminics: Need Help :-(

01 November 2013 - 06:33 AM

Mauro, can you explain the meaning of that normal vector n ? Is it the normal of the receiving or emitting surface ? Or is it the vector connecting the emitter and receiver ? And how did you derive the four SH coefficients ?

N emitting normal
SH derivation is order 2 truncation of polynomial form...

In Topic: Spherical Harminics: Need Help :-(

30 October 2013 - 04:07 PM

I am not familiar with RSMs but, judging from the code you posted, I believe SH suit your needs.

 

Remember that SH represent a signal defined over a spherical domain. In this case the signal is the total incoming light from all the secondary sources. A SH probe has an associated position in world space. For a <light, probe> pair, the signal is (cosThetaI * lR * Flux) in the direction defined by R (normalized). The cosThetaJ  term depends on the receiver's normal and will be taken into account later at runtime when shading a surface.

Some pseudo-code:

 

for each probe

  SH = 0

  for each light

     signal = R / | R | * (cosThetaI * lR * Flux)

     SH += signalToSH(signal)

 

signalToSH is a function that encodes a directional light in the SH basis. See D3DXSHEvalDirectionalLight for an implementation.

 

 

At runtime, when shading a pixel, pick the probe spatially closest to it. The pixel has a normal associated. Assuming that the BRDF is purely diffuse, you have to convolve the cosine lobe around the pixel's normal with the signal encoded in the probe, achieved with a SH rotation and dot product. See the paper http://www.cs.berkeley.edu/~ravir/papers/envmap/envmap.pdf

 

I suggest you read more material on SH in order to have a better understanding of their properties and use cases. As for myself, I will read the RSM paper asap and edit my reply if I've made wrong assumptions.

 

Please let me know if you have more questions.

 

Stefano

 

Ok first thanks for response and yes I need to dig into SH realms better.... but let's make it simple Stefano (well not so simple happy.png): given a normal vector  n (x,y,z) I can get second order SH coefficents c = (c0,c1,c2,c3)

 

 

where: 

 

c0 = sqrt(pi) / 2

c1 = -sqrt(pi/3) * y

c2 = sqrt(pi/3) * z

c3 = - sqrt(pi/3) * x

 

so for every VPL ( virtual point light ) I'll have a n vector and an associated SH coefficents c. 

 

The question is how I can go back and compute reflected radiance from those second order SH coefficents?

 

Thanks

 

Mauro


In Topic: Real-time Global illumination for games discussion

28 October 2013 - 01:46 PM

Based on my experience you can add GI on your engine.....but two goals are difficult to achieve:

 

1. Even if global illumination stays into the low frequency domain....make it convincing and temporal coherent it's hard

2. Make it fast is even harder 

 

just my 2 cents

 

p.s.

Is it worth since it will "open" your brain :-)


PARTNERS