mirror of
https://github.com/godotengine/godot.git
synced 2025-01-06 17:37:18 +08:00
Fix shader compilation error when enabling texture MSDF and UV1 Triplanar at the same time
This commit is contained in:
parent
0175be8948
commit
0c0723c659
@ -821,7 +821,18 @@ uniform float distance_fade_max : hint_range(0.0, 4096.0, 0.01);
|
|||||||
)";
|
)";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags[FLAG_ALBEDO_TEXTURE_MSDF]) {
|
if (flags[FLAG_ALBEDO_TEXTURE_MSDF] && flags[FLAG_UV1_USE_TRIPLANAR]) {
|
||||||
|
String msg = "MSDF is not supported on triplanar materials. Ignoring MSDF in favor of triplanar mapping.";
|
||||||
|
if (textures[TEXTURE_ALBEDO].is_valid()) {
|
||||||
|
WARN_PRINT(vformat("%s (albedo %s): " + msg, get_path(), textures[TEXTURE_ALBEDO]->get_path()));
|
||||||
|
} else if (!get_path().is_empty()) {
|
||||||
|
WARN_PRINT(vformat("%s: " + msg, get_path()));
|
||||||
|
} else {
|
||||||
|
WARN_PRINT(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags[FLAG_ALBEDO_TEXTURE_MSDF] && !flags[FLAG_UV1_USE_TRIPLANAR]) {
|
||||||
code += R"(
|
code += R"(
|
||||||
uniform float msdf_pixel_range : hint_range(1.0, 100.0, 1.0);
|
uniform float msdf_pixel_range : hint_range(1.0, 100.0, 1.0);
|
||||||
uniform float msdf_outline_size : hint_range(0.0, 250.0, 1.0);
|
uniform float msdf_outline_size : hint_range(0.0, 250.0, 1.0);
|
||||||
@ -1270,7 +1281,7 @@ void vertex() {)";
|
|||||||
|
|
||||||
code += "}\n";
|
code += "}\n";
|
||||||
|
|
||||||
if (flags[FLAG_ALBEDO_TEXTURE_MSDF]) {
|
if (flags[FLAG_ALBEDO_TEXTURE_MSDF] && !flags[FLAG_UV1_USE_TRIPLANAR]) {
|
||||||
code += R"(
|
code += R"(
|
||||||
float msdf_median(float r, float g, float b, float a) {
|
float msdf_median(float r, float g, float b, float a) {
|
||||||
return min(max(min(r, g), min(max(r, g), b)), a);
|
return min(max(min(r, g), min(max(r, g), b)), a);
|
||||||
@ -1413,7 +1424,7 @@ void fragment() {)";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags[FLAG_ALBEDO_TEXTURE_MSDF]) {
|
if (flags[FLAG_ALBEDO_TEXTURE_MSDF] && !flags[FLAG_UV1_USE_TRIPLANAR]) {
|
||||||
code += R"(
|
code += R"(
|
||||||
{
|
{
|
||||||
// Albedo Texture MSDF: Enabled
|
// Albedo Texture MSDF: Enabled
|
||||||
@ -1425,13 +1436,9 @@ void fragment() {)";
|
|||||||
)";
|
)";
|
||||||
if (flags[FLAG_USE_POINT_SIZE]) {
|
if (flags[FLAG_USE_POINT_SIZE]) {
|
||||||
code += " vec2 dest_size = vec2(1.0) / fwidth(POINT_COORD);\n";
|
code += " vec2 dest_size = vec2(1.0) / fwidth(POINT_COORD);\n";
|
||||||
} else {
|
|
||||||
if (flags[FLAG_UV1_USE_TRIPLANAR]) {
|
|
||||||
code += " vec2 dest_size = vec2(1.0) / fwidth(uv1_triplanar_pos);\n";
|
|
||||||
} else {
|
} else {
|
||||||
code += " vec2 dest_size = vec2(1.0) / fwidth(base_uv);\n";
|
code += " vec2 dest_size = vec2(1.0) / fwidth(base_uv);\n";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
code += R"(
|
code += R"(
|
||||||
float px_size = max(0.5 * dot(msdf_size, dest_size), 1.0);
|
float px_size = max(0.5 * dot(msdf_size, dest_size), 1.0);
|
||||||
float d = msdf_median(albedo_tex.r, albedo_tex.g, albedo_tex.b, albedo_tex.a) - 0.5;
|
float d = msdf_median(albedo_tex.r, albedo_tex.g, albedo_tex.b, albedo_tex.a) - 0.5;
|
||||||
|
Loading…
Reference in New Issue
Block a user