Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
shader development
02-17-2010, 04:32 AM,
shader development
I have committed a RenderMonkey workspace with VDrift full shader (no shadows, postprocessing yet).

[Image: rmmkym1.jpg]

So anyone interested in GLSL shader development(sorry Windows only) checkout immediately! Smile
02-17-2010, 05:54 PM,
Playing with the shader I've noticed that the ambient cubemap values can be calculated in the pixel shader.
So we can scrap the ambient map and use the sampler for something else(like normalmaps?).

cubemap: color=textureCube(tu3_cube,ambientmapdir)
[Image: oldhrta2.jpg]

quadratic interpolation: y=1-0.5*(ambientmapdir.y-1)^2, color=0.25*y+0.75
[Image: paras1uhe.jpg]

linear interpolation: color=0.2*ambientmapdir.y+0.8
[Image: linearqg3yg.jpg]

I would go for the quadratic interpolation. It comes quite close to the cubemap version.
02-18-2010, 10:45 PM,
There's probably already room for using another sampler for normal maps.

The ambient cubemap gives you different colors and intensities in different directions, which you don't get with an approximation based only on the y coordinate of the normal. If you look at the sides of the tents in your screenshots you can see the difference. I'll grant that it's a very subtle effect, though. If you want to avoid using the texture but match the effect exactly, an approximation with low order spherical harmonics would look almost identical, although it would be more costly than the approximations you proposed.

I'm not really against using something else or scrapping the effect, though. I think the final product just has to look good. By the way, if you haven't found it yet, VDrift has a key you can bind to instantly reload the shaders, which is verrry handy while working on shader development.
02-19-2010, 04:46 AM,
So the ambient map is actually an irradiance environment map generated from the static environment map?
Sorry, I haven't worked with spherical harmonics in graphics yet. :oops:
02-19-2010, 11:26 AM,
NaN Wrote:So the ambient map is actually an irradiance environment map generated from the static environment map?

Yep! That's all done offline though, and really the only reason for it is to try to make the track geometry look less flat, so I'm willing to change it if needed.

Spherical harmonics are similar to the way you can build up any function using a sum of simple sine or cosine waves of different frequencies (fourier series) but using a basis function appropriate for a sphere instead of a sine/cosine. Representing an irradiance environment map is fairly easy with spherical harmonics because it's so low frequency:

Also, valve uses an "ambient cube" approach which is a little faster (but not as general as spherical harmonics) and easier to understand:

Forum Jump:

Users browsing this thread: 1 Guest(s)