Which of the two screenshots looks brighter?
The brightness is the same. I only modify attenuation.
Let us start from the beginning. To apply sunlight to the object you need 2 things: the shadow and the angle to the sun.
float attenuation = dot(_WorldSpaceLightPos0.xyz, normal); // Angle
float3 sunlight = lightColor * shadow * attenuation ;
This gets you:
Then you add your ambient light, multiply by texture colour and produce the final image.
Let's remember that we probably aren't using light's real value in our video games. Unless you do photorealistic renderings, in which case stop reading, these are cheap tricks for fakers.
Let's look closer. The light is just too sharp. But also too smooth. Sure, the ambient will take care of the darker areas, but that light just gives away the game.
Now, correct or not, I like to give myself a slider there, to remap the original "attenuation " value into this:
Or to this (ignore colour differences):
The code is a bit of a mess and is subject to change, but for completeness's sake, I'll post it here:
float attenuation = _qc_Sun_Atten;
float aoObscuring = smoothstep(1,0,attenuation) * ao * 0.5;
float angle = dot(_WorldSpaceLightPos0.xyz, normal);
angle = smoothstep(aoObscuring,1,angle);
attenuation = 1-pow(1-angle,1 + (1-ao) * 2 * attenuation);
For night scenes you would want that attenuation to be lower:
Higher for daytime:
And for cloudy days crank it up as high as possible to imitate the scattering by the clouds.
Now, none of the things mentioned above have anything to do with physically based rendering. These are artistic solutions.
Your shaders can look slightly better now! Or worse, you judge.
Comments