Jump to content

Writing to a StructuredBuffer from a Vertex/GeometryShader (DX11)


photo

Recommended Posts

Posted

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

 

Posted

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

test.png

Posted (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!

 

rtv_and_uav_set_marked.png

Edited by helmut.bressler
×
×
  • Create New...