Implemented rim_light and rim_power shader parameters, enabling outlining of objects on a per-model basis.

Will need to later refactor to allow for a more scalable means of adding per-model shader attributes.

--HG--
branch : nfb
This commit is contained in:
2013-12-05 01:09:31 -08:00
parent c7948ea314
commit 79abdd98d0
26 changed files with 156 additions and 50 deletions

View File

@@ -27,6 +27,11 @@
#extension GL_EXT_shadow_samplers : require
#if ENABLE_RIM_COLOR == 1
uniform lowp vec3 rim_color;
uniform mediump float rim_power;
#endif
#if FOG_TYPE > 0
// FOG_TYPE 1 - Linear
// FOG_TYPE 2 - Exponential
@@ -111,18 +116,27 @@
uniform sampler2D reflectionTexture;
#endif
#if ENABLE_RIM_COLOR == 1
#define NEED_EYEVEC
#endif
#if HAS_REFLECTION_CUBE_MAP == 1
uniform lowp vec3 material_reflection;
uniform samplerCube reflectionCubeTexture;
#if HAS_NORMAL_MAP == 1
varying highp mat3 tangent_to_world_matrix;
varying mediump vec3 eyeVec;
#define NEED_EYEVEC
uniform highp mat4 model_matrix;
#else
varying mediump vec3 reflectionVec;
#endif
#endif
#ifdef NEED_EYEVEC
varying mediump vec3 eyeVec;
#endif
#if SHADOW_QUALITY >= 1
#ifdef GL_EXT_shadow_samplers
@@ -394,6 +408,12 @@ void main()
#endif
#if ENABLE_RIM_COLOR == 1
lowp float rim = 1.0 - clamp(dot(normalize(eyeVec), normal), 0.0, 1.0);
gl_FragColor += vec4(rim_color, 1.0) * pow(rim, rim_power));
#endif
#if BONE_COUNT > 0
gl_FragColor.b = 1.0;
#endif

View File

@@ -138,11 +138,14 @@ uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying t
varying mediump float specularFactor;
#endif
#if ENABLE_RIM_COLOR == 1
#define NEED_EYEVEC
#endif
#if HAS_REFLECTION_CUBE_MAP == 1
#if HAS_NORMAL_MAP == 1
#define NEED_EYEVEC
uniform highp mat4 model_inverse_transpose_matrix;
varying mediump vec3 eyeVec;
varying highp mat3 tangent_to_world_matrix;
#else
uniform highp mat4 model_matrix;
@@ -150,6 +153,10 @@ uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying t
#endif
#endif
#ifdef NEED_EYEVEC
varying mediump vec3 eyeVec;
#endif
#if HAS_DIFFUSE_MAP_SCALE == 1
uniform highp vec2 diffuseTexture_Scale;
#endif
@@ -246,7 +253,7 @@ void main()
#if HAS_REFLECTION_CUBE_MAP == 1
#if HAS_NORMAL_MAP == 1
eyeVec = normalize(camera_position_model_space - vertex_position_skinned);
#else
// Calculate reflection vector as I - 2.0 * dot(N, I) * N
mediump vec3 eyeVec = normalize(camera_position_model_space - vertex_position_skinned);
@@ -255,6 +262,9 @@ void main()
#endif
#endif
#ifdef NEED_EYEVEC
eyeVec = normalize(camera_position_model_space - vertex_position_skinned);
#endif
#if HAS_LIGHT_MAP == 1
// Pass shadow UV co-ordinates