godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.04k stars 21.18k forks source link

Shaders in opengl3 renderer do not interpolate texture #70799

Closed jmdejong closed 1 year ago

jmdejong commented 1 year ago

Godot version

v4.0.beta10.official.d0398f62f

System information

archlinux; vulkan on dedicated NVIDIA GeForce RTX 3060 Laptop GPU; opengl3 on integrated AMD Radeon Graphics (renoir, LLVM 14.0.6, DRM 3.49, 6.1.1-arch1-1)

Issue description

Setting the albedo in the fragment shader based on a sampled texture does not do any interpolation between the pixels of the texture with the opengl3 renderer.

Example of viewing a quadmesh with a green texture in opengl3: opengl_texture

Same view with the vulkan renderer: vulkan_texture (the brightness seems to be a different problem)

used texture: ground_grass

Shader:

render_mode world_vertex_coords, unshaded;

uniform sampler2D tex;

void fragment() {
    ALBEDO = texture(tex, UV).xyz;
}

Steps to reproduce

Minimal reproduction project

texturebrightness.zip

Calinou commented 1 year ago

Does it work if you use uniform sampler2D tex : filter_linear;?

It's possible that the OpenGL renderer defaults to nearest-neighbor filtering when no hint is specified, while the Vulkan rendere defaults to linear filtering.

clayjohn commented 1 year ago

Indeed it sounds like the OpenGL renderer isn't using the same defaults as the Vulkan renderer. It should.

jmdejong commented 1 year ago

Yes, using filter_linear fixed it.

Also, it seems that using the mipmap was not included in the opengl defaults either.

HolonProduction commented 1 year ago

Another default mismatch exists with repeat_enable. The opengl render will default to repeat_enable but vulcan uses repeat_disable by default.

clayjohn commented 1 year ago

This was fixed yesterday in https://github.com/godotengine/godot/pull/71011 the defaults should be good now.