Added new demo, tweaked some values to produce better lighting

master
MitchellHansen 8 years ago
parent 0d82cd5a20
commit 5e222a0331

@ -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:

@ -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();
}

@ -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;
}

@ -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"
@ -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();

@ -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;
@ -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;

Loading…
Cancel
Save