Skip to content

Commit

Permalink
Illumination mapping of the dark side of custom planets is now suppor…
Browse files Browse the repository at this point in the history
…ted on the diffuse map's alpha channel. If the alpha channel is used in the diffuse map, low values correspond to high illumination.
  • Loading branch information
AnotherCommander committed Apr 29, 2020
1 parent 938d49e commit 3b91106
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 8 additions & 0 deletions Resources/Config/material-defaults.plist
Expand Up @@ -55,26 +55,30 @@
{
IS_OOLITE = 1;
OOSTD_DIFFUSE_MAP = 1;
OOSTD_DIFFUSE_AND_ILLUMINATION_MAP = 1;
OOSTD_CUBE_MAP = 0;
};
"moon-customized-macros" =
{
IS_OOLITE = 1;
OOSTD_DIFFUSE_MAP = 1;
OOSTD_DIFFUSE_AND_ILLUMINATION_MAP = 1;
OOSTD_CUBE_MAP = 0;
OOSTD_HARSH_MISTRESS = 1;
};
"planet-customized-normspec-macros" =
{
IS_OOLITE = 1;
OOSTD_DIFFUSE_MAP = 1;
OOSTD_DIFFUSE_AND_ILLUMINATION_MAP = 1;
OOSTD_CUBE_MAP = 0;
OOSTD_NORMAL_AND_SPECULAR_MAP = 1;
};
"moon-customized-normspec-macros" =
{
IS_OOLITE = 1;
OOSTD_DIFFUSE_MAP = 1;
OOSTD_DIFFUSE_AND_ILLUMINATION_MAP = 1;
OOSTD_CUBE_MAP = 0;
OOSTD_HARSH_MISTRESS = 1;
OOSTD_NORMAL_AND_SPECULAR_MAP = 1;
Expand All @@ -83,26 +87,30 @@
{
IS_OOLITE = 1;
OOSTD_DIFFUSE_MAP = 1;
OOSTD_DIFFUSE_AND_ILLUMINATION_MAP = 1;
OOSTD_CUBE_MAP = 1;
};
"moon-customized-cubemap-macros" =
{
IS_OOLITE = 1;
OOSTD_DIFFUSE_MAP = 1;
OOSTD_DIFFUSE_AND_ILLUMINATION_MAP = 1;
OOSTD_CUBE_MAP = 1;
OOSTD_HARSH_MISTRESS = 1;
};
"planet-customized-cubemap-normspec-macros" =
{
IS_OOLITE = 1;
OOSTD_DIFFUSE_MAP = 1;
OOSTD_DIFFUSE_AND_ILLUMINATION_MAP = 1;
OOSTD_CUBE_MAP = 1;
OOSTD_NORMAL_AND_SPECULAR_MAP = 1;
};
"moon-customized-cubemap-normspec-macros" =
{
IS_OOLITE = 1;
OOSTD_DIFFUSE_MAP = 1;
OOSTD_DIFFUSE_AND_ILLUMINATION_MAP = 1;
OOSTD_CUBE_MAP = 1;
OOSTD_HARSH_MISTRESS = 1;
OOSTD_NORMAL_AND_SPECULAR_MAP = 1;
Expand Down
10 changes: 6 additions & 4 deletions Resources/Shaders/oolite-default-planet.fragment
Expand Up @@ -68,7 +68,9 @@
uniform sampler2D uIlluminationMap;
#define ILLUMINATION_COLOR texture2D(uIlluminationMap, texCoords).rgb
#elif OOSTD_DIFFUSE_AND_ILLUMINATION_MAP
#define ILLUMINATION_COLOR (diffuseMapSample.a * vec3(0.8, 0.8, 0.4))
// low alpha values correspond to high illumination, so that textures with unused alpha channel
// (i.e. alpha == 1.0 for all pixels) display correctly without any illumination
#define ILLUMINATION_COLOR ((1.0 - diffuseMapSample.a) * vec3(0.8, 0.8, 0.4))
#endif


Expand Down Expand Up @@ -319,14 +321,14 @@ void main()

// conservation of energy
totalColor += diffuseColor * diffuseLight * (vec3(1.0) - fresnel);

// paint the orange-reddish terminator
totalColor *= diffuseIntensity;

#if USE_ILLUMINATION
vec3 illuminationColor = ILLUMINATION_COLOR;
totalColor += (1.0 - diffuseIntensity.r) * illuminationColor;
#endif

// paint the orange-reddish terminator
totalColor *= diffuseIntensity;

// Ambient light, biased towards blue.
vec3 ambientColor = diffuseColor;
Expand Down

0 comments on commit 3b91106

Please sign in to comment.