space-game001/shaders/defaultColor_desktop.fragment
2025-12-13 15:02:03 +03:00

22 lines
740 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

varying vec3 color; // Цвет вершины (с шумом)
varying vec3 normal;
varying vec3 lightDirection_VS;
varying vec2 TexCoord; // UV-координаты
uniform sampler2D Texture;
uniform vec3 uLightDirection;
void main()
{
// 1. Получаем цвет из текстуры и смешиваем с цветовым шумом
vec4 textureColor = texture2D(Texture, TexCoord);
vec3 finalColor = textureColor.rgb * color;
// 3. Расчет освещения
float diffuse = max(0.0, dot(normal, uLightDirection));
float ambient = 0.2;
float lightingFactor = min(1.0, ambient + diffuse);
gl_FragColor = vec4(finalColor * lightingFactor, 1.0);
}