Welcome to mirror list, hosted at ThFree Co, Russian Federation.

workbench_diffuse_lib.glsl « shaders « workbench « engines « draw « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 22a55a386f7c1394e8e341517916dc47152f8d59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
float normalized_dot(vec3 v1, vec3 v2)
{
	return max(0.0, dot(v1, v2));
}

float lambert_diffuse(vec3 light_direction, vec3 surface_normal)
{
	return normalized_dot(light_direction, surface_normal);
}

vec3 get_world_diffuse_light(vec3 N, vec3 xp, vec3 xn, vec3 yp, vec3 yn, vec3 zp, vec3 zn)
{
	vec3 result = vec3(0.0, 0.0, 0.0);
	result = mix(result, xp, normalized_dot(vec3( 1.0,  0.0,  0.0), N));
	result = mix(result, xn, normalized_dot(vec3(-1.0,  0.0,  0.0), N));
	result = mix(result, yp, normalized_dot(vec3( 0.0,  1.0,  0.0), N));
	result = mix(result, yn, normalized_dot(vec3( 0.0, -1.0,  0.0), N));
	result = mix(result, zp, normalized_dot(vec3( 0.0,  0.0,  1.0), N));
	result = mix(result, zn, normalized_dot(vec3( 0.0,  0.0, -1.0), N));
	return result;
}