Material.tres 使用旧的已弃用的参数名称?

Mah*_*ood 4 godot godot-shader-language

问题:

我有一个使用 godot4(第一个稳定版本)中的着色器的材质,这是着色器的代码:

shader_type canvas_item;

uniform sampler2D custom_texture;
uniform float cutoff: hint_range(0, 1) = 1;
uniform float smoothness: hint_range(0, 1) = 0.1;
uniform vec3 color = vec3(0, 0, 0);
uniform bool inverted = false;
uniform bool linear_fade = true;

void fragment() {
    if (!linear_fade) {
        float value = texture(custom_texture, UV).r;
        if (inverted) {
            value = 1.0 - value;
        }
        float alpha = smoothstep(cutoff, cutoff + smoothness, value * (1.0 - smoothness) + smoothness);
        COLOR = vec4(color.rgb, alpha);
    } else {
        COLOR = vec4(color.rgb, (1.0 - cutoff));
    }
}
Run Code Online (Sandbox Code Playgroud)

在将此着色器附加到颜色矩形的情况下运行游戏场景后,我多次收到此警告消息:

W 0:00:01:0839   _set: This material (containing shader with path: 'res://addons/scene_manager/scene_manager.tres::Shader_vksmm') uses an old deprecated parameter names. Consider re-saving this resource (or scene which contains it) in order for it to continue working in future versions.
  <C++ Source>   scene/resources/material.cpp:184 @ _set()
Run Code Online (Sandbox Code Playgroud)

如果您想自己实际创建此错误消息并查看发生了什么,您可以克隆scene_manager存储库(这是 godot 的插件)并运行其演示以查看我正在处理的原始问题。

感谢所有在这方面帮助我的人。

Mah*_*ood 10

回答之前

实际上有人回答了这个问题,但不是在这里,答案是在场景管理器项目的github 问题线程中,所有功劳都归功于那个人。

实际答案

问题与我在问题中提到的着色器代码或材质甚至 ColorRect 无关,但它与我在场景中更改着色器代码的某些变量的动画播放器有关。

看看这个: godot4参数问题

看一下左侧提到的参数名称:

material:shader_param/cutoff

您所要做的就是将该param部分更改为parameter. 像这样:

material:shader_parameter/cutoff

将其应用于所有其他动画并解决问题。

@卢克达杜克