Added vertex color support for the FontMaterial.

This commit is contained in:
Relintai 2024-01-04 15:56:01 +01:00
parent caa9e4d39c
commit 8d7321f93c
2 changed files with 6 additions and 2 deletions

View File

@ -137,7 +137,7 @@ GameScene::GameScene() {
//_font_test_mi->transform.scale(Vector2(10, 10));
_font_test_mi->transform.set_origin(Vector2(1000, 400));
_font->generate_mesh("asdfgh\nasdfvb", _font_test_mesh);
_font->generate_mesh("asdfgh\nasdfvb", _font_test_mesh, Color(1, 1, 0));
_font_test_mesh->upload();
image.instance();

View File

@ -45,11 +45,14 @@ public:
"\n"
"attribute vec4 a_position;\n"
"attribute vec2 a_uv;\n"
"attribute vec4 a_color;\n"
"\n"
"varying vec2 v_uv;\n"
"varying vec4 v_color;\n"
"\n"
"void main() {\n"
" v_uv = a_uv;\n"
" v_color = a_color;\n"
" gl_Position = u_proj_matrix * u_model_view_matrix * a_position;\n"
"}"
};
@ -64,6 +67,7 @@ public:
"uniform sampler2D u_texture;\n"
"\n"
"varying vec2 v_uv;\n"
"varying vec4 v_color;\n"
"\n"
"void main() {\n"
" vec4 col = texture2D(u_texture, v_uv);\n"
@ -72,7 +76,7 @@ public:
" discard;\n"
" }\n"
"\n"
" gl_FragColor = col;\n"
" gl_FragColor = col * v_color;\n"
"}"
};