godot-简单的斯派德着色器结果太亮了(未展示,习惯)

发布于 2025-02-05 18:41:09 字数 1431 浏览 1 评论 0原文

:)

tl:dr

在编写自定义空间着色器 aberedo颜色不是输出颜色,即使render_mode unhanded << /代码>已设置。


长篇小说

我在Godot v3.4.4.stable.official [419E713A2]中创建了一个新项目,并简单地添加了两个CSGBOX。

对于留下一个,我分配了空间材料,并将其设置为 unhaded ,并分配了 abredo纹理(见下文) 。结果是预期的。

但是,对于,我分配了 shadermaterial ,并写下了以下简单,着色器:

shader_type spatial;
render_mode unshaded;

uniform sampler2D albedo;

void fragment() {
  ALBEDO = texture(albedo, UV).rgb;
}

在将相同的纹理分配给abredo 着色器参数,结果太亮了。我已经尝试了几个render_modes,例如镜面和其他内容,例如纹理导入设置,但无法弄清楚如何获得与左盒相同的结果。

纹理

”我选择的纹理“

结果

“两个立方体”

左侧:左侧:正如预期使用空间材料,右侧:使用shadermaterial

示例项目

好吧,这没什么大的,但是如果您想看看: https> https: //files.catbox.moe/nj407g.zip

预先感谢您❤

:)

TL:DR

When writing a custom spatial shader the ALBEDO color isn't the output color, even if render_mode unshaded is set.


Long story

I created a new project in Godot v3.4.4.stable.official [419e713a2] and simply added two CSGBox.

For the left one I assigned a SpatialMaterial and set it to unshaded and assigned an albedo texture (see below). The result is as expected.

However, for the right one I assigned a ShaderMaterial and wrote the following, very simple, shader:

shader_type spatial;
render_mode unshaded;

uniform sampler2D albedo;

void fragment() {
  ALBEDO = texture(albedo, UV).rgb;
}

After assigning the same texture to the albedo shader parameter, the result is a lot too bright. I already tried several render_modes, variables such as SPECULAR and other things like texture import settings, but couldn't figure out how to get the same result as the left box.

The texture

The texture I choose

The result

The two cubes

Left side: As expected using SpatialMaterial, Right side: Too bright using ShaderMaterial

Sample project

Well, it's nothing big, but if you want to take a look: https://files.catbox.moe/nj407g.zip

Thank you in advance ❤

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无语# 2025-02-12 18:41:09

这是教程和解释中通常会忽略的:添加​​hint_albedo告诉戈多特对线性转换进行SRGB。关于“ noreferrer”> perentions:

重要的是要了解,作为颜色提供的纹理需要提示适当的srgb-&gt;线性转换(即hint_albedo),因为Godot的3D引擎在线性色彩空间中呈现。

因此,更改此行:

uniform sampler2D albedo;

对此:

uniform sampler2D albedo:hint_albedo;

它应该给您预期的结果。

This is something that is often dismissed in tutorials and explanations: Adding hint_albedo tells Godot to do an sRGB to linear conversion. The documentation about uniforms mentions:

It's important to understand that textures that are supplied as color require hints for proper sRGB->linear conversion (i.e. hint_albedo), as Godot's 3D engine renders in linear color space.

So change this line:

uniform sampler2D albedo;

To this:

uniform sampler2D albedo:hint_albedo;

And it should give you the expected result.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文