A issue about rasterization,What's the way to deal with matrix?

28 views Asked by At

During the Geometry and Pixel,I want to generate matrix to transform position dynamically. If there is a same matrix in attribute of geometry,passing the rasterization, will the matrix in pixel shader be changed? thanks!

1

There are 1 answers

1
Chuck Walbourn On BEST ANSWER

The performance of pixel shaders on most GPU hardware is primarily determined by three factors:

  • Number of memory operations (texture lookups)
  • Number of ALU operations (adds, multiplies, etc.)
  • Number of interpolators (i.e. 4-vectors passed from the vertex to pixel shader stages and interpolated by the rasterizer hardware)

Generally speaking, modern GPUs have a lot of ALU bandwidth relative to the memory bandwidth, and the number of interpolators is a fixed resource.

In other words, passing a full matrix down as 3 to 4 interpolators is generally not desirable.

You generally want to have the pixel shader compute it's own transformations for per-pixel lighting, typically using a small number of interpolators and otherwise relying on constant buffers which are fixed for the whole draw operation. It's probably worthwhile to do redundant computations if there's not a simple and compact way to pass the data between stages.

I'm being vague here because everything is a trade-off, and your question is missing a description of what you are actually trying to accomplish.