2008-11-28 20:20:58 +00:00
|
|
|
|
/*
|
|
|
|
|
oolite-default-shader.fragment
|
|
|
|
|
Default fragment shader for Oolite ships.
|
|
|
|
|
|
2012-04-01 13:27:36 +00:00
|
|
|
|
|
2012-12-31 09:00:28 +00:00
|
|
|
|
© 2007–2013 Jens Ayton
|
2012-04-01 13:27:36 +00:00
|
|
|
|
|
2008-11-28 20:20:58 +00:00
|
|
|
|
This is similar to normal ship shaders, but has special controlling
|
|
|
|
|
macros (like OOSTD_DIFFUSE_MAP, OOSTD_SPECULAR etc.) which are specific
|
|
|
|
|
to the default shader.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
|
SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
#ifndef OOSTD_DIFFUSE_MAP
|
|
|
|
|
#define OOSTD_DIFFUSE_MAP 0
|
|
|
|
|
#endif
|
|
|
|
|
|
2010-04-05 14:32:33 +00:00
|
|
|
|
|
|
|
|
|
#ifndef OOSTD_DIFFUSE_MAP_IS_CUBE_MAP
|
|
|
|
|
#define OOSTD_DIFFUSE_MAP_IS_CUBE_MAP 0
|
|
|
|
|
#endif
|
|
|
|
|
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
#ifndef OOSTD_SPECULAR
|
|
|
|
|
#define OOSTD_SPECULAR 0
|
|
|
|
|
#undef OOSTD_SPECULAR_MAP
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef OOSTD_SPECULAR_MAP
|
|
|
|
|
#define OOSTD_SPECULAR_MAP 0
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-11-28 19:37:47 +00:00
|
|
|
|
#ifndef OOSTD_NORMAL_MAP
|
|
|
|
|
#define OOSTD_NORMAL_MAP 0
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef OOSTD_NORMAL_AND_PARALLAX_MAP
|
|
|
|
|
#define OOSTD_NORMAL_AND_PARALLAX_MAP 0
|
|
|
|
|
#endif
|
|
|
|
|
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
#ifndef OOSTD_EMISSION
|
|
|
|
|
#define OOSTD_EMISSION 0
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef OOSTD_EMISSION_MAP
|
|
|
|
|
#define OOSTD_EMISSION_MAP 0
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef OOSTD_ILLUMINATION_MAP
|
|
|
|
|
#define OOSTD_ILLUMINATION_MAP 0
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef OOSTD_EMISSION_AND_ILLUMINATION_MAP
|
|
|
|
|
#define OOSTD_EMISSION_AND_ILLUMINATION_MAP 0
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
2008-11-28 19:37:47 +00:00
|
|
|
|
#if OOSTD_EMISSION_AND_ILLUMINATION_MAP && !OOSTD_EMISSION_MAP
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
#undef OOSTD_EMISSION_MAP
|
|
|
|
|
#define OOSTD_EMISSION_MAP 1
|
|
|
|
|
#endif
|
|
|
|
|
#if OOSTD_EMISSION_AND_ILLUMINATION_MAP && OOSTD_ILLUMINATION_MAP
|
|
|
|
|
#undef OOSTD_EMISSION_AND_ILLUMINATION_MAP
|
|
|
|
|
#define OOSTD_EMISSION_AND_ILLUMINATION_MAP 0
|
|
|
|
|
#endif
|
2008-11-28 19:37:47 +00:00
|
|
|
|
#if OOSTD_NORMAL_AND_PARALLAX_MAP && !OOSTD_NORMAL_MAP
|
|
|
|
|
#undef OOSTD_NORMAL_AND_PARALLAX_MAP
|
|
|
|
|
#define OOSTD_NORMAL_AND_PARALLAX_MAP 0
|
|
|
|
|
#endif
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
|
|
|
|
|
|
2012-01-16 18:53:56 +00:00
|
|
|
|
#define NEED_EYE_VECTOR (OOSTD_SPECULAR || OOSTD_NORMAL_AND_PARALLAX_MAP)
|
2008-11-28 19:37:47 +00:00
|
|
|
|
|
2012-01-16 18:53:56 +00:00
|
|
|
|
#define HAVE_ILLUMINATION (OOSTD_EMISSION_AND_ILLUMINATION_MAP || OOSTD_ILLUMINATION_MAP)
|
2008-11-28 19:37:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if NEED_EYE_VECTOR
|
|
|
|
|
varying vec3 vEyeVector;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
varying vec2 vTexCoord;
|
|
|
|
|
|
2010-04-07 22:35:24 +00:00
|
|
|
|
varying vec3 vLight1Vector;
|
2008-11-28 19:37:47 +00:00
|
|
|
|
|
2012-01-16 18:53:56 +00:00
|
|
|
|
#if OOSTD_DIFFUSE_MAP
|
|
|
|
|
#if !OOSTD_DIFFUSE_MAP_IS_CUBE_MAP
|
|
|
|
|
// Standard 2D diffuse map
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
uniform sampler2D uDiffuseMap;
|
2012-01-16 18:53:56 +00:00
|
|
|
|
#else
|
|
|
|
|
// Cube diffuse map
|
2010-04-05 14:32:33 +00:00
|
|
|
|
uniform samplerCube uDiffuseMap;
|
2010-04-21 19:12:26 +00:00
|
|
|
|
varying vec3 vCubeTexCoords;
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
#endif
|
2012-01-16 18:53:56 +00:00
|
|
|
|
#endif
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
|
2010-04-07 22:35:24 +00:00
|
|
|
|
|
2008-11-28 19:37:47 +00:00
|
|
|
|
#if OOSTD_SPECULAR_MAP
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
uniform sampler2D uSpecularMap;
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-11-28 19:37:47 +00:00
|
|
|
|
#if OOSTD_EMISSION_MAP
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
uniform sampler2D uEmissionMap;
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-11-28 19:37:47 +00:00
|
|
|
|
#if OOSTD_ILLUMINATION_MAP
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
uniform sampler2D uIlluminationMap;
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-01-16 18:53:56 +00:00
|
|
|
|
#if OOSTD_NORMAL_MAP
|
|
|
|
|
uniform sampler2D uNormalMap;
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-11-28 19:37:47 +00:00
|
|
|
|
#if OOSTD_NORMAL_AND_PARALLAX_MAP
|
|
|
|
|
uniform float uParallaxScale;
|
|
|
|
|
uniform float uParallaxBias;
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2008-11-28 19:37:47 +00:00
|
|
|
|
|
|
|
|
|
vec4 CalcDiffuseLight(in vec3 lightVector, in vec3 normal, in vec4 lightColor)
|
|
|
|
|
{
|
|
|
|
|
#if OOSTD_NORMAL_MAP
|
|
|
|
|
float intensity = dot(normal, lightVector);
|
|
|
|
|
#else
|
|
|
|
|
// dot(v, (0,0,1)) is v.x*0 + v.y*0 + v.z*1 = v.z
|
|
|
|
|
float intensity = lightVector.z;
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
#endif
|
2008-11-28 19:37:47 +00:00
|
|
|
|
intensity = max(intensity, 0.0);
|
|
|
|
|
return lightColor * intensity;
|
|
|
|
|
}
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
|
|
|
|
|
|
2008-11-28 19:37:47 +00:00
|
|
|
|
vec4 CalcSpecularLight(in vec3 lightVector, in vec3 eyeVector, in float exponent, in vec3 normal, in vec4 lightColor)
|
|
|
|
|
{
|
|
|
|
|
#if OOSTD_NORMAL_MAP
|
|
|
|
|
vec3 reflection = -reflect(lightVector, normal);
|
|
|
|
|
#else
|
|
|
|
|
/* reflect(I, N) is defined as I - 2 * dot(N, I) * N
|
|
|
|
|
If N is (0,0,1), this becomes (I.x,I.y,-I.z).
|
|
|
|
|
Note that we want it negated as per above.
|
|
|
|
|
*/
|
|
|
|
|
vec3 reflection = vec3(-lightVector.x, -lightVector.y, lightVector.z);
|
|
|
|
|
#endif
|
|
|
|
|
float intensity = dot(reflection, eyeVector);
|
|
|
|
|
intensity = pow(max(intensity, 0.0), exponent);
|
|
|
|
|
return lightColor * intensity;
|
|
|
|
|
}
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
|
|
|
|
|
|
2007-12-05 14:32:56 +00:00
|
|
|
|
uniform float uHullHeatLevel;
|
|
|
|
|
uniform float uTime;
|
2016-02-21 20:03:21 +00:00
|
|
|
|
uniform vec4 uFogColor;
|
2007-12-05 14:32:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Irregular flickering function.
|
2008-11-30 02:03:27 +00:00
|
|
|
|
float Pulse(in float value, in float timeScale)
|
2007-12-05 14:32:56 +00:00
|
|
|
|
{
|
|
|
|
|
float t = uTime * timeScale;
|
|
|
|
|
|
|
|
|
|
float s0 = t;
|
|
|
|
|
s0 -= floor(s0);
|
|
|
|
|
float sum = abs( s0 - 0.5);
|
|
|
|
|
|
|
|
|
|
float s1 = t * 0.7 - 0.05;
|
|
|
|
|
s1 -= floor(s1);
|
|
|
|
|
sum += abs(s1 - 0.5) - 0.25;
|
|
|
|
|
|
|
|
|
|
float s2 = t * 1.3 - 0.3;
|
|
|
|
|
s2 -= floor(s2);
|
|
|
|
|
sum += abs(s2 - 0.5) - 0.25;
|
|
|
|
|
|
|
|
|
|
float s3 = t * 5.09 - 0.6;
|
|
|
|
|
s3 -= floor(s3);
|
|
|
|
|
sum += abs(s3 - 0.5) - 0.25;
|
|
|
|
|
|
|
|
|
|
return (sum * 0.1 + 0.9) * value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Colour ramp from black through reddish brown/dark orange to yellow-white.
|
2008-11-30 02:03:27 +00:00
|
|
|
|
vec4 TemperatureGlow(in float level)
|
2007-12-05 14:32:56 +00:00
|
|
|
|
{
|
|
|
|
|
vec4 result = vec4(0);
|
|
|
|
|
|
|
|
|
|
result.r = level;
|
|
|
|
|
result.g = level * level * level;
|
|
|
|
|
result.b = max(level - 0.7, 0.0) * 2.0;
|
|
|
|
|
result.a = 1.0;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
void main(void)
|
|
|
|
|
{
|
|
|
|
|
vec4 totalColor = vec4(0);
|
2008-11-28 19:37:47 +00:00
|
|
|
|
|
|
|
|
|
// Get eye vector
|
|
|
|
|
#if NEED_EYE_VECTOR
|
2007-10-23 07:36:58 +00:00
|
|
|
|
vec3 eyeVector = normalize(vEyeVector);
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
#endif
|
2008-11-28 19:37:47 +00:00
|
|
|
|
|
|
|
|
|
// Get texture coords, using parallax mapping if appropriate
|
|
|
|
|
#if OOSTD_NORMAL_AND_PARALLAX_MAP
|
|
|
|
|
float parallax = texture2D(uNormalMap, vTexCoord).a;
|
|
|
|
|
parallax = parallax * uParallaxScale + uParallaxBias;
|
|
|
|
|
vec2 texCoord = vTexCoord - parallax * eyeVector.xy * vec2(-1.0, 1.0);
|
|
|
|
|
#else
|
|
|
|
|
#define texCoord vTexCoord
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2008-11-28 19:37:47 +00:00
|
|
|
|
// Get normal
|
|
|
|
|
#if OOSTD_NORMAL_MAP
|
2010-01-09 20:18:21 +00:00
|
|
|
|
vec3 normal = normalize(texture2D(uNormalMap, texCoord).rgb - 0.5);
|
2008-11-28 19:37:47 +00:00
|
|
|
|
#else
|
|
|
|
|
const vec3 normal = vec3(0.0, 0.0, 1.0);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Get light vectors
|
2010-05-09 23:13:12 +00:00
|
|
|
|
vec3 lightVector = normalize(vLight1Vector);
|
2008-11-28 19:37:47 +00:00
|
|
|
|
|
|
|
|
|
// Get ambient colour
|
2009-12-10 17:45:54 +00:00
|
|
|
|
vec4 ambientLight = gl_LightModel.ambient;
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
|
2008-11-28 19:37:47 +00:00
|
|
|
|
// Get emission colour
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
#if OOSTD_EMISSION || OOSTD_EMISSION_MAP
|
|
|
|
|
vec4 emissionColor = vec4(1.0);
|
|
|
|
|
#if OOSTD_EMISSION
|
2007-10-23 07:36:58 +00:00
|
|
|
|
emissionColor *= gl_FrontMaterial.emission;
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
#endif
|
|
|
|
|
#if OOSTD_EMISSION_MAP
|
|
|
|
|
vec4 emissionMapColor = texture2D(uEmissionMap, texCoord);
|
|
|
|
|
emissionColor *= emissionMapColor;
|
|
|
|
|
#endif
|
|
|
|
|
emissionColor.a = 1.0;
|
|
|
|
|
totalColor += emissionColor;
|
|
|
|
|
#endif
|
2008-11-28 19:37:47 +00:00
|
|
|
|
|
|
|
|
|
// Get illumination colour
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
#if OOSTD_EMISSION_AND_ILLUMINATION_MAP
|
|
|
|
|
// Use alpha channel of emission map as white illumination
|
|
|
|
|
vec4 illuminationMapLight = vec4(emissionMapColor.aaa, 1.0);
|
|
|
|
|
#elif OOSTD_ILLUMINATION_MAP
|
|
|
|
|
vec4 illuminationMapLight = texture2D(uIlluminationMap, texCoord);
|
|
|
|
|
#endif
|
2010-04-21 18:21:29 +00:00
|
|
|
|
#ifdef OOSTD_ILLUMINATION_COLOR
|
|
|
|
|
// OOSTD_ILLUMINATION_COLOR, if defined, is a vec4() declaration.
|
|
|
|
|
illuminationMapLight *= OOSTD_ILLUMINATION_COLOR;
|
|
|
|
|
#endif
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
|
|
|
|
|
vec4 diffuseLight = vec4(0);
|
2010-05-09 23:13:12 +00:00
|
|
|
|
diffuseLight += CalcDiffuseLight(lightVector, normal, gl_LightSource[1].diffuse);
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
|
2008-11-28 19:37:47 +00:00
|
|
|
|
#if HAVE_ILLUMINATION
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
diffuseLight += illuminationMapLight;
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-11-28 19:37:47 +00:00
|
|
|
|
// Get specular parameters
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
#if OOSTD_SPECULAR_MAP
|
|
|
|
|
vec4 specularMapColor = texture2D(uSpecularMap, texCoord);
|
|
|
|
|
float specularExponentLevel = pow(specularMapColor.a, 2.0) + 0.001;
|
|
|
|
|
specularMapColor.a = 1.0;
|
2008-11-28 20:20:58 +00:00
|
|
|
|
#define APPLY_MAPPED_EXPONENT exponent = (exponent - 1.0) * specularExponentLevel + 1.0
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
#else
|
2008-11-28 20:20:58 +00:00
|
|
|
|
#define APPLY_MAPPED_EXPONENT exponent += 0.001
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
#endif
|
2008-11-28 19:37:47 +00:00
|
|
|
|
|
|
|
|
|
// Calculate specular light
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
#if OOSTD_SPECULAR
|
|
|
|
|
vec4 specularLight = vec4(0);
|
|
|
|
|
float exponent = gl_FrontMaterial.shininess;
|
2008-11-28 20:20:58 +00:00
|
|
|
|
APPLY_MAPPED_EXPONENT;
|
2010-05-09 23:13:12 +00:00
|
|
|
|
specularLight += CalcSpecularLight(lightVector, eyeVector, exponent, normal, gl_LightSource[1].specular);
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
specularLight.a = 1.0;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
vec4 ambientColor = gl_FrontMaterial.ambient;
|
|
|
|
|
vec4 diffuseColor = gl_FrontMaterial.diffuse;
|
|
|
|
|
#if OOSTD_SPECULAR
|
|
|
|
|
vec4 specularColor = gl_FrontMaterial.specular;
|
|
|
|
|
#endif
|
|
|
|
|
#if OOSTD_SPECULAR_MAP
|
|
|
|
|
specularColor *= specularMapColor;
|
|
|
|
|
#endif
|
2010-04-07 22:35:24 +00:00
|
|
|
|
|
2012-01-16 18:53:56 +00:00
|
|
|
|
#if OOSTD_DIFFUSE_MAP
|
|
|
|
|
#if !OOSTD_DIFFUSE_MAP_IS_CUBE_MAP
|
2010-04-07 22:35:24 +00:00
|
|
|
|
vec4 diffuseMapColor = texture2D(uDiffuseMap, texCoord);
|
2012-01-16 18:53:56 +00:00
|
|
|
|
#else
|
2010-04-21 19:12:26 +00:00
|
|
|
|
vec4 diffuseMapColor = textureCube(uDiffuseMap, vCubeTexCoords);
|
2010-04-07 22:35:24 +00:00
|
|
|
|
#endif
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
diffuseMapColor.a = 1.0;
|
|
|
|
|
diffuseColor *= diffuseMapColor;
|
|
|
|
|
ambientColor *= diffuseMapColor;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
totalColor += ambientColor * ambientLight + diffuseColor * diffuseLight;
|
|
|
|
|
#if OOSTD_SPECULAR
|
|
|
|
|
totalColor += specularColor * specularLight;
|
|
|
|
|
#endif
|
|
|
|
|
|
2007-12-05 14:32:56 +00:00
|
|
|
|
// Heat glow
|
|
|
|
|
float hullHeat = max(uHullHeatLevel - 0.5, 0.0) * 2.0;
|
|
|
|
|
hullHeat = Pulse(hullHeat * hullHeat, 0.1);
|
|
|
|
|
totalColor += TemperatureGlow(hullHeat);
|
|
|
|
|
|
2016-02-24 18:45:28 +00:00
|
|
|
|
gl_FragColor = mix(totalColor, vec4(uFogColor.xyz, 1.0), uFogColor.w);
|
* Got Game Options submenu working under OS X.
* Save reduced detail, wireframe and shader settings in preferences.
* Implemented variable shader complexity support.
Added default shader, used for all otherwise-unshaded ships with full shaders on, and for smooth ships or ships with effect maps specified in material dictionary with simple shaders.
* All ships now drawn with slight specular highlight by default (shininess = 10, intensity = 0.2) except in reduced detail mode.
* (JS) Made Ship.shipDescription read-write (except for the player).
* (JS) Added global function ExpandDescription(string : String), to perform substitutions like %H, [commander_name] and so forth.
* (JS) Added global function RandomName(), intended to be like %R substitution. In so doing, I discovered that %R is broken, but left it as-is so it will generate the same name for existing descriptions. Added %X to do the same thing, but without the bugs. RandomName() is different from either in that it doesn't use the "predictable" PRNG, so it will provide a new name each time. To use the "predictable" variant in JavaScript, use ExpandDescription("%X").
* Ships that hyperspace out are no longer replenished in interstellar space.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1228 127b21dd-08f5-0310-b4b7-95ae10353056
2007-10-22 12:18:18 +00:00
|
|
|
|
}
|