godotengine / godot

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

Material looks metallic and pretty smooth/shiny surface with GLES2 on Android #37673

Open volzhs opened 4 years ago

volzhs commented 4 years ago

Godot version: 3.2.2 df87601c88

OS/device including version: Linux mint 19.3 / Galaxy s8+

Issue description: Material looks metallic and pretty smooth with GLES2 on Android.

This is how it looks on desktop desktop

This is how it looks on Android phone it looks pretty metallic and smooth/shiny surface. too shiny on front side, and too dark bottom of the sphere.

image

Steps to reproduce:

  1. Download attached sample project
  2. run on PC and Android

Minimal reproduction project: mat_test.zip

clayjohn commented 4 years ago

I think this is connected to #34257

volzhs commented 4 years ago

after further testing, this issue happens with PanoramaSky or ProcedualSky. without it, it looks same with PC and mobile on GLES2.

here's another recording with PanoramaSky.

pc_new Linux mint 19.3

phone_new Galaxy S8+

image

clayjohn commented 4 years ago

I think what is happening is that the objects are not reading from the blurred mipmaps of the environment on Android. So it is as if they always have a roughness of 0. But even worse, we use the the radiance map to approximate diffuse irradiance, so it is read from twice at the lowest mip level, resulting in extreme shininess.

NeoSpark314 commented 3 years ago

I briefly investigated this issue some time ago here: https://github.com/godotengine/godot/issues/33633#issuecomment-554537340 and it looked like there is an error in the roughness mip map computation on android for the sky and mip-level 1 is black while all other mip levels (0, 2, 3, ...) look correct.

wombatwingdings commented 3 years ago

I have this problem too. Phone is Motorola G6 Play (GPU: Adreno 505).

clktmr commented 2 years ago

I did some investigation on this and basically @clayjohn assumption is correct. Because GL_EXT_shader_texture_lod is not supported on most Android devices (including Oculus Quest 2), both blurring and reading from radiance/reflection fails. My current workaround is to reduce sky/reflection contribution to ambient lighting.

Maybe it would be worthwhile to think about a possibility to bake reflection maps. This would also improve rendering of roughness, which currently only reduces intensity of the reflection. This would however add an additional one for each cube map to the scene shader, because we need a specific one for roughness and the most blurred one for ambient lighting.

wombatwingdings commented 2 years ago

Does anyone know if it's easy to force a roughness value of 1 everywhere instead of computing it and getting it wrong to get round this issue? Having shiny materials everywhere looks horrible. But I would think having rough materials would look OK for most games (including mine). I'm not suggesting committing this to the repo, but would be a useful workaround for those building from source. Thanks!

Calinou commented 2 years ago

Does anyone know if it's easy to force a roughness value of 1 everywhere instead of computing it and getting it wrong to get round this issue? Having shiny materials everywhere looks horrible. But I would think having rough materials would look OK for most games (including mine). I'm not suggesting committing this to the repo, but would be a useful workaround for those building from source. Thanks!

If you can recompile Android export templates, you can clone the 3.4-stable tag and make the following change in scene/resources/material.cpp:

diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 0af0378c83..51303b39a6 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -825,9 +825,9 @@ void SpatialMaterial::_update_shader() {
        } else {
            code += "\tfloat roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel);\n";
        }
-       code += "\tROUGHNESS = roughness_tex * roughness;\n";
+       code += "\tROUGHNESS = 1.0;\n";
    } else {
-       code += "\tROUGHNESS = roughness;\n";
+       code += "\tROUGHNESS = 1.0;\n";
    }

    code += "\tSPECULAR = specular;\n";

This will only affect SpatialMaterial, not custom shaders. You could edit drivers/gles3/scene.glsl and drivers/gles2/scene.glsl to affect custom shaders as well, but it's a bit more involved.

Acvarium commented 2 years ago

Updated my project for Oculus Quest to Godot 3.4 and than to 3.4.1. Secular glitch is showing up with directional light, if secular value for material is not 0

https://user-images.githubusercontent.com/463177/143664649-6cfe3ed2-8203-494d-9d80-26465298ff3c.mp4

Acvarium commented 2 years ago

Tested today with Godot 3.3.3. No sparkly issue there. That is only with 3.4 and 3.4.1 with GLES2 rendered

Calinou commented 2 years ago

Tested today with Godot 3.3.3. No sparkly issue there. That is only with 3.4 and 3.4.1 with GLES2 rendered

Please open a new issue with a minimal reproduction project attached.