Falcor icon indicating copy to clipboard operation
Falcor copied to clipboard

raytracing doesn't support structure of data

Open bryan05 opened this issue 6 years ago • 2 comments

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?

bryan05 avatar Dec 20 '18 17:12 bryan05

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?

nbentyNV avatar Dec 28 '18 01:12 nbentyNV

    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.

bryan05 avatar Dec 31 '18 22:12 bryan05