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

workbench_world_light_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: 6507f1ec70783eaf54f4eb0d0179b419c42052cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
vec3 get_world_diffuse_light(WorldData world_data, vec3 N)
{
	vec4 result = world_data.diffuse_light_x_pos * clamp(N.x, 0.0, 1.0);
	result = mix(result, world_data.diffuse_light_x_neg, clamp(-N.x, 0.0, 1.0));
	result = mix(result, world_data.diffuse_light_y_pos, clamp(-N.y, 0.0, 1.0));
	result = mix(result, world_data.diffuse_light_y_neg, clamp(N.y, 0.0, 1.0));
	result = mix(result, world_data.diffuse_light_z_pos, clamp(N.z, 0.0, 1.0));
	return mix(result, world_data.diffuse_light_z_neg, clamp(-N.z, 0.0, 1.0)).xyz;
}

vec3 get_camera_diffuse_light(WorldData world_data, vec3 N)
{
	vec4 result = world_data.diffuse_light_x_pos * clamp(N.x, 0.0, 1.0);
	result = mix(result, world_data.diffuse_light_x_neg, clamp(-N.x, 0.0, 1.0));
	result = mix(result, world_data.diffuse_light_z_pos, clamp( N.y, 0.0, 1.0));
	result = mix(result, world_data.diffuse_light_z_neg, clamp(-N.y, 0.0, 1.0));
	result = mix(result, world_data.diffuse_light_y_pos, clamp( N.z, 0.0, 1.0));
	result = mix(result, world_data.diffuse_light_y_neg, clamp(-N.z, 0.0, 1.0));
	return result.xyz;
}