(1) AO factors set to 1.0 in materials: There is no reason why AO should have arbitrary gains set by people based on taste. Gain of AO should be 1.0. In the fragment shaders, AO was arbitrarily multiplied by 2.0, making it invisible, pretty much.
(2) Skyward bias for ambient light in shaders: The traditional OpenGL pipeline models ambient light as light coming from all directions equally. This works well for scenes taking place deep inside the Sun. Anywhere else, ambient light shows directional biases. The best way to deal with this is by using the same cube or sphere used for environment mapping, and the surface normal; but the environment map has to be sufficiently blurred to match the diffuse reflection pattern (cos of the angle), which implies using an environment cube box with full range of LOD's included, rather than an arbitrarily set Environment Color. Failing that, a cheap and dirty approximation that works for open sky environments is a simple computed bias that increases the light coming from above for the blue channel, biases the green channel half as much, and keeps the red channel more or less untouched. It is despicable, yet orders of magnitude better than the OGL model.
(3) Some terrains, particularly the Acropolis Bay, are too white. So white, in fact, that they saturate. Upon working on a shader that would fix them on the fly, I discovered that the floor was tiled; I never knew this; it always seemed pure white. What this shader mod does is it computes S and V as if converting to HSV, and computes a darkening factor based on intensity and saturation. For pure white, the factor output is minimal. For less bright, or more saturated colors, the factor rapidly moves towards 1.0. The color from the terrain texture is then mixed between the original color and the original color squared times 0.75 (darkened and given more contrast). This patch also gets rid of any specular computations and ignores a specular texture if such an atrocity is specified. Specularity is of two types: metallic or dielectric (Fresnel). Ground specularity can come from sand crystals (Fresnel), or from polished marble floors (Fresnel) or from pools of water (Fresnel). Fresnel needs to be computed; it cannot come from a texture.
(4) Since some of the assets lack AO's, defaulting their ambient brightness to 1.0 would make them look much brighter than assets that do have AO's, so in the shader, where an AO texture is not present, the default AO value is 0.5 (50% shadowed). The terrain has no AO, and cannot have, since it cannot know beforehand where shadowing entities will be. Even trees can be there one moment, gone the next. I have a proposal for ambient shadowing onto the terrain for A25 below. For now, I followed the same philosophy, and made the ground 50% ambient shadowed by default. This should be removed if/when the ambient shadowing below (or some other ambient shadowing solution) is implemented.
This patch is suggested for A24. Further work is suggested below for A25.
TODO:
- Many AO bakes have a range from 0.0 to 0.63 or whereabouts. This is incorrect, and the way to deal with it is NOT by manually tweaking materials. If re-baking the AO's for most assets is unrealistic to expect, a temporary solution would be for software to take a thousand random samples upon loading an ao to determine range, and therefor how much the shader should scale up the AO value from the texture.
- A better AO algorithm is included in some tools, such as X-normal: The more standard AO accumulates all unblocked rays from a point on the surface of a model, counting them all equally. The better algorithm multiplies each ray by ray dot normal, which makes rays normal to the surface count more, and rays parallel to the surface not count at all. Effectively, this is a post-diffuse-reflectance ao, which is a lot more useful than a pre-reflectance ao, and in fact looks far more realistic and natural. We should strive to get this better type of ao in-game.
- Having environmental cube-maps with LOD's is an invaluable asset. The blurriest level of the LOD can be used to fetch ambient light from the surface normal, for one example. For another, the shininess power of a material can be used to bias the LOD level when environment mapping, making the blurring of highlights agree with blurring of the environment map, avoiding the environment mapping's looking ridiculously sharp on otherwise visibly rough surfaces. For realistic metal looks, nothing compares to the simplicity of sprinkling randomly some shininess power variations. As you turn the metal piece, the blurry spots look like watermarks. But this does not work if only lights are affected by shininess power; it must be the environment mapping LOD bias as well. In any case, using the deepest LOD of the environment map to fetch ambient light is an extremely realistic ambient lighting algorithm, and it puts a final nail on the arbitrarily set Ambient Light hateful parameter.
- With (now) more realistic looking lights and shadows (with this patch) it becomes more painfully obvious how badly ambient shadowing onto the ground is needed. I have an idea for how to solve this problem for A25. For a quick preview: Create a disc (e.g. do-decagon), and write code that can create instances of it that keep forever hovering a few centimeters above the ground. That is, they govern their own Y position. Programmatically attach one of these to every moving entity upon creation, such that the entity writes its own X and Z to this contraption, but has no control of Y. These contraptions do not need a texture. The shader programmatically computes their ambient light blocking strength as a function of distance from the XZ center. At the center they'd block say 30% of ambient light, decreasing quadratic-ally towards the periphery. The size of the contraption would be based on the owner entity's height, and they would not participate in collisions or anything of the sort. Trees should get these shadow discs, also, albeit with some mechanism to make the shade block green light less than blue or red. Plant leaves partly reflect green light, but partly allow it to pass through, so the shade under trees is biased towards green.