godotengine / godot

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

GLES2 - shadows does not work #37975

Open avril-gh opened 4 years ago

avril-gh commented 4 years ago

Godot Engine v3.2.2.beta.custom_build.4e70279b5 Android 4.4 GPU VideoCore IV HW

GLES: Broadcom, VideoCore IV HW, OpenGL ES 2.0
GL_EXT_debug_marker GL_OES_compressed_ETC1_RGB8_texture GL_OES_compressed_paletted_texture GL_OES_texture_npot GL_OES_depth24 GL_OES_vertex_half_float GL_OES_EGL_image GL_OES_EGL_image_external GL_EXT_discard_framebuffer GL_OES_rgb8_rgba8 GL_OES_depth32 GL_OES_packed_depth_stencil GL_EXT_texture_format_BGRA8888 GL_APPLE_rgb_422
EGL:
EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_vg_parent_image EGL_KHR_lock_surface EGL_ANDROID_image_native_buffer EGL_ANDROID_swap_rectangle EGL_ANDROID_image_native_buffer

On device log gives

**ERROR**: Directional shadow framebuffer status invalid
   At: drivers\gles2\rasterizer_scene_gles2.cpp:4026:initialize() - Directional shadow framebuffer status invalid

Issue description: When lights have no shadows enabled, then scene is rendered ok. When lights shadows are enabled then everything turns very dark.

Steps to reproduce: Use example project attached, turn shadow option in light node's on and off

Minimal reproduction project: VideoCore-1.zip

volzhs commented 4 years ago

tested on Galaxy S8+ / Android 9

Screenshot_20200418-071336_vc1 Screenshot_20200418-071343_vc1

avril-gh commented 4 years ago

@volzhs , thank's for testing ❤️ yes, i can confirm too, it does work on mali GPU's, ... but does not work on VideoCore IV HW

When light's shadows are disabled then on VideoCore IV HW GPU , it looks like on @volzhs top image. But when shadows are enabled then it looks like top image but very dark (almost same color as background).

clayjohn commented 4 years ago

With such an old low-end GPU, it may also just not fully support the GL ES 2.0 spec. I wouldn't be surprised.

We can test if its a hardware specific issue by forcing the rgba_3d_shadows branch by setting this false: https://github.com/godotengine/godot/blob/50582446ad13a7ce034bdd8695409bf26c1abac3/drivers/gles2/rasterizer_storage_gles2.cpp#L5931

If you change that to false, and it still works fine on newer hardware, then the issue is likely with the hardware. If you change it to false, and you get similar errors on newer hardware, then the issue is with Godot itself.

avril-gh commented 4 years ago

@clayjohn if you meant this config.use_rgba_3d_shadows = false; // !config.support_depth_texture; then it have no effect on VideoCore, still same error and dark scene when shadow used.

Then changing it to true gives same error and dark scene on VideoCore, but also same dark scene and error on other devices that worked fine before.

( _Also tried on PowerVR device, and there are no problem with shadows, but i could'nt get anything just all 0.0's from DEPTHTEXTURE, but that's for another issue. )

clayjohn commented 4 years ago

@avril-gh The use_rgba_3d_shadows is there for devices like yours that do not support depth textures, so of course setting it to use depth texture on that device will fail.

I mae a mistake in my above post, I meant for you to set use_rgba_3d_shadows to true and test on the VideoCore device and on a newer device. You did it anyway despite my unclear instructions, so, thank you.

The fact that setting use_rgba_3d_shadows creates the error on other devices means that it is likely a problem with use_rgba_3d_shadows which you VideoCore device is forced to use because it doesn't support depth textures.

I will look into it and see what I can do.

avril-gh commented 4 years ago

I will look into it and see what I can do.

@clayjohn , thanks, awesome

clayjohn commented 4 years ago

I think I found a fix. This line should be storage->config.depth_buffer_internalformat because it is a buffer and not an image. We did a big cleanup in #33844 for this before the 3.2 release and I guess we missed this one. https://github.com/godotengine/godot/blob/2a10e301195abf1ad4894cf54aab71a9b6e1a734/drivers/gles2/rasterizer_scene_gles2.cpp#L135

Im doing a full rebuild so I can test this change. Ill have to check the results in the morning as it is getting late here.

avril-gh commented 4 years ago

awesome work! there's a big progress. The storage->config.depth_buffer_internalformat nicely fixes SpotLight and OmniLight shadow's ,

spotlight shadow on VideoCore IV HW spotlight

omnilight shadow on VideoCore IV HW omnilight

However there's still something wrong with DirectionalLight shadow. When Directional Light's shadow is enabled the whole object is dark.

A small test that perhaps may give some clues in debugging (?)

directionallight

test project used - test-project.zip

clayjohn commented 4 years ago

@avril-gh Thanks for testing, I am having trouble running my android build, so it may take a bit before I can test as well.

When you run the scene with a DirectionalLight, do you still receive that same error message?

edit: Once I got it running on my android device, I can't reproduce the DirectionalLight issue.

avril-gh commented 4 years ago

@clayjohn

When you run the scene with a DirectionalLight, do you still receive that same error message?

yes, even when there are no DirectionalLight in the scene (i removed it) and there's only OmniLight, it looks normal, there is shadow, but the error persists anyway.

Godot Engine v3.2.2.beta.custom_build.cfc4526c1
Using GLES2 video driver
OpenGL ES 2.0 Renderer: VideoCore IV HW
**ERROR**: Directional shadow framebuffer status invalid
   At: drivers\gles2\rasterizer_scene_gles2.cpp:4026:initialize() - Directional shadow framebuffer status invalid