Last active
May 19, 2019 09:28
-
-
Save britzl/9880dad39b0d01fa0c908927320dd6d1 to your computer and use it in GitHub Desktop.
DEPRECATED - How to tint labels in Defold
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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