I’m going to implement a paper about env. mapping and I have prefiltered env maps. they are in a power of 2 format (1024*1024). the X-axis is the phi and the Y-axis is my theta from spherical coordinates.
Now, my problem is: what’s the best way to load those .exr files? Atm I have this code. (nvm the ‘data’ stuff)
void initEnvData(){
Header header;
Array<Rgba> pixels;
const Imf::Rgba * _rawPixels;
loadImage("0_175.exr", header, pixels);
_rawPixels = pixels;
cout<<"Image loaded" <<endl;
float* data1 = (float*)malloc(48*sizeof(float));
float* data2 = (float*)malloc(48*sizeof(float));
//insert loop to read data from file
//placeholder
for (int i=0; i<96; i++){
data1[i] = i+1.0;
}
//placeholder
glGenTextures(1, &dataTexture1);
glGenTextures(2, &dataTexture2);
glGenTextures(3, &envMapTexture);
glBindTexture( GL_TEXTURE_2D, dataTexture1);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB16F_ARB, 4, 4 ,0,GL_RGB16F_ARB,GL_FLOAT,data1);
glBindTexture( GL_TEXTURE_2D, dataTexture2);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB16F_ARB, 4, 4 ,0,GL_RGB16F_ARB,GL_FLOAT,data2);
glBindTexture (GL_TEXTURE_2D, envMapTexture);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA16F_ARB, 1024, 1024, 0, GL_RGBA, GL_FLOAT, _rawPixels);
}
But _rawpixels is a 1D array of RGBA stucts, so I’m guessing that won’t work right? Do I need to convert to a 102410244 array thing or something like that ?