Forums

Full Version: shader development
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
RenderMonkey: http://developer.amd.com/gpu/rendermonke...fault.aspx
Workspace: http://svn.vdrift.net/viewvc.cgi/trunk/t...oot=VDrift
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.
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.
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:
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:
http://graphics.stanford.edu/papers/envmap/

Also, valve uses an "ambient cube" approach which is a little faster (but not as general as spherical harmonics) and easier to understand:
http://www.valvesoftware.com/publication...Engine.pdf