1
votes

My question is simple in theory - what is the best way to input per face data to a pixel shader? If it were injected via a simple cbuffer array, I could access the data using the SV_PrimitiveID value. The limit of 8096 floats per cbuffer would obviously be a problem for any moderately detailed model, however.

Is there an alternative to this method? Possibly using a separate vertex stream?

Ideally, I would input the data on a per vertex basis, but the data is per face to hold the index of the texture to use for each face to be looked up in in a texture array. Interpolation of texcoord data across vertices would mess up this index if used per vertex, surely? If there is anyway to do it per vertex, however, I'm all ears!

Many thanks for any help you can provide.

1

1 Answers

2
votes

Geometry shaders run per-face and can be used to pass data per polygon to the pixel shader.

When used on triangles, they take as input 3 vertices and output 3 vertices, but they're essentially de-duplicated at this point, so the fact that one vertex is shared between multiple triangles doesn't matter from the Geometry Shader onwards. Since uints aren't interpolated you don't have a problem in that regard, the index is taken from the 'leading' vertex in the triangle.

Geometry Shaders on MSDN