I want to use float3 type instead of VertexAttributes for vertices in optixIntro example projects but cannot get it to work.
Here is the piece of the code to create the attributesBuffer in createGeometry method where I only changed
VertexAttributes to float3
geometry = m_context->createGeometry();
optix::Buffer attributesBuffer = m_context->createBuffer(RT_BUFFER_INPUT, RT_FORMAT_FLOAT3);
attributesBuffer->setSize(attributes.size());
void *dst = attributesBuffer->map(0, RT_BUFFER_MAP_WRITE_DISCARD);
memcpy(dst, attributes.data(), sizeof(optix::float3) * attributes.size());
attributesBuffer->unmap();
I am not sure about Acceleration properties. I changed the size 48 to 12
acceleration->setProperty("vertex_buffer_name", "attributesBuffer");
MY_ASSERT(sizeof(optix::float3) == 12);//48
acceleration->setProperty("vertex_buffer_stride", "12");//48
acceleration->setProperty("index_buffer_name", "indicesBuffer");
MY_ASSERT(sizeof(optix::uint3) == 12);
acceleration->setProperty("index_buffer_stride", "12");
I also changed the attributedBuffer declaration in the cuda file to be of float3:
rtBufferoptix::float3 attributesBuffer;
However I get below error:
“Type mismatch (Details: Function “_rtContextValidate” caught exception: Variable “attributesBuffer” assigned type Buffer(1d, 12 byte element). Should be Buffer(1d, 48 byte element).)”
Any idea?