Jump to content
  • Advertisement
Sign in to follow this  
saghi.sharif

Load HDR texture

This topic is 2524 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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);

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!