NSImage and Radiance .hdr files

I was going to write some code to load Radiance format “.hdr” images (Debevec light probes). After downloading a probe I was delighted to find that Preview opened it and displayed it. I’m assuming from this that NSImage understands the Radiance file format, and I’d like to leverage it.

Has anyone tried using NSImage with Debevec’s light probes? My concern is that NSImage will silently tone map and clamp the images to LDR when I request the data.

I don’t know about NSImage, but CoreGraphics (ImageIO) can return you full 96-bit floating point images from .hdr files.

Thanks! That worked great.

I’ve got the light probes partitioned and I can save them back out successfully, but as OpenGL textures I get junk. I’ve chosen a segment of the probe such that the bottom half is black and the upper half is texture info. As an OpenGL texture I still have the black bottom half, but I garbage in the upper half.

This suggests to me that the format I’ve specified to glTexImage2D doesn’t match what CGDrawImage is writing to the buffer I’ve given it, but I’m not seeing the mismatch. Does CGDrawImage leave things in a strange format even with an RGB color space?


CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
partitions[i] = CGImageCreateWithImageInRect(source, imageBounds[i]);			
CGContextRef imageContext = CGBitmapContextCreate( &imageCube.image[i][0], imageCube.size, imageCube.size, imageCube.bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaNoneSkipLast | kCGBitmapFloatComponents );
				
CGContextDrawImage(imageContext, CGRectMake(0, 0, imageCube.size, imageCube.size), partitions[i]);
CGContextRelease(imageContext);

    
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA32F_ARB, imageCube.size, imageCube.size, 0, GL_RGBA, GL_FLOAT, &imageCube.image[0][0]);

Fixed! I forgot to specify glPixelStorei(GL_UNPACK_SWAP_BYTES, 1)

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.