Load HDR texture

Started by
-1 comments, last by saghi.sharif 12 years, 3 months ago
Hi, I'm having trouble with setting up a texture which I've read from the OpenEXR file. It's a HDR light probe image and I'm trying to set it as a texture of a big sphere for showing it as my background. The problem is that the color is not right and only a light blue color is visible. I used OpenExr library for reading the image file and stored it like this:


InputFile file(Filename);
Box2i dw = file.header().dataWindow();
m_iWidth = dw.max.x - dw.min.x + 1;
m_iHeight = dw.max.y - dw.min.y + 1;
half *rgb = new half[3 * m_iWidth * m_iHeight];
FrameBuffer frameBuffer;
frameBuffer.insert("R", Slice(HALF, (char *)rgb,
3*sizeof(half), m_iWidth * 3 * sizeof(half), 1, 1, 0.0));
frameBuffer.insert("G", Slice(HALF, (char *)rgb+sizeof(half),
3*sizeof(half), m_iWidth * 3 * sizeof(half), 1, 1, 0.0));
frameBuffer.insert("B", Slice(HALF, (char *)rgb+2*sizeof(half),
3*sizeof(half), m_iWidth * 3 * sizeof(half), 1, 1, 0.0));
file.setFrameBuffer(frameBuffer);
file.readPixels(dw.min.y, dw.max.y);
m_Image = new Color[m_iWidth * m_iHeight];
for (int i = 0; i < m_iWidth * m_iHeight; ++i) {
float frgb[3] = { rgb[3*i], rgb[3*i+1], rgb[3*i+2] };
m_Image = frgb;




where color contains float R, G , B.

and this is how i create a texture:


glGenTextures(1 , &texture);
glBindTexture(GL_TEXTURE_2D,texture);

glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST);

glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, light_tex.m_iWidth, light_tex.m_iHeight, 0, GL_RGBA, GL_FLOAT, light_tex.m_Image);

This topic is closed to new replies.

Advertisement