adds multilight handling
This commit is contained in:
parent
4c4b8288d5
commit
729fcb8559
4 changed files with 43 additions and 6 deletions
shaders
Binary file not shown.
|
@ -149,7 +149,8 @@ void main() {
|
|||
uint volume_pos_y = scene_info.infos[volume_index + 1];
|
||||
uint volume_pos_z = scene_info.infos[volume_index + 2];
|
||||
|
||||
uint light_index = scene_info.infos[volume_index + 6];
|
||||
// setup light info
|
||||
uint light_index = scene_info.infos[fragVolumeStart + 6 + light_num];
|
||||
vec3 light_direction = get_light_position(light_index) - origPosition;
|
||||
vec3 light_color = get_light_color(light_index);
|
||||
|
||||
|
@ -162,6 +163,7 @@ void main() {
|
|||
bool z_pos = light_direction.z > 0.0;
|
||||
bool z_null = (light_direction.z == 0.0);
|
||||
|
||||
// initialize color
|
||||
vec3 color_sum = vec3(0.0, 0.0, 0.0) + (orig_color_sample.xyz * 0.01);
|
||||
|
||||
uint max_iterations = max_light_num * 20;
|
||||
|
@ -188,7 +190,7 @@ void main() {
|
|||
|
||||
if ((x_factor >= 1.0) && (y_factor >= 1.0) && (z_factor >= 1.0)) {
|
||||
// no hit, add light color result
|
||||
color_sum += (orig_color_sample.xyz * light_color) / ((0.01 * light_direction.length() * light_direction.length()) + 1.0);
|
||||
color_sum += (orig_color_sample.xyz * light_color) / ((0.1 * light_direction.length() * light_direction.length()) + 1.0);
|
||||
needs_next_light = true;
|
||||
} else {
|
||||
// if there is a border hit before reaching the light
|
||||
|
@ -249,7 +251,32 @@ void main() {
|
|||
}
|
||||
}
|
||||
if (needs_next_light) {
|
||||
break;
|
||||
light_num += 1;
|
||||
if (light_num >= max_light_num) {
|
||||
break;
|
||||
}
|
||||
// set up the new light
|
||||
light_index = scene_info.infos[fragVolumeStart + 6 + light_num];
|
||||
if (light_index == 0) {
|
||||
// abort if there is no new light
|
||||
break;
|
||||
}
|
||||
light_direction = get_light_position(light_index) - origPosition;
|
||||
light_color = get_light_color(light_index);
|
||||
|
||||
x_pos = light_direction.x > 0.0;
|
||||
x_null = (light_direction.x == 0.0);
|
||||
|
||||
y_pos = light_direction.y > 0.0;
|
||||
y_null = (light_direction.y == 0.0);
|
||||
|
||||
z_pos = light_direction.z > 0.0;
|
||||
z_null = (light_direction.z == 0.0);
|
||||
// reset volume info
|
||||
volume_index = fragVolumeStart;
|
||||
volume_pos_x = scene_info.infos[volume_index + 0];
|
||||
volume_pos_y = scene_info.infos[volume_index + 1];
|
||||
volume_pos_z = scene_info.infos[volume_index + 2];
|
||||
}
|
||||
}
|
||||
outColor = vec4(color_sum, 1.0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue