Add option to use world coordinates in canvas item shader

By using the render mode `world_vertex_coords` you can automatically use the vertex coordinates in world space
This commit is contained in:
Patrick
2023-08-30 14:59:06 +02:00
parent d2f76e8786
commit c98ab5aba3
5 changed files with 13 additions and 2 deletions

View File

@ -199,6 +199,10 @@ void main() {
#ifdef USE_POINT_SIZE
float point_size = 1.0;
#endif
#ifdef USE_WORLD_VERTEX_COORDS
vertex = (model_matrix * vec4(vertex, 0.0, 1.0)).xy;
#endif
{
#CODE : VERTEX
}
@ -207,7 +211,7 @@ void main() {
pixel_size_interp = abs(read_draw_data_dst_rect.zw) * vertex_base;
#endif
#if !defined(SKIP_TRANSFORM_USED)
#if !defined(SKIP_TRANSFORM_USED) && !defined(USE_WORLD_VERTEX_COORDS)
vertex = (model_matrix * vec4(vertex, 0.0, 1.0)).xy;
#endif

View File

@ -1184,6 +1184,7 @@ MaterialStorage::MaterialStorage() {
actions.render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
actions.render_mode_defines["unshaded"] = "#define MODE_UNSHADED\n";
actions.render_mode_defines["light_only"] = "#define MODE_LIGHT_ONLY\n";
actions.render_mode_defines["world_vertex_coords"] = "#define USE_WORLD_VERTEX_COORDS\n";
actions.global_buffer_array_variable = "global_shader_uniforms";