picky about a few errors. Good thing though, I'm not really sure why clang + osx let me be that lax with memorymaster
parent
9c99f9edd0
commit
f487895f9f
@ -1,125 +1,125 @@
|
|||||||
// global : local : constant : private
|
// global : local : constant : private
|
||||||
|
|
||||||
// Function arguments of type image2d_t, image3d_t, image2d_array_t, image1d_t, image1d_buffer_t,
|
// Function arguments of type image2d_t, image3d_t, image2d_array_t, image1d_t, image1d_buffer_t,
|
||||||
// and image1d_array_t refer to image memory objects allocated in the **global** address space.
|
// and image1d_array_t refer to image memory objects allocated in the **global** address space.
|
||||||
|
|
||||||
// http://downloads.ti.com/mctools/esd/docs/opencl/memory/buffers.html
|
// http://downloads.ti.com/mctools/esd/docs/opencl/memory/buffers.html
|
||||||
|
|
||||||
// Open CL C
|
// Open CL C
|
||||||
// https://www.fixstars.com/en/opencl/book/OpenCLProgrammingBook/opencl-c/
|
// https://www.fixstars.com/en/opencl/book/OpenCLProgrammingBook/opencl-c/
|
||||||
|
|
||||||
__kernel void hello(
|
__kernel void hello(
|
||||||
global int2* resolution,
|
global int2* resolution,
|
||||||
global char* map,
|
global char* map,
|
||||||
global float3* projection_matrix,
|
global float3* projection_matrix,
|
||||||
global float3* cam_dir,
|
global float3* cam_dir,
|
||||||
global float3* cam_pos,
|
global float3* cam_pos,
|
||||||
global image2d_t* canvas) {
|
global image2d_t* canvas) {
|
||||||
|
|
||||||
printf("%s\n", "this is a test string\n");
|
printf("%s\n", "this is a test string\n");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const int MAX_RAY_STEPS = 64;
|
const int MAX_RAY_STEPS = 64;
|
||||||
|
|
||||||
// The pixel coord we are at
|
// The pixel coord we are at
|
||||||
int2 screenPos = (int2)(get_global_id(0) % resolution->x, get_global_id(0) / resolution->x);
|
int2 screenPos = (int2)(get_global_id(0) % resolution->x, get_global_id(0) / resolution->x);
|
||||||
|
|
||||||
// The X and Y planes
|
// The X and Y planes
|
||||||
//float3 cameraPlaneU = vec3(1.0, 0.0, 0.0)
|
//float3 cameraPlaneU = vec3(1.0, 0.0, 0.0)
|
||||||
|
|
||||||
// Y being multiplied by the aspect ratio, usually around .5-6ish;
|
// Y being multiplied by the aspect ratio, usually around .5-6ish;
|
||||||
//cl_float3 cameraPlaneV = vec3(0.0, 1.0, 0.0) * iResolution.y / iResolution.x;
|
//cl_float3 cameraPlaneV = vec3(0.0, 1.0, 0.0) * iResolution.y / iResolution.x;
|
||||||
|
|
||||||
// So this is how they do that ray aiming! hah this is so tiny
|
// So this is how they do that ray aiming! hah this is so tiny
|
||||||
// (camera direction) + (pixel.x * the X plane) + (product of pixel.y * Y plane)
|
// (camera direction) + (pixel.x * the X plane) + (product of pixel.y * Y plane)
|
||||||
// Oh all it's doing is adding the x and y coords of the pixel to the camera direction vector, interesting
|
// Oh all it's doing is adding the x and y coords of the pixel to the camera direction vector, interesting
|
||||||
|
|
||||||
//cl_float3 rayDir = cameraDir + screenPos.x * cameraPlaneU + screenPos.y * cameraPlaneV;
|
//cl_float3 rayDir = cameraDir + screenPos.x * cameraPlaneU + screenPos.y * cameraPlaneV;
|
||||||
|
|
||||||
// the origin of the ray
|
// the origin of the ray
|
||||||
// So the sign thing is for the up and down motion
|
// So the sign thing is for the up and down motion
|
||||||
|
|
||||||
//cl_float3 rayPos = vec3(0.0, 2.0 * sin(iGlobalTime * 2.7), -12.0);
|
//cl_float3 rayPos = vec3(0.0, 2.0 * sin(iGlobalTime * 2.7), -12.0);
|
||||||
|
|
||||||
// Ah, and here is where it spins around the center axis
|
// Ah, and here is where it spins around the center axis
|
||||||
// So it looks like its applying a function to rotate the x and z axis
|
// So it looks like its applying a function to rotate the x and z axis
|
||||||
//rayPos.xz = rotate2d(rayPos.xz, iGlobalTime);
|
//rayPos.xz = rotate2d(rayPos.xz, iGlobalTime);
|
||||||
//rayDir.xz = rotate2d(rayDir.xz, iGlobalTime);
|
//rayDir.xz = rotate2d(rayDir.xz, iGlobalTime);
|
||||||
|
|
||||||
// Just an intvec of out coords
|
// Just an intvec of out coords
|
||||||
//ivec3 mapPos = ivec3(floor(rayPos));
|
//ivec3 mapPos = ivec3(floor(rayPos));
|
||||||
|
|
||||||
// I think this is the delta t value
|
// I think this is the delta t value
|
||||||
// the magnitude of the vector divided by the rays direction. Not sure what the aim of that is
|
// the magnitude of the vector divided by the rays direction. Not sure what the aim of that is
|
||||||
// The ray direction might always be normalized, so that would be the dame as my delta_T
|
// The ray direction might always be normalized, so that would be the dame as my delta_T
|
||||||
//vec3 deltaDist = abs(vec3(length(rayDir)) / rayDir);
|
//vec3 deltaDist = abs(vec3(length(rayDir)) / rayDir);
|
||||||
|
|
||||||
// The steps are the signs of the ray direction
|
// The steps are the signs of the ray direction
|
||||||
//ivec3 rayStep = ivec3(sign(rayDir));
|
//ivec3 rayStep = ivec3(sign(rayDir));
|
||||||
|
|
||||||
// ithe sign of the rays direction
|
// ithe sign of the rays direction
|
||||||
// *
|
// *
|
||||||
// Convert map position to a floating point vector and take away the ray position
|
// Convert map position to a floating point vector and take away the ray position
|
||||||
// +
|
// +
|
||||||
// the sign of the rays direction by 0.5
|
// the sign of the rays direction by 0.5
|
||||||
// +
|
// +
|
||||||
// 0.5
|
// 0.5
|
||||||
// Now multyply everything by 0.5
|
// Now multyply everything by 0.5
|
||||||
//vec3 sideDist = (sign(rayDir) * (vec3(mapPos) - rayPos) + (sign(rayDir) * 0.5) + 0.5) * deltaDist;
|
//vec3 sideDist = (sign(rayDir) * (vec3(mapPos) - rayPos) + (sign(rayDir) * 0.5) + 0.5) * deltaDist;
|
||||||
|
|
||||||
// A byte mask
|
// A byte mask
|
||||||
//bvec3 mask;
|
//bvec3 mask;
|
||||||
|
|
||||||
// repeat until the max steps
|
// repeat until the max steps
|
||||||
//for (int i = 0; i < MAX_RAY_STEPS; i++) {
|
//for (int i = 0; i < MAX_RAY_STEPS; i++) {
|
||||||
|
|
||||||
// If there is a voxel at the map position, continue?
|
// If there is a voxel at the map position, continue?
|
||||||
//if (getVoxel(mapPos))
|
//if (getVoxel(mapPos))
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
//
|
//
|
||||||
// find which is smaller
|
// find which is smaller
|
||||||
// y ? z --> x`
|
// y ? z --> x`
|
||||||
// z ? x --> y`
|
// z ? x --> y`
|
||||||
// x ? y --> z`
|
// x ? y --> z`
|
||||||
//
|
//
|
||||||
// find which os is less or equal
|
// find which os is less or equal
|
||||||
// x` ? x --> x
|
// x` ? x --> x
|
||||||
// y` ? y --> y
|
// y` ? y --> y
|
||||||
// z` ? z --> z
|
// z` ? z --> z
|
||||||
|
|
||||||
// Now find which ons is
|
// Now find which ons is
|
||||||
//mask = lessThanEqual(sideDist.xyz, min(sideDist.yzx, sideDist.zxy));
|
//mask = lessThanEqual(sideDist.xyz, min(sideDist.yzx, sideDist.zxy));
|
||||||
|
|
||||||
|
|
||||||
// Originally he used a component wise
|
// Originally he used a component wise
|
||||||
/*bvec3 b1 = lessThan(sideDist.xyz, sideDist.yzx);
|
/*bvec3 b1 = lessThan(sideDist.xyz, sideDist.yzx);
|
||||||
bvec3 b2 = lessThanEqual(sideDist.xyz, sideDist.zxy);
|
bvec3 b2 = lessThanEqual(sideDist.xyz, sideDist.zxy);
|
||||||
mask.x = b1.x && b2.x;
|
mask.x = b1.x && b2.x;
|
||||||
mask.y = b1.y && b2.y;
|
mask.y = b1.y && b2.y;
|
||||||
mask.z = b1.z && b2.z;*/
|
mask.z = b1.z && b2.z;*/
|
||||||
//Would've done mask = b1 && b2 but the compiler is making me do it component wise.
|
//Would've done mask = b1 && b2 but the compiler is making me do it component wise.
|
||||||
|
|
||||||
//All components of mask are false except for the corresponding largest component
|
//All components of mask are false except for the corresponding largest component
|
||||||
//of sideDist, which is the axis along which the ray should be incremented.
|
//of sideDist, which is the axis along which the ray should be incremented.
|
||||||
|
|
||||||
//sideDist += vec3(mask) * deltaDist;
|
//sideDist += vec3(mask) * deltaDist;
|
||||||
//mapPos += ivec3(mask) * rayStep;
|
//mapPos += ivec3(mask) * rayStep;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// Ah this is for coloring obviously, seems to be odd though, no indexing
|
// Ah this is for coloring obviously, seems to be odd though, no indexing
|
||||||
//vec4 color;
|
//vec4 color;
|
||||||
//if (mask.x) {
|
//if (mask.x) {
|
||||||
// color = vec4(0.5);
|
// color = vec4(0.5);
|
||||||
//}
|
//}
|
||||||
//if (mask.y) {
|
//if (mask.y) {
|
||||||
// color = vec4(1.0);
|
// color = vec4(1.0);
|
||||||
//}
|
//}
|
||||||
//if (mask.z) {
|
//if (mask.z) {
|
||||||
// color = vec4(0.75);
|
// color = vec4(0.75);
|
||||||
//}
|
//}
|
||||||
//write_imagef(image, pixel, color);
|
//write_imagef(image, pixel, color);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in new issue