Advertisement
Guest User

PhongRands

a guest
Jan 25th, 2015
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1.     const float PhongRandsConsts[32] =
  2.     {
  3.         0,
  4.         188,
  5.         137,
  6.         225,
  7.         99,
  8.         207,
  9.         165,
  10.         241,
  11.         71,
  12.         198,
  13.         151,
  14.         233,
  15.         120,
  16.         216,
  17.         177,
  18.         248,
  19.         50,
  20.         193,
  21.         145,
  22.         229,
  23.         110,
  24.         212,
  25.         171,
  26.         244,
  27.         86,
  28.         203,
  29.         158,
  30.         237,
  31.         129,
  32.         220,
  33.         182,
  34.         252
  35.     };
  36.  
  37.     inline float tosRGBFloat(float rgba)
  38.     {
  39.         float srgb = (rgba*rgba)*(rgba*0.2848f + 0.7152f);
  40.         return srgb;
  41.     }
  42.  
  43.     Math::Vector4* GetPhongRands()
  44.     {
  45.         static Math::Vector4 rands[32];
  46.         float r1 = 0.032f;
  47.  
  48.         for (int it = 0, end = 32; it != end; ++it)
  49.         {
  50.             float r2 = tosRGBFloat(PhongRandsConsts[it] / 255.f);
  51.                
  52.             //float r2 = Platform::Random::RandFloat(0.f, 1.0f);
  53.  
  54.             rands[it].x = r1;
  55.             rands[it].y = r2;
  56.             rands[it].z = Math::Cos(2.f * Math::PI<float>() * r2);
  57.             rands[it].w = Math::Sin(2.f * Math::PI<float>() * r2);
  58.  
  59.             r1 += 0.032f;
  60.         }
  61.  
  62.         return rands;
  63.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement