Introduced light source radiance and exposure multipliers in the planet, atmosphere and ship shaders. This allows some more control over the intensity of the light source and the overall amount of light in the scene. Default values for all mutlipliers are set to 1.0.
This commit is contained in:
parent
1fcfbb89f7
commit
104f9c045d
@ -24,7 +24,10 @@
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#define DIFFUSE_LIGHT (gl_LightSource[1].diffuse.rgb)
|
||||
#define MULTIPLIER_LIGHTSRCRADIANCE 1.0
|
||||
#define NULTIPLIER_EXPOSURE 1.0
|
||||
|
||||
#define DIFFUSE_LIGHT (gl_LightSource[1].diffuse.rgb * MULTIPLIER_LIGHTSRCRADIANCE)
|
||||
#define AMBIENT_LIGHT (gl_LightModel.ambient.rgb)
|
||||
|
||||
uniform vec4 atmPosition;
|
||||
@ -94,6 +97,9 @@ void main()
|
||||
// add ambient light
|
||||
totalColor += AMBIENT_LIGHT * NdotL;
|
||||
|
||||
// exposure
|
||||
totalColor *= NULTIPLIER_EXPOSURE;
|
||||
|
||||
// all above calculations were done in linear space - tonemap & go to sRGB for display
|
||||
// using Jim Hejl's filmic tonemapping and gamma correction approximation.
|
||||
// Normally this would require HDR, but I think it works extremely well in Oolite.
|
||||
@ -102,7 +108,7 @@ void main()
|
||||
vec3 x = max(vec3(0.0), totalColor - 0.004);
|
||||
totalColor = (x * (6.2 * x + 0.5)) / (x * (6.2 * x + 1.7) + 0.06);
|
||||
|
||||
//totalColor = vec4(1.0) - exp(-totalColor * 5.5); // exposure tonemapping, if we ever need it
|
||||
//totalColor = vec3(1.0) - exp(-totalColor * NULTIPLIER_EXPOSURE); // exposure tonemapping, if we ever need it
|
||||
|
||||
gl_FragColor = vec4(totalColor, newOpacity);
|
||||
}
|
||||
|
@ -29,10 +29,13 @@
|
||||
#endif
|
||||
|
||||
#if IS_OOLITE
|
||||
#define SPECULAR_LIGHT (gl_LightSource[1].specular.rgb)
|
||||
#define DIFFUSE_LIGHT (gl_LightSource[1].diffuse.rgb)
|
||||
#define MULTIPLIER_LIGHTSRCRADIANCE 1.0
|
||||
#define NULTIPLIER_EXPOSURE 1.0
|
||||
#define SPECULAR_LIGHT (gl_LightSource[1].specular.rgb * MULTIPLIER_LIGHTSRCRADIANCE)
|
||||
#define DIFFUSE_LIGHT (gl_LightSource[1].diffuse.rgb * MULTIPLIER_LIGHTSRCRADIANCE)
|
||||
#define AMBIENT_LIGHT (gl_LightModel.ambient.rgb)
|
||||
#else
|
||||
#define MULTIPLIER_LIGHTSRCRADIANCE 1.0
|
||||
#define SPECULAR_LIGHT vec3(0.8)
|
||||
#define DIFFUSE_LIGHT vec3(0.8)
|
||||
#define AMBIENT_LIGHT vec3(0.2)
|
||||
@ -337,6 +340,9 @@ void main()
|
||||
#endif
|
||||
totalColor += AMBIENT_LIGHT * ambientColor;
|
||||
|
||||
// exposure
|
||||
totalColor *= NULTIPLIER_EXPOSURE;
|
||||
|
||||
// re-apply gamma correction
|
||||
// using Jim Hejl's filmic tonemapping and gamma correction approximation.
|
||||
// Normally this would require HDR, but I think it works extremely well in Oolite.
|
||||
|
@ -30,6 +30,12 @@
|
||||
*/
|
||||
|
||||
|
||||
#define MULTIPLIER_LIGHTSRCRADIANCE 1.0
|
||||
#define MULITPLIER_EXPOSURE 1.0
|
||||
#define LIGHTSRC_RADIANCE_DIFFUSE (gl_LightSource[1].diffuse * MULTIPLIER_LIGHTSRCRADIANCE)
|
||||
#define LIGHTSRC_RADIANCE_SPECULAR (gl_LightSource[1].specular * MULTIPLIER_LIGHTSRCRADIANCE)
|
||||
#define LIGHTSRC_AMBIENT (gl_LightModel.ambient)
|
||||
|
||||
#ifndef OOSTD_DIFFUSE_MAP
|
||||
#define OOSTD_DIFFUSE_MAP 0
|
||||
#endif
|
||||
@ -301,7 +307,7 @@ void main(void)
|
||||
vec3 halfVector = normalize(lightVector + eyeVector);
|
||||
#endif
|
||||
// Get ambient colour
|
||||
vec4 ambientLight = gl_LightModel.ambient;
|
||||
vec4 ambientLight = LIGHTSRC_AMBIENT;
|
||||
|
||||
// Get emission colour
|
||||
#if OOSTD_EMISSION || OOSTD_EMISSION_MAP
|
||||
@ -333,7 +339,7 @@ void main(void)
|
||||
#endif
|
||||
|
||||
vec4 diffuseLight = vec4(0);
|
||||
diffuseLight += CalcDiffuseLight(lightVector, normal, gl_LightSource[1].diffuse);
|
||||
diffuseLight += CalcDiffuseLight(lightVector, normal, LIGHTSRC_RADIANCE_DIFFUSE);
|
||||
|
||||
#if HAVE_ILLUMINATION
|
||||
diffuseLight += illuminationMapLight;
|
||||
@ -411,11 +417,14 @@ void main(void)
|
||||
#if OOSTD_SPECULAR
|
||||
// we should not multiply by specularColor here; we already took that into account
|
||||
// when calculating the Fresnel-Schlick term
|
||||
totalColor += specularLight * gl_LightSource[1].specular;
|
||||
totalColor += specularLight * LIGHTSRC_RADIANCE_SPECULAR;
|
||||
#endif
|
||||
|
||||
// apparently some drivers fail to clamp alpha properly, so let's do it for them
|
||||
totalColor.a = clamp(totalColor.a, 0.0, 1.0);
|
||||
|
||||
// exposure
|
||||
totalColor.rgb *= MULITPLIER_EXPOSURE;
|
||||
|
||||
// gamma correction
|
||||
// using Jim Hejl's filmic tonemapping and gamma correction approximation.
|
||||
|
Loading…
x
Reference in New Issue
Block a user