mirror of
https://github.com/MartinOpat/cuda-based-raytrace.git
synced 2025-06-07 02:13:10 +02:00
Wrapping up
This commit is contained in:
@@ -72,6 +72,14 @@ __device__ Vec3 computeGradient(float* volumeData, const int volW, const int vol
|
||||
float dfdz = (sampleVolumeTrilinear(volumeData, volW, volH, volD, fx, fy, fz + hz) -
|
||||
sampleVolumeTrilinear(volumeData, volW, volH, volD, fx, fy, fz - hz)) / (2.0f * hz);
|
||||
|
||||
// // DEBUG (TODO: Delete) - Back to nearest
|
||||
// float dfdx = (sampleVolumeNearest(volumeData, volW, volH, volD, (int)roundf(fx + 1), (int)roundf(fy), (int)roundf(fz)) -
|
||||
// sampleVolumeNearest(volumeData, volW, volH, volD, (int)roundf(fx - 1), (int)roundf(fy), (int)roundf(fz))) / (2.0f * hx);
|
||||
// float dfdy = (sampleVolumeNearest(volumeData, volW, volH, volD, (int)roundf(fx), (int)roundf(fy + 1), (int)roundf(fz)) -
|
||||
// sampleVolumeNearest(volumeData, volW, volH, volD, (int)roundf(fx), (int)roundf(fy - 1), (int)roundf(fz))) / (2.0f * hy);
|
||||
// float dfdz = (sampleVolumeNearest(volumeData, volW, volH, volD, (int)roundf(fx), (int)roundf(fy), (int)roundf(fz + 1)) -
|
||||
// sampleVolumeNearest(volumeData, volW, volH, volD, (int)roundf(fx), (int)roundf(fy), (int)roundf(fz - 1))) / (2.0f * hz);
|
||||
|
||||
return Vec3::init(dfdx, dfdy, dfdz);
|
||||
};
|
||||
|
||||
@@ -84,7 +92,7 @@ __device__ unsigned int packUnorm4x8(float r, float g, float b, float a) {
|
||||
|
||||
float len = sqrtf(r*r + g*g + b*b + a*a);
|
||||
|
||||
// This is a Vec4 but i can't be bothered to make that its own struct/class; FIXME: maybe do that if we need to?
|
||||
// This is a Vec4 but i can't be bothered to make that its own struct/class; FIXME: maybe do that if we need to? From Martin: We could use a Vec4 for rgba too, but I don't feel like it either
|
||||
u.in[0] = round(r/len * 255.0f);
|
||||
u.in[1] = round(g/len * 255.0f);
|
||||
u.in[2] = round(b/len * 255.0f);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <cuda_runtime.h>
|
||||
#include <cmath>
|
||||
|
||||
struct Vec3 { // TODO: Maybe make this into a class ... maybe
|
||||
struct Vec3 {
|
||||
double x, y, z;
|
||||
|
||||
static __host__ __device__ Vec3 init(double x, double y, double z) {Vec3 v = {x, y, z}; return v;}
|
||||
|
||||
Reference in New Issue
Block a user