18 lines
579 B
HLSL
18 lines
579 B
HLSL
/*
|
|
point: Hit point
|
|
view: View vector (camera ray)
|
|
normal: Normal vector
|
|
*/
|
|
vec3 applyLighting(vec3 hitPoint, vec3 view, vec3 normal, uint brick)
|
|
{
|
|
// Lighting
|
|
vec3 light_color = vec3(1.0, 1.0, 1.0);
|
|
|
|
vec3 ambient = light_color * 0.1;
|
|
vec3 diffuse = light_color * max(1.0-dot(normal, _SunDir), 0.0);
|
|
vec3 specular = light_color * pow(max(dot(view, reflect(-_SunDir, normal)), 0.0), 32);
|
|
|
|
// Combine colors
|
|
vec3 object_color = _Materials[brick-1].albedo.rgb;//vec3(0.0, 0.1, 0.5);
|
|
return (ambient + diffuse + specular) * object_color;
|
|
} |