123456789101112131415161718192021222324252627282930313233 |
- #include <cmath>
- #include <iostream>
- #include "client/rendering/NormalTexture.h"
- #include "client/utils/PNGReader.h"
- NormalTexture::NormalTexture(const char* path) : texture(Texture::NEAREST) {
- u32 maxWidth = 256;
- u32 maxHeight = 256;
- u32 buffer[256 * 256];
- if(PNGReader::load(path, buffer, maxWidth, maxHeight)) {
- for(uint x = 0; x < maxWidth; x++) {
- for(uint y = 0; y < maxHeight; y++) {
- /*float fx = (x % 16) * (2.0f * M_PIf32 / 15.0f);
-
- float fb = (sinf(fx) + 1.0f) * 0.5f;
-
- uint r = 0;
- uint g = sqrtf(1 - fb * fb) * 255.0f;
- uint b = fb * 255.0f;
- if(y == 0)
- std::cout << x << " " << fb << "\n";
- buffer[y * maxWidth + x] = (b << 16) | (g << 8) | r;*/
- buffer[y * maxWidth + x] = 0x00FF00;
- }
- }
- texture.setRGBAData(maxWidth, maxHeight, buffer);
- }
- }
- void NormalTexture::bind(uint index) const {
- texture.bind(index);
- }
|