Horde3D http://horde3d.org/forums/ |
|
Uploading and using texture from memory http://horde3d.org/forums/viewtopic.php?f=2&t=965 |
Page 1 of 1 |
Author: | r3d [ 01.10.2009, 00:52 ] |
Post subject: | Uploading and using texture from memory |
I am trying to create a floating point image, upload it as a texture and use it inside a Material and would like to know if this is the fastest/only way to do it. Code: H3DRes samplerTexture = h3dCreateTexture("samplers", 16, 2, H3DFormats::TEX_RGBA32F, H3DResFlags::NoTexMipmaps); float* data = static_cast<float*>(h3dMapResStream(samplerTexture, H3DTexRes::ImageElem, 0, H3DTexRes::ImgPixelStream, true, true )); data[0] = 0.355512; data[1] = -0.709318; data[2] = -0.102371; data[3] = 0.0; //and all the other values.... h3dUnmapResStream(samplerTexture); Btw, If I would like to use a TEX_RGBA16F do you have any suggestion other than the OPENEXR library to use?. (it would also be great to add support to .exr. .hdr is pretty old ) Then I have to find the resource material and find a sampler element defined beforehand (with the map attribute empty) in the xml to assign the new sampler. Wouldn't be nice to be able to create a new sampler on the fly ? Code: //Point the texture to the material H3DRes material = h3dFindResource( H3DResTypes::Material, "models/building/volumetric.material.xml" ); h3dSetResParamI(material, H3DMatRes::SamplerElem, 0, H3DMatRes::SampTexResI, samplerTexture); Best regards return true; |
Author: | marciano [ 01.10.2009, 20:40 ] |
Post subject: | Re: Uploading and using texture from memory |
That's the right way to do it. If you don't have to read out the texture you can map it with the read flag set to false. This will be more efficient since the pixel data will not be transfered from VRAM to RAM. DDS supports Float16 formats. Another solution is to use your own encoding, something like RGBM. However, from my experience HDR textures are usually not required so often except for some cube maps (image based lighting). Most of the HDR is usually coming directly from the lighting math in the shader. r3d wrote: Wouldn't be nice to be able to create a new sampler on the fly ? The current philosophy is that the resource structure is immutable after creation. So you can only change values but nothing that would require a memory allocation. This is close to the direction that D3D10 started to take. |
Author: | karstux [ 08.07.2010, 12:22 ] |
Post subject: | Re: Uploading and using texture from memory |
I've taken the liberty to add this information to the howto section in the wiki. Maybe someone more knowledgeable should check it for correctness... I had the problem that texture creation would fail because I called h3dutLoadResorcesFromDisk before. Took me a little while to figure this out! |
Author: | marciano [ 19.07.2010, 21:35 ] |
Post subject: | Re: Uploading and using texture from memory |
Thanks for updating the wiki. The second part, the creation of a custom sampler in the shader, is optional and probably not necessary in most cases, especially if you want to use your texture as diffuse or normal map (the corresponding samplers are already defined in the model.shader). karstux wrote: I had the problem that texture creation would fail because I called h3dutLoadResorcesFromDisk before. Took me a little while to figure this out! I agree that this is a pitfall. To solve that, h3dCreateTexture could be modified to be successful if it is called for an existing texture resource which is still unloaded. |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |