NoiseTexture.cpp 423 B

1234567891011121314151617
  1. #include "client/rendering/NoiseTexture.h"
  2. #include "utils/Array.h"
  3. #include "utils/Random.h"
  4. NoiseTexture::NoiseTexture() {
  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. }
  13. void NoiseTexture::bindTo(int index) const {
  14. texture.bindTo(index);
  15. }