From 4c31cfaf4819fa71e3e8942f0131b9c46d0e794f Mon Sep 17 00:00:00 2001 From: MitchellHansen Date: Mon, 3 Oct 2016 00:13:45 -0700 Subject: [PATCH] remove some debug to make it clearer where I left off --- kernels/ray_caster_kernel.cl | 12 +++++++----- src/main.cpp | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/kernels/ray_caster_kernel.cl b/kernels/ray_caster_kernel.cl index aa33ac4..1a4e8c6 100644 --- a/kernels/ray_caster_kernel.cl +++ b/kernels/ray_caster_kernel.cl @@ -27,7 +27,7 @@ float4 cast_light_rays(float3 eye_direction, float3 ray_origin, float4 voxel_col for (int i = 0; i < *light_count; i++) { float3 light_direction = (lights[10 * i + 7], lights[10 * i + 8], lights[10 * i + 9]); - float c = 1.5; + float c = 1.0; if (dot(light_direction, voxel_normal) > 0.0) { float3 halfwayVector = normalize(light_direction + eye_direction); @@ -37,9 +37,11 @@ float4 cast_light_rays(float3 eye_direction, float3 ray_origin, float4 voxel_col } } - /*if (get_global_id(0) == 0) - printf("%f", intensity);*/ - return voxel_color * (intensity) + ambient_constant; + //if (get_global_id(0) == 0) + // printf("%i", *light_count); + voxel_color *= intensity; + voxel_color.w += ambient_constant; + return voxel_color; // for every light // @@ -174,7 +176,7 @@ __kernel void min_kern( float3 vox = convert_float3(voxel); - float3 norm = normalize(convert_float3(mask)); + float3 norm = normalize(fabs(convert_float3(mask))); float4 color = (float4)(0.25, 0.00, 0.25, 1.00); diff --git a/src/main.cpp b/src/main.cpp index a05db0a..f1380bd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -142,13 +142,15 @@ int main() { c.create_buffer("cam_dir_buffer", sizeof(float) * 4, (void*)camera.get_direction_pointer(), CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR); c.create_buffer("cam_pos_buffer", sizeof(float) * 4, (void*)camera.get_position_pointer(), CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR); + int light_count = 2; + c.create_buffer("light_count_buffer", sizeof(int), &light_count); + // {r, g, b, i, x, y, z, x', y', z'} sf::Vector3f v = Normalize(sf::Vector3f(1.0, 1.0, 0.0)); - float light[] = { 0.4, 0.8, 0.1, 1, 50, 50, 50, v.x, v.y, v.z}; - c.create_buffer("light_buffer", sizeof(float) * 10, light, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR); - - int light_count = 1; - c.create_buffer("light_count_buffer", sizeof(int), &light_count); + sf::Vector3f v2 = Normalize(sf::Vector3f(1.1, 0.4, 0.7)); + float light[] = { 0.4, 0.8, 0.1, 1, 50, 50, 50, v.x, v.y, v.z, + 0.4, 0.8, 0.1, 1, 50, 50, 50, v2.x, v2.y, v2.z}; + c.create_buffer("light_buffer", sizeof(float) * 10 * light_count, light, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR); // The drawing canvas unsigned char* pixel_array = new sf::Uint8[WINDOW_X * WINDOW_Y * 4];