godotengine / godot

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

3D Omni Lights cut in half after exporting to Web #95524

Open MerchantZoro opened 4 weeks ago

MerchantZoro commented 4 weeks ago

Tested versions

v4.2.2

System information

Windows 10

Issue description

The Omni Lights get cut in half and the directional light also acts weird, I’m assuming It's because the browser renderer is different. How can I fix this?

Steps to reproduce

In editor, lights work fine, export to web, and lights are weird

Minimal reproduction project (MRP)

Captura de ecrã 2024-08-13 112956

AThousandShips commented 4 weeks ago

Please upload an MRP to make this easier to test:

MerchantZoro commented 4 weeks ago

When I create a new project with just an omni light and a camera, it works fine when exporting to web But on my main game it doesn't, can I just send you my whole project?

AThousandShips commented 4 weeks ago

Please strip down your project by removing parts until it is the smallest that replicates the bug, don't upload a full game project

MerchantZoro commented 4 weeks ago

Ok here it is, its a large file still so I had to zip it into google drive Like I said, in the editor it will look fine but when you export to web the lights get all messed up Thank you brother https://drive.google.com/file/d/11Tx5OgvvEzqrotooduk71FKKfzGk6Emz/view?usp=sharing

AThousandShips commented 4 weeks ago

That's not a minimal project, please reduce the size

Also please don't call me a "brother", I'm a woman :)

MerchantZoro commented 4 weeks ago

I have reduced the size a lot already, only the enemy with the messed lights spawns Like I said before, if I create a new project the lights work fine so its something in the original project that I don't know

Please check the project out, I'm desperate to find a solution xD

AThousandShips commented 4 weeks ago

That project isn't minimal, please remove more until only the issue remains, over 700 mb is far too big, you can remove unnecessary assets and such

I would test this if the project was of a reasonable size, but a complete working project isn't appropriate as an MRP, it would be far too much work to try to identify the problem from that

Calinou commented 4 weeks ago

Please switch to the Compatibility rendering method in the top-right corner of the editor, so you can preview your project as it'll look like in the web export (nonwithstanding web-specific bugs).

You are likely hitting a light count limit (only a certain number of positional lights may light up each mesh resource). To avoid this, use fewer lights or split your MeshInstance3D nodes into smaller meshes. You can also adjust the limits when using Compatibility as described in the link, but this should be done as a last resort as it'll impact performance on low-end devices (especially on mobile).

MerchantZoro commented 4 weeks ago

I am in compatibility renderer and with only 1 light the problem persists

I am currently trying to size down the project but I can only get it to 700 Mbs, idk if you guys ok with that It can't be much lower otherwise the problem won't exist

MerchantZoro commented 3 weeks ago

I am in compatibility mode and its still different from editor to export

Even with just 1 light the problem still remains the same Please help

AThousandShips commented 3 weeks ago

We will help if you provide something that's reasonable to test with, a single scene with just the content necessary to reproduce the bug, unless you have a single scene that takes over 700 megabytes that's not what the files you linked are (unless you forgot the instruction to not include the .godot folder, that could take a lot of space)

MerchantZoro commented 3 weeks ago

For that I would need to change the code of the game a lot, I have a lot of scripts interacting with each other and if I delete too many scenes the game stops working entirely Already got some errors by just sizing down a bit I believe if you open the project you won't have a hard time navigating it tho, the "demon_skull" entity has the light problem

AThousandShips commented 3 weeks ago

It's much easier if you recreate the issue yourself and make an easy to access MRP

The MRP isn't about proving that the bug is there, but figuring out what is causing it, a project that is that large and complicated is very difficult to break down and identify, so please make a project that allows us to do that so that we can solve this bug

MerchantZoro commented 3 weeks ago

I have done that before, when I create a new project the problem is not there, something in the main project is wrong

AThousandShips commented 3 weeks ago

That's the reason you need to find what makes it happen and make a project with that, by either working backwards removing parts that aren't relevant, or by building up from nothing to find specifics

But since it won't happen in a new project it must be more specific, and it's a lot of work to pick out what actually causes that, that's why we're asking you to try to do that to help the process

So if you upload a minimal project we can continue investigating this

ethanp4 commented 3 weeks ago

I'm getting a similar issue in editor and in a Linux export. v4.3 on Linux mint I'm not sure when the issue began, I only noticed once I added textures while following this tutorial heres a very small project with the issue minecraft-3.0.zip

Going backwards in versions the issue persisted in 4.2.2 but not 4.1.4

Edit: Fixed this by using SurfaceTool.generate_normals()

MerchantZoro commented 3 weeks ago

Where did you use SurfaceTool.generate_normals()

ethanp4 commented 3 weeks ago

I used it before setting the mesh of my mesh_instance since I'm creating the meshes entirely using SurfaceTool but it seems like you can use an existing mesh with SurfaceTool.create_from

this is where im using it

surface_tool.begin(Mesh.PrimitiveType.PRIMITIVE_TRIANGLES)
for x in range(DIMENSIONS.x):
    for y in range(DIMENSIONS.y):
        for z in range(DIMENSIONS.z):
            create_block_mesh(Vector3i(x,y,z))

surface_tool.generate_normals()
surface_tool.set_material(block_manager.chunk_material)
var mesh : ArrayMesh = surface_tool.commit()

mesh_instance.mesh = mesh
collision_shape.shape = mesh.create_trimesh_shape()