diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-07-04 17:26:25 +0200 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-08-16 05:19:39 +0200 |
commit | c9a491b6710f62e5bf2007cf3b36322c7a247521 (patch) | |
tree | eb1489b366b637a43f0023f1c054ad35eb667192 /scene/resources/material.cpp | |
parent | 1ed00dca882118598d14eae315f608af9de758cf (diff) | |
download | redot-engine-c9a491b6710f62e5bf2007cf3b36322c7a247521.tar.gz |
Add a comment at the top of generated shaders
This comment is useful to determine the origin of ShaderMaterials
converted from built-in material types (such as CanvasItemMaterial
or StandardMaterial3D).
The Godot version is also included in case the shader needs to be
regenerated with a newer engine version.
Diffstat (limited to 'scene/resources/material.cpp')
-rw-r--r-- | scene/resources/material.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 896a33e02e..1d2a2ef26c 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -31,6 +31,7 @@ #include "material.h" #include "core/config/engine.h" +#include "core/version.h" #ifdef TOOLS_ENABLED #include "editor/editor_settings.h" @@ -469,7 +470,12 @@ void BaseMaterial3D::_update_shader() { //must create a shader! - String code = "shader_type spatial;\nrender_mode "; + // Add a comment to describe the shader origin (useful when converting to ShaderMaterial). + String code = vformat( + "// NOTE: Shader automatically converted from " VERSION_NAME " " VERSION_FULL_CONFIG "'s %s.\n\n", + orm ? "ORMMaterial3D" : "StandardMaterial3D"); + + code += "shader_type spatial;\nrender_mode "; switch (blend_mode) { case BLEND_MODE_MIX: code += "blend_mix"; |