diff --git a/src/consts.cu b/src/consts.cu index 27803b4..5fa57f3 100644 --- a/src/consts.cu +++ b/src/consts.cu @@ -5,7 +5,7 @@ __device__ Vec3 d_cameraDir; __device__ Vec3 d_cameraUp; __device__ Point3 d_lightPos; -Point3 h_cameraPos = Point3::init(-500.0f, 200.0f, 100.0f); +Point3 h_cameraPos = Point3::init(-300.0f, 200.0f, -300.0f); Vec3 center = Vec3::init((float)VOLUME_WIDTH/2.0f, (float)VOLUME_HEIGHT/2.0f, (float)VOLUME_DEPTH/2.0f); Vec3 h_cameraDir = (center - h_cameraPos).normalize(); Vec3 h_cameraUp = Vec3::init(0.0, 1.0, 0.0).normalize(); diff --git a/src/illumination/Raycaster.cu b/src/illumination/Raycaster.cu index 5b97e0d..705d882 100644 --- a/src/illumination/Raycaster.cu +++ b/src/illumination/Raycaster.cu @@ -10,6 +10,19 @@ #include #include "objs/sphere.h" +// Samples the voxel nearest to the given coordinates. TODO: Can be re-used in other places so move +__device__ float sampleVolumeNearest(float* volumeData, const int volW, const int volH, const int volD, int vx, int vy, int vz) { + if (vx < 0) vx = 0; + if (vy < 0) vy = 0; + if (vz < 0) vz = 0; + if (vx >= volW) vx = volW - 1; + if (vy >= volH) vy = volH - 1; + if (vz >= volD) vz = volD - 1; + + int idx = vz * volW * volH + vy * volD + vx; + return volumeData[idx]; +} + // TODO: instead of IMAGEWIDTH and IMAGEHEIGHT this should reflect the windowSize; __global__ void raycastKernel(float* volumeData, FrameBuffer framebuffer) { diff --git a/src/main.cu b/src/main.cu index 293cd9b..968be31 100644 --- a/src/main.cu +++ b/src/main.cu @@ -54,8 +54,8 @@ void getSpeed(std::vector& speedData, int idx = 0) { int main() { std::vector data; - getTemperature(data); - // getSpeed(data); + // getTemperature(data); + getSpeed(data); std::cout << "DATA size: " << data.size() << std::endl; diff --git a/src/objs/sphere.h b/src/objs/sphere.h index dbac251..27e042d 100644 --- a/src/objs/sphere.h +++ b/src/objs/sphere.h @@ -78,17 +78,4 @@ __host__ void generateVolume(float* volumeData, int volW, int volH, int volD) { } } } -} - -// Samples the voxel nearest to the given coordinates. TODO: Can be re-used in other places so move -__device__ float sampleVolumeNearest(float* volumeData, const int volW, const int volH, const int volD, int vx, int vy, int vz) { - if (vx < 0) vx = 0; - if (vy < 0) vy = 0; - if (vz < 0) vz = 0; - if (vx >= volW) vx = volW - 1; - if (vy >= volH) vy = volH - 1; - if (vz >= volD) vz = volD - 1; - - int idx = vz * volW * volH + vy * volD + vx; - return volumeData[idx]; } \ No newline at end of file