Question

It's a common problem that outputs from a vertex shader are linearly interpolated as 3D/4D vector values, which leads to artifacts. For instance if a vertex shader outputs a normalised vector, you still typically need to renormalise it in your fragment shader.

Do D3D/OpenGL/Cg provide any way to control how interpolation is performed? e.g. can you suggest what the interpolated values mean so that some context-aware interpolation could be performed?

Was it helpful?

Solution

Like the GLSL interpolation qualifiers mentioned by Pavel Beliy, Direct3D (HLSL) has a limited set of Interpolation Modifiers that you can set on each member of data structs or on any arguments that are passed to the pixel shader. See the remarks section of this MSDN page.

The set of supported modifiers is limited to linear, centroid, nointerpolation, noperspective and sample (see link for details).

Unfortunately, the wording of your question and comment seems to suggest you have a need for more detailed control over the interpolation technique used. For example, none of the will solve the need for renormalizing interpolated vectors.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top