godotengine / godot

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

Web export renders 1px wide textures completely black. #99399

Open varianttombstones opened 2 weeks ago

varianttombstones commented 2 weeks ago

Tested versions

System information

Windows 10 - v4.3.stable.steam [77dcf97d8] - Replicates on OpenGL

Issue description

If you set a StandardMaterial3D's texture to a 1 pixel thin texture and apply it to a mesh, it will render the mesh's material as completely black when playing via web.

In Editor as a single pixel thin texture: image

In Desktop debug (Windows): image

In web debug (Waterfox, but has been tested on Chrome, Edge, Firefox, etc, same result): image

Steps to reproduce

Minimal reproduction project (MRP)

minimal-reproduction-project.zip

adamscott commented 2 days ago

@varianttombstones Please create and join a minimal reproduction project. I was about to test your issue, but there's no project file.

varianttombstones commented 13 hours ago

@varianttombstones Please create and join a minimal reproduction project. I was about to test your issue, but there's no project file.

Hey @adamscott , I have attached an MRP it's not specifically web exports the issue is present across the entire compatibility renderer.

adamscott commented 11 hours ago

It seems to be related to the litteral "shading", as unshaded renders flawlessly.

Unshaded Per-pixel / Per-vertex
Image Image
adamscott commented 11 hours ago

Just found out that if you add a light source in Compatibility, it lights/shows up properly. It's not related to the texture size. I renamed the issue in consequence.

Calinou commented 11 hours ago

In web debug (Waterfox, but has been tested on Chrome, Edge, Firefox, etc, same result):

There's a shadow being cast, so default lighting is working. The plane also has a blue-ish hue, so it's taking the environment lighting in.

That said, remember that default lights don't apply to the running project, only the editor. It's why you need to add a DirectionalLight3D node from the editor preview. OP already did this because their lighting is working correctly when running the project on Windows.

adamscott commented 11 hours ago

I tried the MRP locally. There's no lights in the main scene.

Calinou commented 11 hours ago

I found the issue: when using Compatibility, the radiance map doesn't update according to the Default Clear Color project setting.

If you set the clear color in _ready() instead (or even in _init()), it'll work:

RenderingServer.set_default_clear_color(Color(1, 1, 1))
varianttombstones commented 11 hours ago

I tried the MRP locally. There's no lights in the main scene.

* the cube is black on _Compatibility_

* the cube is lit on _Forward+_

I want to alert both of you to the fact that my post originally said the issue is when testing web exports, I forgot to add lighting and got confused, so I guess it's 2 issues as I just tested the web exports based on both of your comments and even with lighting it renders pitch black just for 1 pixel thin textures.

varianttombstones commented 11 hours ago

Just found out that if you add a light source in Compatibility, it lights/shows up properly. It's not related to the texture size. I renamed the issue in consequence.

Desktop Testing Image Web Testing Image

Both have lighting. On the web export, texture size is still a problem.

Calinou commented 11 hours ago

The issue is likely fixed in 4.4.dev by properly handling VRAM-compressed textures that have a size that isn't a multiple of 4 pixels (the texture in the MRP is 1×10). In the meantime, switch to Lossless compression in the Import dock (you won't save any meaningful amount of VRAM on such a small texture anyway, it only loses quality).

varianttombstones commented 10 hours ago

Oh perfect! Could someone confirm its fully fixed on 4.4dev and then close the issue please, I tried but I couldn't get the web export template to run on 4.4dev, I might be able to check again later.