HDR - DDS Cube maps

Started by
4 comments, last by leet bix 14 years, 11 months ago
Hey, I have created a cube map object that handles dds images fine, but not the HDR light probe images, is there a way i can convert them, or does anyone know where I can find dds format images of the cube map textures found at the bottom of this page http://www.debevec.org/probes/ Thanks EDIT: or is there a way of loading the HDR texture as a LPDIRECT3DCUBETEXTURE9 object like this:
[source lang = "cpp"]
FILE* fp;
	if( FAILED (fopen_s(&fp, "RNL.hdr", "rb")))
	{
		MessageBox( g_hWnd, "Unable to load texture", "Error", MB_ICONINFORMATION );
	}
	
	rgbe_header_info info;
	RGBE_ReadHeader( fp, &g_iWidthTex1, &g_iWidthTex1, &info );

	float fExposure = info.exposure;
	float fGamma	= info.gamma;

	float* m_fHDRPixels = new float[3 * g_iWidthTex1 * g_iWidthTex1];
	memset( m_fHDRPixels, 0, 3 * g_iWidthTex1 * g_iWidthTex1 * sizeof( float ) );

    RGBE_ReadPixels_RLE( fp, m_fHDRPixels, g_iWidthTex1, g_iWidthTex1 );

	D3DXCreateTexture( g_pd3dDevice, g_iWidthTex1, g_iWidthTex1, 1, D3DUSAGE_DYNAMIC, FORMAT64, D3DPOOL_DEFAULT, &g_pCubeTexture )

[Edited by - leet bix on May 2, 2009 5:57:36 PM]
Advertisement
D3DXCreateTextureFromFile should handle .hdr files...what doesn't work when you try to load them this way? Keep in mind mind that most .hdr files store the images in RGBE format, so you need to either convert to RGB ahead of time or do it in your pixel shader.
I'm currently trying to load it as a cube texture (possibly what the problem is) rather than just load a 2d texture, this is what I'm calling, and how I'm calling it;

IDirect3DCubeTexture9* pCubeTexture = NULL;    hr = D3DXCreateCubeTextureFromFileEx(pd3dDevice, strCubeMapFilePath, D3DX_DEFAULT, 1, 0, D3DFMT_A16B16G16R16F,                                         D3DPOOL_MANAGED, D3DX_FILTER_LINEAR, D3DX_FILTER_LINEAR, 0, NULL,                                         NULL, &pCubeTexture);


When I try and load an hdr image as is here, the application crashes, I assume this is due to the fact that the hdr image doesn't contain information regarding which faces should go where, that's why I wanted to try and convert the hdr images to a D3DFMT_A16B16G16R16F dds cube map texture.
I'm trying something new now, taking a step back, now all I'm trying to do is load an hdr texture into a plain old LPDIRECT3DTEXTURE9 object, I load it like this;

snip

EDIT: got it to load and display, but it creates this image;

http://img100.imageshack.us/my.php?image=asdfq.png

when trying to render a full screen rendering with the following hlsl code;


uniform extern texture g_tTexture;sampler2D DownSampler = sampler_state{	Texture = <g_tTexture>;	AddressU = Clamp;    AddressV = Clamp;    MinFilter = POINT;    MagFilter = POINT;    MipFilter = POINT;};float4 Test(float2 inTex: TEXCOORD0) : COLOR0{	float4 colour = tex2D(DownSampler, inTex);	return colour;}technique TestTechnique{	pass Pass0	{		PixelShader  = compile ps_2_0 Test();	}}


[Edited by - leet bix on May 3, 2009 2:55:34 AM]
What do you mean "it crashes"? Do you mean you have an unhandled expection? If so, what exception? The exception code and information that goes with it will give you valuable information about what went wrong. BTW a D3DX function won't throw an exception if you're doing thing correctly, it will instead give you a failing HRESULT return value.

As for your test scenario, like I said before a .hdr file doesn't contain RGB color data. Therefore you may not get anything useful out of just rendering it to the screen. If you want to see the texel values, just run your app through PIX and step through your shader or look at the actual texture itself.

I'm not trying to load it as a cube map texture anymore, just trying to render it to the screen as a full screen quad, so I'm leaving that alone for now. I've loaded the image like this;


LPDIRECT3DTEXTURE9 g_pHDRTexture = NULL;// snipg_pHDRTexture = LoadHDRTexture("Media/LightProbes/uffizi_cross.hdr"); // snip/**********************************************************************************LoadHDRTexture**********************************************************************************/LPDIRECT3DTEXTURE9 LoadHDRTexture(const char* cPath){	LPDIRECT3DTEXTURE9 pHDRTexture;	int g_iWidthTex1	= 0;	int g_iHeightTex1	= 0;	// Read in the HDR light probe.	FILE* fp;	if(FAILED(fopen_s(&fp, cPath, "rb")))	{		MessageBox( NULL, "Unable to load texture", "Error", MB_ICONINFORMATION );	}		rgbe_header_info info;	RGBE_ReadHeader( fp, &g_iWidthTex1, &g_iWidthTex1, &info );	float fExposure = info.exposure;	float fGamma	= info.gamma;	float* m_fHDRPixels = new float[3 * g_iWidthTex1 * g_iWidthTex1];	memset(m_fHDRPixels, 0, 3 * g_iWidthTex1 * g_iWidthTex1 * sizeof(float));    RGBE_ReadPixels_RLE( fp, m_fHDRPixels, g_iWidthTex1, g_iWidthTex1);	if(FAILED(D3DXCreateTexture(g_pd3dDevice, g_iWidthTex1, g_iWidthTex1, 1, D3DUSAGE_DYNAMIC, 								D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, &pHDRTexture)))	{		MessageBox(NULL, "Unable to create texture", "Error", MB_ICONINFORMATION);	}	return pHDRTexture;}


and render it to a full screen quad and using the above hlsl code, I've saved the surface that contains the hdr image as it is loaded and it ended up being 1536 x 1536 pixel version of this

http://img100.imageshack.us/my.php?image=asdfq.png

This topic is closed to new replies.

Advertisement