X-Git-Url: http://git.euphorik.ch/?p=GPU.git;a=blobdiff_plain;f=WCudaMSE%2FStudent_Cuda_Image%2Fsrc%2Fcpp%2Fcore%2F00_Rippling_warmup%2F03_math%2FRippling0Math.h;h=3879d1dff86a03594f88d6620e674257ea99dc91;hp=67b4387370c92541712383b0c5ce1b3fc008abe2;hb=b1138708dfa104f784170fcf2d50989156e5c5d0;hpb=f4016003996bd8f9dd903ad9ba6ec6269140a928 diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/00_Rippling_warmup/03_math/Rippling0Math.h b/WCudaMSE/Student_Cuda_Image/src/cpp/core/00_Rippling_warmup/03_math/Rippling0Math.h index 67b4387..3879d1d 100755 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/00_Rippling_warmup/03_math/Rippling0Math.h +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/00_Rippling_warmup/03_math/Rippling0Math.h @@ -1,7 +1,7 @@ #ifndef RIPPLING_0_MATH_H_ #define RIPPLING_0_MATH_H_ -#include +#include #include "MathTools.h" /*----------------------------------------------------------------------*\ @@ -23,14 +23,8 @@ class Rippling0Math __device__ Rippling0Math(int w, int h) + : dim2(w / 2.0) { - // TODO - } - - __device__ - Rippling0Math(const Rippling0Math& source) - { - // TODO } /*--------------------------------------*\ @@ -46,33 +40,32 @@ class Rippling0Math __device__ void color(int i, int j, float t, uchar4* ptrColor) { - // Debug (a mettre en commentaire) - { - unsigned char levelGris = 128; //in [0.255] (debug image) - ptrColor->x = levelGris; - ptrColor->y = levelGris; - ptrColor->z = levelGris; - } - - // Vrai problem - { - // TODO - } - - //color.w = 255; // opaque + const double dxy10 = dxy(j, i) / 10.0; + const double grayLevelFloat = 128.0 + 127.0 * cos(dxy10 - 100.0 * t / 7.0) / (dxy10 + 1); + const uchar grayLevel = (uchar)(long(grayLevelFloat) % 256); + + ptrColor->x = grayLevel; + ptrColor->y = grayLevel; + ptrColor->z = grayLevel; } private: + __device__ + double dxy(int x, int y) + { + return sqrt(pow(x - this->dim2, 2.0) + pow(y - this->dim2, 2.0)); + } /*--------------------------------------*\ |* Attributs *| \*-------------------------------------*/ private: + const double dim2; }; -#endif +#endif /*----------------------------------------------------------------------*\ |* End *|