Small tweaks while debugging. Will get 1:1 traversal working 100% before tackling jump_power
This commit is contained in:
@@ -74,8 +74,7 @@ float4 view_light(float4 in_color, float3 light, float4 light_color, float3 view
|
|||||||
float diffuse = max(dot(normalize(convert_float3(mask)), normalize(light)), 0.1f);
|
float diffuse = max(dot(normalize(convert_float3(mask)), normalize(light)), 0.1f);
|
||||||
float specular = 0.0f;
|
float specular = 0.0f;
|
||||||
|
|
||||||
if (diffuse > 0.0f)
|
if (diffuse > 0.0f) {
|
||||||
{
|
|
||||||
// Small dots of light are caused by floating point error
|
// Small dots of light are caused by floating point error
|
||||||
// flipping bits on the face mask and screwing up this calculation
|
// flipping bits on the face mask and screwing up this calculation
|
||||||
float3 halfwayVector = normalize(normalize(light) + normalize(view));
|
float3 halfwayVector = normalize(normalize(light) + normalize(view));
|
||||||
@@ -84,12 +83,6 @@ float4 view_light(float4 in_color, float3 light, float4 light_color, float3 view
|
|||||||
}
|
}
|
||||||
|
|
||||||
in_color += diffuse * light_color + specular * light_color / d;
|
in_color += diffuse * light_color + specular * light_color / d;
|
||||||
|
|
||||||
//in_color = pow(in_color, (float4)(1.0/2.2));
|
|
||||||
// This creates that blown out color look
|
|
||||||
//in_color.xyz += in_color.w * 0.002f;
|
|
||||||
|
|
||||||
//in_color.w += 0.8f;
|
|
||||||
return in_color;
|
return in_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,7 +291,7 @@ __kernel void raycaster(
|
|||||||
// it over the axis like we want. So here, isless returns a boolean if intersection_t
|
// it over the axis like we want. So here, isless returns a boolean if intersection_t
|
||||||
// is less than 0 which dictates whether or not we subtract the delta which in effect
|
// is less than 0 which dictates whether or not we subtract the delta which in effect
|
||||||
// mirrors the offset
|
// mirrors the offset
|
||||||
intersection_t -= delta_t * convert_float3(isless(intersection_t, 0));
|
intersection_t += delta_t * convert_float3(isless(intersection_t, 0));
|
||||||
|
|
||||||
int distance_traveled = 0;
|
int distance_traveled = 0;
|
||||||
int max_distance = 700;
|
int max_distance = 700;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ bool Application::init_clcaster() {
|
|||||||
sf::Image bitmap = map->GenerateHeightBitmap(sf::Vector3i(MAP_X, MAP_Y, MAP_Z));
|
sf::Image bitmap = map->GenerateHeightBitmap(sf::Vector3i(MAP_X, MAP_Y, MAP_Z));
|
||||||
map->ApplyHeightmap(bitmap);
|
map->ApplyHeightmap(bitmap);
|
||||||
|
|
||||||
map->octree.CastRayOctree(sf::Vector2f(1.5f, -2.0f), sf::Vector3f(5.0f, 5.0f, 5.0f));
|
map->octree.CastRayOctree(sf::Vector2f(1.5f, -2.0f), sf::Vector3f(5.1f, 5.1f, 5.1f));
|
||||||
|
|
||||||
raycaster->assign_octree(map);
|
raycaster->assign_octree(map);
|
||||||
raycaster->assign_map(map);
|
raycaster->assign_map(map);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ ArrayMap::ArrayMap(sf::Vector3i dimensions) {
|
|||||||
|
|
||||||
voxel_data = new char[dimensions.x * dimensions.y * dimensions.z];
|
voxel_data = new char[dimensions.x * dimensions.y * dimensions.z];
|
||||||
for (int i = 0; i < dimensions.x * dimensions.y * dimensions.z; i++) {
|
for (int i = 0; i < dimensions.x * dimensions.y * dimensions.z; i++) {
|
||||||
|
voxel_data[i] = 0;
|
||||||
voxel_data[i] = 1;
|
voxel_data[i] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -358,7 +358,7 @@ std::vector<std::tuple<sf::Vector3i, char>> Octree::CastRayOctree(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
// Setup the voxel coords from the camera origin
|
// Setup the voxel coords from the camera origin
|
||||||
sf::Vector3i voxel(0, 0, 0);
|
sf::Vector3i voxel(cam_pos);
|
||||||
|
|
||||||
// THIS DOES NOT HAVE TO RETURN TRUE ON FOUND
|
// THIS DOES NOT HAVE TO RETURN TRUE ON FOUND
|
||||||
// This function when passed an "air" voxel will return as far down
|
// This function when passed an "air" voxel will return as far down
|
||||||
@@ -417,10 +417,11 @@ std::vector<std::tuple<sf::Vector3i, char>> Octree::CastRayOctree(
|
|||||||
// for all 3 axis XYZ. We take the full positive cardinality when
|
// for all 3 axis XYZ. We take the full positive cardinality when
|
||||||
// subtracting the floor, so we must transfer the sign over from
|
// subtracting the floor, so we must transfer the sign over from
|
||||||
// the voxel step
|
// the voxel step
|
||||||
|
|
||||||
sf::Vector3f intersection_t(
|
sf::Vector3f intersection_t(
|
||||||
delta_t.x * (cam_pos.y - floor(cam_pos.x)) * voxel_step.x,
|
delta_t.x * (cam_pos.y - ceil(cam_pos.x)) * voxel_step.x,
|
||||||
delta_t.y * (cam_pos.x - floor(cam_pos.y)) * voxel_step.y,
|
delta_t.y * (cam_pos.x - ceil(cam_pos.y)) * voxel_step.y,
|
||||||
delta_t.z * (cam_pos.z - floor(cam_pos.z)) * voxel_step.z
|
delta_t.z * (cam_pos.z - ceil(cam_pos.z)) * voxel_step.z
|
||||||
);
|
);
|
||||||
|
|
||||||
// When we transfer the sign over, we get the correct direction of
|
// When we transfer the sign over, we get the correct direction of
|
||||||
@@ -475,7 +476,11 @@ std::vector<std::tuple<sf::Vector3i, char>> Octree::CastRayOctree(
|
|||||||
int mask_index = traversal_state.idx_stack[traversal_state.scale];
|
int mask_index = traversal_state.idx_stack[traversal_state.scale];
|
||||||
|
|
||||||
// Whether or not the next oct we want to enter in the current CD's valid mask is 1 or 0
|
// Whether or not the next oct we want to enter in the current CD's valid mask is 1 or 0
|
||||||
bool is_valid = (traversal_state.parent_stack[traversal_state.parent_stack_position] >> 16) & mask_8[mask_index];
|
bool is_valid = false;
|
||||||
|
|
||||||
|
// TODO: Rework this logic so we don't have this bodgy if
|
||||||
|
if (mask_index > prev_val)
|
||||||
|
is_valid = (traversal_state.parent_stack[traversal_state.parent_stack_position] >> 16) & mask_8[mask_index];
|
||||||
|
|
||||||
// Check to see if the idx increased or decreased
|
// Check to see if the idx increased or decreased
|
||||||
// If it decreased
|
// If it decreased
|
||||||
@@ -486,8 +491,8 @@ std::vector<std::tuple<sf::Vector3i, char>> Octree::CastRayOctree(
|
|||||||
|
|
||||||
// Keep track of the 0th edge of out current oct
|
// Keep track of the 0th edge of out current oct
|
||||||
traversal_state.oct_pos.x = floor(voxel.x / 2) * jump_power;
|
traversal_state.oct_pos.x = floor(voxel.x / 2) * jump_power;
|
||||||
traversal_state.oct_pos.y = floor(voxel.x / 2) * jump_power;
|
traversal_state.oct_pos.y = floor(voxel.y / 2) * jump_power;
|
||||||
traversal_state.oct_pos.z = floor(voxel.x / 2) * jump_power;
|
traversal_state.oct_pos.z = floor(voxel.z / 2) * jump_power;
|
||||||
|
|
||||||
// Clear and pop the idx stack
|
// Clear and pop the idx stack
|
||||||
traversal_state.idx_stack[traversal_state.scale] = 0;
|
traversal_state.idx_stack[traversal_state.scale] = 0;
|
||||||
@@ -590,12 +595,12 @@ std::vector<std::tuple<sf::Vector3i, char>> Octree::CastRayOctree(
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (voxel.x >= map_dim->x || voxel.y >= map_dim->y || voxel.z >= map_dim->z) {
|
//if (voxel.x >= map_dim->x || voxel.y >= map_dim->y || voxel.z >= map_dim->z) {
|
||||||
return travel_path;
|
// return travel_path;
|
||||||
}
|
//}
|
||||||
if (voxel.x < 0 || voxel.y < 0 || voxel.z < 0) {
|
//if (voxel.x < 0 || voxel.y < 0 || voxel.z < 0) {
|
||||||
return travel_path;
|
// return travel_path;
|
||||||
}
|
//}
|
||||||
|
|
||||||
// If we hit a voxel
|
// If we hit a voxel
|
||||||
//voxel_data = map[voxel.x + (*map_dim).x * (voxel.y + (*map_dim).z * (voxel.z))];
|
//voxel_data = map[voxel.x + (*map_dim).x * (voxel.y + (*map_dim).z * (voxel.z))];
|
||||||
|
|||||||
Reference in New Issue
Block a user