godotengine / godot

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

OpenGL: Clearcoat has no effect if BaseMaterial3D roughness is exactly 0 #83223

Open Calinou opened 1 year ago

Calinou commented 1 year ago

Godot version

4.2.beta1

System information

Fedora 38, GeForce RTX 4090 (NVIDIA 535.104.05)

Issue description

When using the Compatibility rendering method, Clearcoat has no effect if BaseMaterial3D roughness is exactly 0:

Screenshot_20231013_012642 webp

However, it works if roughness is set to 0.01 or 1.0:

Roughness 0.01 Roughness 1.0
Screenshot_20231013_012628 webp Screenshot_20231013_012638 webp

This issue only occurs in Compatibility, not Forward+ or Mobile. I noticed it while working on a solution for https://github.com/godotengine/godot/issues/69327.

Steps to reproduce

Minimal reproduction project

Clearcoat_Test_2.zip

clayjohn commented 1 year ago

See: https://github.com/godotengine/godot/blob/51f81e1c88499f04d2ebdcc0be0b34e73f5e90eb/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl#L187