Very very close to pixel perfect shadows. Having some of that axis switch malarchy slowing things down

This commit is contained in:
MitchellHansen
2017-01-18 22:06:33 -08:00
parent ad2d5052de
commit 73026bc65d
7 changed files with 95 additions and 83 deletions

View File

@@ -94,7 +94,7 @@ void Camera::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Even
vr::KeyHeld *held_event = static_cast<vr::KeyHeld*>(event.get());
if (held_event->code == sf::Keyboard::LShift) {
default_impulse = 0.2f;
default_impulse = 0.1f;
}
if (held_event->code == sf::Keyboard::RShift) {
default_impulse = 1.0f;

View File

@@ -197,6 +197,17 @@ void Hardware_Caster::draw(sf::RenderWindow* window) {
window->draw(viewport_sprite);
}
int Hardware_Caster::debug_quick_recompile()
{
int error = compile_kernel("../kernels/ray_caster_kernel.cl", true, "raycaster");
if (assert(error, "compile_kernel")) {
std::cin.get(); // hang the output window so we can read the error
return error;
}
validate();
}
void Hardware_Caster::test_edit_viewport(int width, int height, float v_fov, float h_fov)
{
sf::Vector2i view_res(width, height);
@@ -439,6 +450,7 @@ int Hardware_Caster::compile_kernel(std::string kernel_source, bool is_path, std
size_t kernel_source_size = strlen(source);
// Load the source into CL's data structure
cl_program program = clCreateProgramWithSource(
context, 1,
&source,
@@ -474,7 +486,9 @@ int Hardware_Caster::compile_kernel(std::string kernel_source, bool is_path, std
if (assert(error, "clCreateKernel"))
return OPENCL_ERROR;
kernel_map.emplace(std::make_pair(kernel_name, kernel));
// Do I want these to overlap when repeated??
kernel_map[kernel_name] = kernel;
//kernel_map.emplace(std::make_pair(kernel_name, kernel));
return 1;
}

View File

@@ -158,6 +158,18 @@ void Old_Map::generate_terrain() {
}
}
for (int x = 30; x < 60; x++) {
//for (int y = 0; y < dimensions.y; y++) {
for (int z = 0; z < 25; z++) {
voxel_data[x + dimensions.x * (50 + dimensions.z * z)] = 6;
}
//}
}
set_voxel(sf::Vector3i(45, 70, 5), 1);
set_voxel(sf::Vector3i(47, 70, 5), 1);
set_voxel(sf::Vector3i(100, 100, 50), 1);
}

View File

@@ -176,18 +176,22 @@ int main() {
input_handler.handle_held_keys();
input_handler.dispatch_events();
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Equal)) {
raycaster->test_edit_viewport(WINDOW_X, WINDOW_Y, w += 5, h += 5);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Dash)) {
raycaster->test_edit_viewport(WINDOW_X, WINDOW_Y, w -= 5, h -= 5);
if (sf::Keyboard::isKeyPressed(sf::Keyboard::F11)) {
while (raycaster->debug_quick_recompile() != 0);
}
//if (sf::Keyboard::isKeyPressed(sf::Keyboard::Equal)) {
// raycaster->test_edit_viewport(WINDOW_X, WINDOW_Y, w += 5, h += 5);
//}
//if (sf::Keyboard::isKeyPressed(sf::Keyboard::Dash)) {
// raycaster->test_edit_viewport(WINDOW_X, WINDOW_Y, w -= 5, h -= 5);
//}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::LAlt)) {
light_vec.at(0).position = camera->get_position();
light_vec.at(0).direction_cartesian = SphereToCart(camera->get_direction());
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::O)) {
light_vec.at(0).orbit_around_center(timer_accumulator += delta_time);
// light_vec.at(0).orbit_around_center(timer_accumulator += delta_time);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::M)) {