Ray tracing (pas termine).
[GPU.git] / WCudaMSE / Student_Cuda_Image / src / cpp / core / 04_RayTracing / moo / device / RayTracingDevice.cu
diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/device/RayTracingDevice.cu b/WCudaMSE/Student_Cuda_Image/src/cpp/core/04_RayTracing/moo/device/RayTracingDevice.cu
new file mode 100644 (file)
index 0000000..368e469
--- /dev/null
@@ -0,0 +1,43 @@
+#include <iostream>
+#include <stdio.h>
+using namespace std;
+
+#include "Indice2D.h"
+#include "IndiceTools.h"
+#include "cudaTools.h"
+#include "Device.h"
+
+#include "RayTracingDevice.h"
+#include "RayTracingMath.h"
+
+__global__
+void rayTracing(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, float t)
+    {
+    const int TID = Indice2D::tid();
+    const int NB_THREAD = Indice2D::nbThread();
+    const int WH = w * h;
+
+    RayTracingMath rayTracing; // TODO: prendre
+
+    uchar4 color;
+    color.w = 255; // Par défaut, l'image est opaque.
+
+    double x, y;
+    int pixelI, pixelJ;
+
+    int s = TID;
+    while (s < WH)
+        {
+        IndiceTools::toIJ(s, w, &pixelI, &pixelJ); // update (pixelI, pixelJ)
+
+        // (i,j) domaine écran.
+        // (x,y) domaine math.
+        // domaineMath.toXY(pixelI, pixelJ, &x, &y); // (i,j) -> (x,y).
+
+        // newtonMath.colorXY(&color, x, y);
+
+        ptrDevPixels[s] = color;
+
+        s += NB_THREAD;
+        }
+    }