Skip to content

Instantly share code, notes, and snippets.

@britzl
Last active May 19, 2019 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save britzl/9880dad39b0d01fa0c908927320dd6d1 to your computer and use it in GitHub Desktop.
Save britzl/9880dad39b0d01fa0c908927320dd6d1 to your computer and use it in GitHub Desktop.
DEPRECATED - How to tint labels in Defold
varying mediump vec2 var_texcoord0;
varying lowp vec4 var_face_color;
varying lowp vec4 var_outline_color;
varying lowp vec4 var_shadow_color;
uniform lowp vec4 texture_size_recip;
uniform lowp sampler2D texture;
uniform lowp vec4 tint;
void main()
{
// Outline
lowp vec2 t = texture2D(texture, var_texcoord0.xy).xy;
gl_FragColor = vec4(var_face_color.xyz, 1.0) * t.x * var_face_color.w + vec4(var_outline_color.xyz * t.y * var_outline_color.w, t.y * var_outline_color.w) * (1.0 - t.x);
// Pre-multiply alpha since all runtime textures already are
lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w);
gl_FragColor = gl_FragColor * tint_pm;
}
name: "tinted_label"
tags: "tile"
vertex_program: "/builtins/fonts/font.vp"
fragment_program: "/tinted_label/tinted_label.fp"
vertex_constants {
name: "view_proj"
type: CONSTANT_TYPE_VIEWPROJ
value {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
}
fragment_constants {
name: "tint"
type: CONSTANT_TYPE_USER
value {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
}
function init(self)
go.set("#label", "tint", vmath.vector4(1.0, 0, 0, 1.0))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment