Skip to content

Commit

Permalink
Merge pull request #49952 from Calinou/spatialmaterial-depth-triplana…
Browse files Browse the repository at this point in the history
…r-print-warning

Print warning in SpatialMaterial when depth and triplanar are active
  • Loading branch information
akien-mga authored May 2, 2022
2 parents c1a0e6b + b174c67 commit 815f7fe
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scene/resources/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,20 @@ void SpatialMaterial::_update_shader() {
code += "\tvec2 base_uv2 = UV2;\n";
}

if (features[FEATURE_DEPTH_MAPPING] && flags[FLAG_UV1_USE_TRIPLANAR]) {
// Display both resource name and albedo texture name.
// Materials are often built-in to scenes, so displaying the resource name alone may not be meaningful.
// On the other hand, albedo textures are almost always external to the scene.
if (textures[TEXTURE_ALBEDO].is_valid()) {
WARN_PRINT(vformat("%s (albedo %s): Depth mapping is not supported on triplanar materials. Ignoring depth mapping in favor of triplanar mapping.", get_path(), textures[TEXTURE_ALBEDO]->get_path()));
} else if (!get_path().empty()) {
WARN_PRINT(vformat("%s: Depth mapping is not supported on triplanar materials. Ignoring depth mapping in favor of triplanar mapping.", get_path()));
} else {
// Resource wasn't saved yet.
WARN_PRINT("Depth mapping is not supported on triplanar materials. Ignoring depth mapping in favor of triplanar mapping.");
}
}

if (!VisualServer::get_singleton()->is_low_end() && features[FEATURE_DEPTH_MAPPING] && !flags[FLAG_UV1_USE_TRIPLANAR]) { //depthmap not supported with triplanar
code += "\t{\n";
code += "\t\tvec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT*depth_flip.x,-BINORMAL*depth_flip.y,NORMAL));\n"; // binormal is negative due to mikktspace, flip 'unflips' it ;-)
Expand Down

0 comments on commit 815f7fe

Please sign in to comment.