#ifndef TEXTURES_H
#define TEXTURES_H
#include "utils.h"
#include <complex>
#include <cmath>
namespace bex {
const int width = 256;
const int height = 256;
const int checkerSize = 31;
name.c_str(),
width,
height,
&tex));
const int components = 4;
std::vector<unsigned char> lineData(width * components);
for(int y = 0; y < height; ++y) {
for(int x = 0; x < width; ++x) {
unsigned char valLdr = ((x ^ y) & 0xff);
float val = static_cast<float>(valLdr) / 255.0f;
bool checker = ((y & checkerSize) > checkerSize / 2) ^ ((x & checkerSize) > checkerSize / 2);
lineData[x * components] = static_cast<unsigned char>(val * 255.0f * baseColor.r);
lineData[x * components + 1] = static_cast<unsigned char>(val * 255.0f * baseColor.g);
lineData[x * components + 2] = static_cast<unsigned char>(val * 255.0f * baseColor.b);
lineData[x * components + 3] = 255 * checker;
}
}
return tex;
}
float mandelbrot(std::complex<float>& j0, int maxIter) {
std::complex<float> j(0.0f, 0.0f);
int i;
for(i = 0; i < maxIter; ++i) {
j = j * j + j0;
float absJ = abs(j);
if(absJ > 2.0f) {
float res = (log(log(2.0f)) - log(log(absJ))) / log(static_cast<float>(2.0f));
return (static_cast<float>(i) + res) / static_cast<float>(maxIter);
}
}
return 1.0f;
}
name.c_str(),
width,
height,
&tex));
const int components = 4;
const int iterations = 100;
float minU = -2.0f;
float maxU = 2.0f;
float minV = -1.0f;
float maxV = 1.0f;
std::vector<float> lineData(width * components);
for(int y = 0; y < height; ++y) {
for(int x = 0; x < width; ++x) {
float localX = static_cast<float>(x) * (maxU - minU) / static_cast<float>(width) + minU;
float localY = static_cast<float>(y) * (maxV - minV) / static_cast<float>(height) + minV;
std::complex<float> c(localX, localY);
float val = mandelbrot(c, iterations);
lineData[x * components] = val * baseColor.r;
lineData[x * components + 1] = val * baseColor.g;
lineData[x * components + 2] = val * baseColor.b;
lineData[x * components + 3] = 1.0f;
}
}
return tex;
}
const int width = 256;
const int height = 256;
name.c_str(),
width,
height,
&tex));
const int components = 4;
std::vector<unsigned char> lineData(width * components);
for(int y = 0; y < height; ++y) {
for(int x = 0; x < width; ++x) {
bool lr = x > (width/2);
bool ud = y > (height/2);
unsigned char r,g,b;
r = g = b = 0;
if (lr) {
if (ud) {
r = 255;
} else {
g = 255;
}
} else {
if (ud) {
b = 255;
} else {
r = g = 255;
}
}
lineData[x * components] = r;
lineData[x * components + 1] = g;
lineData[x * components + 2] = b;
lineData[x * components + 3] = 255;
}
}
return tex;
}
const float gamma = 2.2f;
int32 count;
int32 width, height;
if (hdr) {
std::vector<float> texture(width*3);
for (int i = 0; i < height; i++) {
}
} else {
std::vector<unsigned char> texture(width*3);
for (int i = 0; i < height; i++) {
}
}
return lightMap;
}
int32 channelCount;
int32 width, height;
colors.resize(width*height*channelCount);
}
}
#endif // TEXTURES_H