X-Git-Url: http://git.euphorik.ch/?p=GPU.git;a=blobdiff_plain;f=WCudaMSE%2FStudent_Cuda_Image%2Fsrc%2Fcpp%2Fcore%2F01_Rippling%2Fmoo%2Fdevice%2Fmath%2FRipplingMath.h;h=655fa094a90f8d3635180d9028379703f45e9d07;hp=74c4dfc3eff7dbd3a70b8bb5a94d336482d7f0e7;hb=b1138708dfa104f784170fcf2d50989156e5c5d0;hpb=f4016003996bd8f9dd903ad9ba6ec6269140a928 diff --git a/WCudaMSE/Student_Cuda_Image/src/cpp/core/01_Rippling/moo/device/math/RipplingMath.h b/WCudaMSE/Student_Cuda_Image/src/cpp/core/01_Rippling/moo/device/math/RipplingMath.h index 74c4dfc..655fa09 100755 --- a/WCudaMSE/Student_Cuda_Image/src/cpp/core/01_Rippling/moo/device/math/RipplingMath.h +++ b/WCudaMSE/Student_Cuda_Image/src/cpp/core/01_Rippling/moo/device/math/RipplingMath.h @@ -22,14 +22,8 @@ class RipplingMath __device__ RipplingMath(int w, int h) + : dim2(w / 2.0) { - // TODO - } - - __device__ - RipplingMath(const RipplingMath& source) - { - // TODO } /*--------------------------------------*\ @@ -45,35 +39,35 @@ class RipplingMath __device__ void color(int i, int j, float t, uchar4& color) { - // Debug (a mettre en commentaire) - { - unsigned char levelGris = 128; //in [0.255] (debug image) - color.x = levelGris; - color.y = levelGris; - color.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 - t / 7.0 / 10.0) / (dxy10 + 1); + const uchar grayLevel = (uchar)(long(grayLevelFloat) % 256); + + color.x = grayLevel; + color.y = grayLevel; + color.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; // Tools }; -#endif +#endif /*----------------------------------------------------------------------*\ |* End *|