NoiseTexture.cpp 438 B

123456789101112131415161718
  1. #include "client/rendering/NoiseTexture.h"
  2. #include "utils/Array.h"
  3. #include "utils/Random.h"
  4. bool NoiseTexture::init() {
  5. texture.init(TextureFormat::float32(3), 0);
  6. Random r(1);
  7. Array<float, 48> data;
  8. for(int i = 0; i < 48; i++) {
  9. data[i] = r.nextFloat() * 2.0f - 1.0f;
  10. }
  11. texture.setData(4, 4, data.begin());
  12. return false;
  13. }
  14. void NoiseTexture::bindTo(int index) const {
  15. texture.bindTo(index);
  16. }