Falcor
Falcor copied to clipboard
raytracing doesn't support structure of data
because my engine is still very old, so the data in my shader is like this:
struct VSInput
{
float4 position : SV_POSITION;
float4 color : COLOR;
};
I want to bind buffer of this structure to raytracing shader. but the following code in Falcor in my view shows that Falcor only support array of data.
bool RtSceneRenderer::setPerMeshInstanceData(const CurrentWorkingData& currentData, const Scene::ModelInstance* pModelInstance, const Model::MeshInstance* pMeshInstance, uint32_t drawInstanceID)
{
...........
setVertexBuffer(mMeshBufferLocations.lightmapUVs, VERTEX_LIGHTMAP_UV_LOC, pVao, pVars);
setVertexBuffer(mMeshBufferLocations.texC, VERTEX_TEXCOORD_LOC, pVao, pVars);
setVertexBuffer(mMeshBufferLocations.normal, VERTEX_NORMAL_LOC, pVao, pVars);
setVertexBuffer(mMeshBufferLocations.position, VERTEX_POSITION_LOC, pVao, pVars);
setVertexBuffer(mMeshBufferLocations.bitangent, VERTEX_BITANGENT_LOC, pVao, pVars);
How can I bind structure of data into raytracing shader?
The representation in the shader is unrelated to how the buffers are stored in memory.
Are you using Falcor's SceneImporter
to load the vertex buffers?
static bool setVertexBuffer(ParameterBlockReflection::BindLocation bindLocation, uint32_t vertexLoc, const Vao* pVao, GraphicsVars* pVars)
{
.......
if (elemDesc.elementIndex == Vao::ElementDesc::kInvalidIndex)
{
pVars->getDefaultBlock()->setSrv(bindLocation, 0, nullptr);
}
else
{
assert(elemDesc.elementIndex == 0);
after I remove the assert, it worked. In the structure we have many elements, so elementIndex will be greater than zero.