improved the shader of mesh renderer to make the global lighting better

This commit is contained in:
2026-08-09 18:04:46 -04:00
parent e14931b27b
commit ee20c903b2
2 changed files with 8 additions and 3 deletions
Binary file not shown.
+8 -3
View File
@@ -11,11 +11,13 @@ float4 main(Input input) : SV_Target0
{ {
float3 normal = normalize(input.WorldNormal); float3 normal = normalize(input.WorldNormal);
// Initial ambient component // Initial ambient component (Soft blue sky ambient)
float3 result = input.Color.rgb * GlobalLightColor * GlobalAmbientIntensity; float3 ambientColor = float3(0.6f, 0.7f, 0.9f);
float3 result = input.Color.rgb * ambientColor * GlobalAmbientIntensity;
// Directional light contribution // Directional light contribution
float ndotl = max(dot(normal, -GlobalLightDirection), 0.0); float3 sunDir = normalize(-GlobalLightDirection);
float ndotl = max(dot(normal, sunDir), 0.0);
result += input.Color.rgb * GlobalLightColor * ndotl; result += input.Color.rgb * GlobalLightColor * ndotl;
// Point lights // Point lights
@@ -42,5 +44,8 @@ float4 main(Input input) : SV_Target0
} }
} }
// Simple Gamma correction
result = pow(result, 1.0 / 2.2);
return float4(result, input.Color.a); return float4(result, input.Color.a);
} }