From c761eea77a7516d3350616676f34d4bdbe4ad180 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 16 Jun 2020 20:11:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=85=89=E7=85=A7=E8=AE=A1?= =?UTF-8?q?=E7=AE=97bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shader/LightPosition3D.vert | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/shader/LightPosition3D.vert b/shader/LightPosition3D.vert index c5c62f2..d6908c2 100644 --- a/shader/LightPosition3D.vert +++ b/shader/LightPosition3D.vert @@ -28,7 +28,7 @@ layout(push_constant) uniform Consts { layout(binding=1) uniform ColorMaterial { vec4 color; - vec4 amibent; + vec4 ambient; } color_material; layout(binding=2) uniform Sun @@ -38,14 +38,16 @@ layout(binding=2) uniform Sun layout(location=0) out vec4 FragmentColor; -float GetSunlightIntensity() +vec4 ComputeSunlightFinalColor(vec4 color,vec4 ambient) { - return max(dot(normalize(Normal*mat3(world.mvp)),sun.direction),0.0); + float intensity=max(dot(normalize(Normal*mat3(world.mvp)),sun.direction),0.0); + + return max(color*intensity,ambient); } void main() { - FragmentColor=color_material.color*GetSunlightIntensity()+color_material.amibent; + FragmentColor=ComputeSunlightFinalColor(color_material.color,color_material.ambient); gl_Position=vec4(Vertex,1.0)*(pc.local_to_world*world.mvp); }