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;