I’m a bit new to shaders but I generally understand how they work, and I’m now trying to understand the theory behind illumination.
I’d like to create a really simple shader that mimics global illumination to mess around with until Unity 5 comes out. I figured since ambient lighting on a character/object is merely the light that is reflected off surroundings and then off the character/object, it’s essentially a really weak reflection, and therefore a cubemap might suffice.
In my logic, I’ve tried using a reflection map but this results in a mirror-like surface for the character. With a plain white reflection this looks exactly how I want. But with any actual reflection cubemaps it looks far too detailed for the actual lighting. It looks like what I’d expect the high-specular parts of the character to look like. I figure the sheer detail is a major part of it.
Am I on the right track in my thinking? If so, is there some way to get a blurred, approximated value for the reflection?
You’re on the right track. The specific type of blurring required to use a cube or sphere map for diffuse lighting is a hemispherical convolution. Marmoset Skyshop will do this for you.
Oh, I remember seeing Marmoset before! Looks absolutely beautiful, but unfortunately out of my price range for a while. I’ll keep experimenting a bit and see what I come up with. I’ve just tried giving my shader a second cubemap for this image-based lighting.
I’d like to have two separate outputs for this; one half3 for diffuse and another for specularity, but if I try to add more to the output it always gives me a “too many interpolators” error. @_@
UPDATE: I was able to create a custom input with two extra half3 values. One for reflection, one for ambient light. I had to use target 3.0 and target glsl to add them. To make the ambient light cubemap texture I merely copied the reflection texture, blurred it like crazy, and saved it as a much smaller resolution just to be more efficient.
I had previously tried using Emission but it didn’t work out well. Instead I directly applied the ambient lighting cubemap inside the custom lighting function. It’s not perfect, but it’s pretty enough to use until Unity 5 comes out.