When you draw triangle with 3 different colors for 3 vertices, XNA automatically interpolates pixel colors in between these vertices. I would like to disable this behavior and supply my own algorithm that determines color of in-between pixels (for example, use average of 3 colors). How this should be done in XNA?
When you draw triangle with 3 different colors for 3 vertices, XNA automatically interpolates
Share
The interpolation is the basic behaviour of a shader, you can not avoid that.
if you send vertex data to a pixel shader, the data of the three vertex that form a triangle will be interpolated.
So if you want to use the average of the three colors, one option maybe precalculate them in the cpu… and send it to gpu through a differet vertex buffer, this way you can change it when you want without change the vertex buffer that contain the vertex positions….
Of course if a vertex is shared with two triangles, and it has different colors, you have to duplicate it.