Slightly closer, for some reason the face mask has been -1 and 0 this whole time????

master
mitchellhansen 7 years ago
parent 86bcd4f0ae
commit 6650eb784d

@ -327,7 +327,7 @@ __kernel void raycaster(
int jump_power = (int)log2((float)vox_dim) - traversal_state.scale;
int prev_jump_power = jump_power;
int3 last_oct_pos = (0);
// TODO: DEBUG
int failsafe = 0;
@ -335,7 +335,6 @@ __kernel void raycaster(
// Andrew Woo's raycasting algo
while (distance_traveled < max_distance && bounce_count < 2) {
// If we hit a voxel
if (setting(OCTENABLED) == 0 && voxel.x < (*map_dim).x/2 && voxel.y < (*map_dim).x/2 && voxel.z < (*map_dim).x/2){
//if (setting(OCTENABLED) == 0 && voxel.x < (*map_dim).x && voxel.y < (*map_dim).x && voxel.z < (*map_dim).x){
@ -353,18 +352,9 @@ __kernel void raycaster(
//
// Fancy no branch version of the logic step
face_mask = intersection_t.xyz <= min(intersection_t.yzx, intersection_t.zxy);
intersection_t +=
delta_t * jump_power * fabs(convert_float3(face_mask.xyz));
int3 other_faces = face_mask.xyz ? 0 : 1;
intersection_t +=
delta_t * jump_power * fabs(convert_float3(other_faces.xyz))
- delta_t * prev_jump_power * fabs(convert_float3(other_faces.xyz));
face_mask = 1 + (intersection_t.xyz <= min(intersection_t.yzx, intersection_t.zxy));
prev_jump_power = jump_power;
voxel.xyz += voxel_step.xyz * jump_power * face_mask.xyz;
@ -376,6 +366,8 @@ __kernel void raycaster(
break;
}
uchar prev_val = traversal_state.idx_stack[traversal_state.scale];
uchar this_face_mask = 0;
// Check the voxel face that we traversed
@ -519,6 +511,18 @@ __kernel void raycaster(
break;
}
intersection_t += delta_t * jump_power * fabs(convert_float3(face_mask.xyz));
//int3 other_faces = face_mask == 1 ? 1 : -1;
int3 other_faces = select((int3)(1,1,1), (int3)(0,0,0), (int3)(face_mask == 1));
//int3 added_diff = last_oct_pos + prev_jump_power - traversal_state.oct_pos;
uint3 multiplier = abs(traversal_state.oct_pos - last_oct_pos) / prev_jump_power ;
last_oct_pos = traversal_state.oct_pos;
intersection_t -= delta_t * prev_jump_power * convert_float3(other_faces.xyz);
intersection_t += delta_t * convert_float3(multiplier) * jump_power * fabs(convert_float3(other_faces.xyz));
// // Test for out of bounds contions, add fog
// if (traversal_state.scale == 1){
// //voxel.xyz -= voxel_step.xyz * face_mask.xyz;

Loading…
Cancel
Save