diff --git a/README.md b/README.md index 59d60b2..319f748 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ In order to build this project you must have Cmake, GLEW, SFML, and the OpenCL d Video demo: -[![Video demo](http://img.youtube.com/vi/DHcg2ZKend0/0.jpg)](http://www.youtube.com/watch?v=DHcg2ZKend0) +[![Video demo](http://img.youtube.com/vi/DHcg2ZKend0/0.jpg)](http://www.youtube.com/watch?v=JmD5ISHbKbU) Screenshots: diff --git a/include/util.hpp b/include/util.hpp index d5c1d9d..0892b9f 100644 --- a/include/util.hpp +++ b/include/util.hpp @@ -38,7 +38,7 @@ public: arr_pos++; ImGui::Begin("Performance"); - ImGui::PlotLines("FPS", fps_array, 200, 0, std::to_string(1.0 / fps_average).c_str(), 0.0f, 150.0f, ImVec2(0, 80)); + ImGui::PlotLines("FPS", fps_array, 200, 0, std::to_string(1.0 / fps_average).c_str(), 0.0f, 150.0f, ImVec2(200, 80)); ImGui::End(); } diff --git a/kernels/ray_caster_kernel.cl b/kernels/ray_caster_kernel.cl index 6f4ff58..30800c8 100644 --- a/kernels/ray_caster_kernel.cl +++ b/kernels/ray_caster_kernel.cl @@ -15,7 +15,7 @@ float4 white_light(float4 input, float3 light, int3 mask) { normalize(light), normalize(convert_float3(mask * (-mask))) ) - ) / 8; + ) / 32; return input; @@ -72,9 +72,9 @@ bool cast_light_intersection_ray( ){ float distance_to_light = DistanceBetweenPoints(ray_pos, (float3)(lights[4], lights[5], lights[6])); - if (distance_to_light > 200.0f){ - return false; - } + //if (distance_to_light > 200.0f){ + // return false; + //} // Setup the voxel step based on what direction the ray is pointing int3 voxel_step = { 1, 1, 1 }; @@ -219,7 +219,7 @@ __kernel void raycaster( int3 face_mask = { 0, 0, 0 }; float4 fog_color = { 0.73f, 0.81f, 0.89f, 0.8f }; - float4 voxel_color = (float4)(0.50f, 0.0f, 0.50f, 0.1f); + float4 voxel_color = (float4)(0.0f, 0.0f, 0.0f, 0.001f); float4 overshoot_color = { 0.25f, 0.48f, 0.52f, 0.8f }; float4 overshoot_color_2 = { 0.25f, 0.1f, 0.52f, 0.8f }; @@ -353,7 +353,7 @@ __kernel void raycaster( )) { // If the light ray intersected an object on the way to the light point - float4 ambient_color = white_light(voxel_color, (float3)(lights[4], lights[5], lights[6]), face_mask); + float4 ambient_color = white_light(voxel_color, (float3)(256.0f, 256.0f, 256.0f), face_mask); write_imagef(image, pixel, ambient_color); return; } diff --git a/src/main.cpp b/src/main.cpp index cc77ee6..115df99 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -35,7 +35,6 @@ #include "Camera.h" #include "Input.h" #include "Pub_Sub.h" -#include "NetworkInput.h" #include "LightController.h" #include "LightHandle.h" #include "imgui/imgui-SFML.h" @@ -105,7 +104,7 @@ int main() { window.setKeyRepeatEnabled(false); window.setFramerateLimit(60); window.setVerticalSyncEnabled(false); - + ImGui::SFML::Init(window); window.resetGLStates(); @@ -142,7 +141,7 @@ int main() { LightController light_controller(raycaster); LightPrototype prototype( - sf::Vector3f(100.0f, 100.0f, 30.0f), + sf::Vector3f(100.0f, 100.0f, 75.0f), sf::Vector3f(-1.0f, -1.0f, -1.5f), sf::Vector4f(0.2f, 0.9f, 0.0f, 1.0f) ); @@ -276,6 +275,13 @@ int main() { handle->set_position(light); } + light_pos[0] = sin(elapsed_time) * 100.0f + 300.0f; + light_pos[1] = sin(elapsed_time) * 100.0f + 300.0f; + + sf::Vector3f light(light_pos[0], light_pos[1], light_pos[2]); + handle->set_position(light); + + ImGui::End(); diff --git a/src/raycaster/Hardware_Caster.cpp b/src/raycaster/Hardware_Caster.cpp index ef23bce..81e997e 100644 --- a/src/raycaster/Hardware_Caster.cpp +++ b/src/raycaster/Hardware_Caster.cpp @@ -292,7 +292,7 @@ int Hardware_Caster::acquire_platform_and_device() { // Check to see if we even have OpenCL on this machine if (deviceIdCount == 0) { - std::cout << "There appears to be no platforms supporting OpenCL" << std::endl; + std::cout << "There appears to be no devices, or none at least supporting OpenCL" << std::endl; return OPENCL_NOT_SUPPORTED; } @@ -372,6 +372,10 @@ int Hardware_Caster::acquire_platform_and_device() { // Upon success of a condition, set the current best device values + //if (strcmp(device.version, "OpenCL 1.2 ") == 0 && strcmp(device.version, current_best_device.version) != 0) { + // current_best_device = device; + //} + // If the current device is not a GPU and we are comparing it to a GPU if (device.type == CL_DEVICE_TYPE_GPU && current_best_device.type != CL_DEVICE_TYPE_GPU) { current_best_device = device; @@ -399,7 +403,7 @@ int Hardware_Caster::acquire_platform_and_device() { } } - platform_id = current_best_device.platform; + platform_id = current_best_device.platform; device_id = current_best_device.id; std::cout << std::endl; @@ -453,6 +457,8 @@ int Hardware_Caster::create_shared_context() { #endif + + // Create our shared context context = clCreateContext( context_properties, @@ -518,7 +524,8 @@ int Hardware_Caster::compile_kernel(std::string kernel_source, bool is_path, std // Try and build the program - error = clBuildProgram(program, 1, &device_id, "-cl-finite-math-only -cl-fast-relaxed-math -cl-unsafe-math-optimizations", NULL, NULL); + // "-cl-finite-math-only -cl-fast-relaxed-math -cl-unsafe-math-optimizations" + error = clBuildProgram(program, 1, &device_id, NULL, NULL, NULL); // Check to see if it errored out if (vr_assert(error, "clBuildProgram")) { @@ -901,6 +908,12 @@ bool Hardware_Caster::vr_assert(int error_code, std::string function_name) { case CL_INVALID_DEVICE_PARTITION_COUNT: err_msg = "CL_INVALID_DEVICE_PARTITION_COUNT"; break; + case CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR : + err_msg = "CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR"; + break; + case CL_PLATFORM_NOT_FOUND_KHR : + err_msg = "CL_PLATFORM_NOT_FOUND_KHR"; + break; case RayCaster::SHARING_NOT_SUPPORTED: err_msg = "SHARING_NOT_SUPPORTED"; break;