Replace textureSize() with a uniform in BaseMaterial3D for MSDF rendering

This uniform was already defined for other uses previously.

`textureSize()` is known to be slow on mobile platforms due to how
the drivers implement it there, so it's best avoided.
This commit is contained in:
Hugo Locurcio 2024-12-11 15:44:06 +01:00
parent 44dfa7e710
commit 3dfc832272
No known key found for this signature in database
GPG Key ID: 39E8F8BE30B0A49C

View File

@ -1515,7 +1515,7 @@ void fragment() {)";
vec3(1.0 + 0.055) * pow(albedo_tex.rgb, vec3(1.0 / 2.4)) - vec3(0.055),
vec3(12.92) * albedo_tex.rgb,
lessThan(albedo_tex.rgb, vec3(0.0031308)));
vec2 msdf_size = vec2(msdf_pixel_range) / vec2(textureSize(texture_albedo, 0));
vec2 msdf_size = vec2(msdf_pixel_range) / vec2(albedo_texture_size));
)";
if (flags[FLAG_USE_POINT_SIZE]) {
code += " vec2 dest_size = vec2(1.0) / fwidth(POINT_COORD);\n";