materials, brick and nodes structure, preparing for world generation

This commit is contained in:
Piotrek
2021-04-24 17:06:44 +02:00
parent 829ae1ddb6
commit 97ece7a823
13 changed files with 311 additions and 244 deletions
+19
View File
@@ -0,0 +1,19 @@
/*
point: Hit point
view: View vector (camera ray)
normal: Normal vector
*/
vec3 solve(vec3 hitPoint, vec3 view, vec3 normal, uint brick)
{
// Lighting
vec3 light_color = vec3(1.0, 1.0, 1.0);
vec3 light_dir = normalize(hitPoint-vec3(0.0, 1.5, 4.0));
vec3 ambient = light_color * 0.1;
vec3 diffuse = light_color * max(1.0-dot(normal, light_dir), 0.0);
vec3 specular = light_color * pow(max(dot(view, reflect(-light_dir, normal)), 0.0), 32);
// Combine colors
vec3 object_color = _Materials[brick].albedo.rgb;//vec3(0.0, 0.1, 0.5);
return (ambient + diffuse + specular) * object_color;
}