Ray tracing (pas termine).
[GPU.git] / WCudaMSE / Student_Cuda_Image / src / cpp / core / 04_RayTracing / moo / device / RayTracingDevice.cu
1 #include <iostream>
2 #include <stdio.h>
3 using namespace std;
4
5 #include "Indice2D.h"
6 #include "IndiceTools.h"
7 #include "cudaTools.h"
8 #include "Device.h"
9
10 #include "RayTracingDevice.h"
11 #include "RayTracingMath.h"
12
13 __global__
14 void rayTracing(uchar4* ptrDevPixels, int w, int h, DomaineMath domaineMath, float t)
15     {
16     const int TID = Indice2D::tid();
17     const int NB_THREAD = Indice2D::nbThread();
18     const int WH = w * h;
19
20     RayTracingMath rayTracing; // TODO: prendre
21
22     uchar4 color;
23     color.w = 255; // Par défaut, l'image est opaque.
24
25     double x, y;
26     int pixelI, pixelJ;
27
28     int s = TID;
29     while (s < WH)
30         {
31         IndiceTools::toIJ(s, w, &pixelI, &pixelJ); // update (pixelI, pixelJ)
32
33         // (i,j) domaine écran.
34         // (x,y) domaine math.
35         // domaineMath.toXY(pixelI, pixelJ, &x, &y); // (i,j) -> (x,y).
36
37         // newtonMath.colorXY(&color, x, y);
38
39         ptrDevPixels[s] = color;
40
41         s += NB_THREAD;
42         }
43     }