godot-简单的斯派德着色器结果太亮了(未展示,习惯)
:)
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 result
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是教程和解释中通常会忽略的:添加
hint_albedo
告诉戈多特对线性转换进行SRGB。关于“ noreferrer”> perentions:因此,更改此行:
对此:
它应该给您预期的结果。
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:So change this line:
To this:
And it should give you the expected result.