PDA

View Full Version : Transformation between vertex and fragment shaders



RedSonja
03-14-2010, 11:08 AM
Hi,

I'm trying to understand the matrix transformations that happen to a vertex coordinate(as outputted by the vertex shader, say at Cg binding POSITION), before it enters the fragment shader (say, at Cg binding WPOS). I'm not interested in the way the rasterizer works in terms of filling primitives with fragments etc, so assume GL_POINTs. Assuming the vertex shader multiplies its incoming vertex coordinate by the ModelView matrix, how would you simulate the transformation of a single vertex coordinate from then on (in terms of the Perspective matrix and the viewport dimensions etc) ? Pseudo-code (like 'mul(M, V)' would be great).

Any help would be greatly appreciated. Thanks.

pjcozzi
03-14-2010, 12:52 PM
There is an excellent, but dated, discussion of the transforms in chapter three (http://www.glprogramming.com/red/chapter03.html) of the Red Book (available online).

Regards,
Patrick

RedSonja
03-15-2010, 10:47 AM
Thanks - gluProject was what I needed (mentioned at the bottom of Chapter 3)