Skip to content

Commit

Permalink
Renderer|Shaders: "model.skeletal.generic" supports uMapTime, custom …
Browse files Browse the repository at this point in the history
…UV macro

The generic shader can now be customized with predefined macros.
The PREDEF_TRANSFORM_UV() macro is called before texel lookup.

uMapTime is available for use in the shader, although the default
implementation does not use it for anything.

IssueID #1995
  • Loading branch information
skyjake committed Dec 18, 2015
1 parent 742a4e6 commit 637ac10
Showing 1 changed file with 9 additions and 1 deletion.
@@ -1,12 +1,15 @@
model.skeletal {
# Shader for skeletal animation and generic per-pixel lighting:
# diffuse color, normal map, emissive map, specular intensity.
# Also supports uMapTime and a custom UV macro.
shader generic {
variable uAlphaLimit { value = 0 }
variable uAlpha { value = 1 }
variable uColor { value <1, 1, 1> }
variable uEmission { value = 0 }
variable uOffsetUV { value <0, 0> }

variable uMapTime {}

# Mapping when used with ModelDrawable.
textureMapping <diffuse, normals, specular, emission>
Expand Down Expand Up @@ -51,6 +54,8 @@ model.skeletal {
vColor = aColor;
}"

defines $= {'PREDEF_TRANSFORM_UV(uv)': ''}

include.fragment <include/texture.glsl,
include/lighting.glsl,
include/fog.glsl>
Expand All @@ -59,6 +64,7 @@ model.skeletal {
uniform highp float uAlpha; // diffuse alpha multiplier
uniform highp float uAlphaLimit; // alpha test to discard fragments
uniform highp vec2 uOffsetUV;
uniform highp float uMapTime;

varying highp vec4 vColor;
varying highp vec2 vUV;
Expand All @@ -67,7 +73,9 @@ model.skeletal {
void main(void)
{
// Calculate UV at the fragment (wrapped inside the bounds).
highp vec2 wrappedUV = fract(vUV + uOffsetUV);
highp vec2 wrappedUV = vUV + uOffsetUV;
PREDEF_TRANSFORM_UV(wrappedUV);
wrappedUV = fract(wrappedUV);
highp vec2 uv = mapToBounds(wrappedUV, vUVBounds[0]);
highp vec2 normalUV = mapToBounds(wrappedUV, vUVBounds[1]);
highp vec2 specularUV = mapToBounds(wrappedUV, vUVBounds[2]);
Expand Down

0 comments on commit 637ac10

Please sign in to comment.