0
\$\begingroup\$

Is there a way to process individual vertex that get pumped into the vertex shader.

I have a cube and pyramid.

I want to multiply a different worldviewproj matrix for the cube. So the first 8 vertex should be a differtent matrix.

Is is possible to do such a thing in the vertex shader?

\$\endgroup\$
  • \$\begingroup\$ Use the world transformation matrix so that the box and pyramid are disjoint in world space. Luna, Frank D. Introduction To 3D Game Programming With Direct X 12 . Mercury Learning and Information. Kindle Edition. \$\endgroup\$ – user3513743 Oct 20 '16 at 17:06
  • \$\begingroup\$ DirectX 12 can do the same thing as DirectX 11 with respect to vertex processing, it just drives the hardware in different ways. DirectX12 is an expert graphics API and is quite unforgiving. Focus on learning DirectX 11 first, and you'll probably find it's more than enough for what you are doing. Don't try to learn DirectX 12 first. \$\endgroup\$ – Chuck Walbourn Oct 20 '16 at 22:35
1
\$\begingroup\$

In Shader Model 5.1 (required for DirectX 12), you certainly could use SV_VertexID in the vertex shader to address different matrices in your constant buffer(s) to transform some of the vertices uniquely, but it's unlikely that in your case the performance difference would be worth the complexity. Unless you are drawing millions of these things, you'd be better off just having distinct vertices for the two shapes: A simple no-branching shader that doesn't need system-generated values is going to be faster than a complex, dynamic branching shader that requires extra information, so the extra vertex count isn't a problem in practice.

See Using System-Generated Values

SV_VertexID is also supported in Shadel Model 4 or later so you can use it with DirectX 11 with Direct3D Hardware Feature Level 10.0 or later. It's not supported for Direct3D Hardware Feature Levels 9.1, 9.2, or 9.3.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.