12345678910111213141516171819202122232425 |
- #include <vector>
- #include <cstdlib>
- #include "client/rendering/NoiseTexture.h"
- NoiseTexture::NoiseTexture(uint width, uint height) {
- std::vector<float> data;
- for(uint x = 0; x < width; x++) {
- for(uint y = 0; y < height; y++) {
- data.push_back(getRandom());
- data.push_back(getRandom());
- data.push_back(getRandom());
- }
- }
- texture.setRGBFloatData(width, height, data.data());
- }
- void NoiseTexture::bind(uint index) const {
- texture.bind(index);
- }
- float NoiseTexture::getRandom() const {
- float r = static_cast<float> (rand()) / static_cast<float> (RAND_MAX);
- return r * 2.0f - 1.0f;
- }
|