sampling in random hemisphere

This commit is contained in:
Piotrek
2021-04-25 13:50:39 +02:00
parent 8585f21c70
commit 9718ea68dd
7 changed files with 57 additions and 25 deletions
+11 -4
View File
@@ -1,18 +1,25 @@
/*
* Returns material albedo for given voxel
*/
vec3 getAlbedo(uint data)
{
return _Materials[data-1].albedo.rgb;
}
/*
point: Hit point
view: View vector (camera ray)
normal: Normal vector
*/
vec3 applyLighting(vec3 hitPoint, vec3 view, vec3 normal, uint brick)
vec3 applyLighting(vec3 hitPoint, vec3 view, vec3 normal, uint data)
{
// Lighting
vec3 light_color = vec3(1.0, 1.0, 1.0);
vec3 light_color = vec3(1);
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;
return (ambient + diffuse + specular) * getAlbedo(data);
}