helmut.bressler Posted February 7, 2019 Share Posted February 7, 2019 Hello, I would like to write the vertices from a ObjectMeshSkinned into a StructuredBuffer (with bone transforms and blend shapes applied) for further processing. I need to do that per frame and I found that doing that on the CPU with getSkinnedVertex() and getSkinnedTangent() is too slow unfortunately. The best place to do that seems to me to 'intercept 'the skinned vertices in a VertexShader, which writes them to a structured buffer through an unordered access view. I have tried to utilise the Object::render() method for that purpose, but it seems this method doesn't trigger any draw calls: Game* game = Game::get(); auto player = game->getPlayer(); auto camera = player->getCamera(); texturerender->enable(); texturerender->setUnorderedAccessBuffer(1, structuredBuffer); texturerender->setColorTexture(0, texture); objMeshSkinned->render(Render::PASS_AUXILIARY, 0); //viewport->renderNode(camera, objMeshSkinned->getNode()); works but I don't get the structured buffer bound as unordered access view texturerender->disable(); I have tried with other render passes as well. (Shaders are not modified yet, I first want to check if the structured buffer is bound as unordered access view somewhere) Many thanks and cheers Helmut Link to comment
andrey-kozlov Posted February 8, 2019 Share Posted February 8, 2019 Hello Helmut, The code seems fine. Maybe the material doesn't have auxiliary pass or something like that. I've attached working example of explicit rendering of a skinned mesh to texture. ObjectMeshSkinnedExplicitRender.zip Link to comment
helmut.bressler Posted February 8, 2019 Author Share Posted February 8, 2019 (edited) Hello andrey, Thank you a lot for the sample code. I haven't tried it yet but I could immediately figure out a big difference. The code snippet I have provided was not executed inside a Render callback, so I would guess that this is the main reason why it was not working on my side. I will keep you updated on this :-) EDIT: Brilliant, got it working! Many thanks! Edited February 8, 2019 by helmut.bressler Link to comment
Recommended Posts