Question

I have two points that describe line, problem is that i know coordinates of one for orthographic matrix (ie 150x250x0), and coordinates for second for perspective matrix (0.5x0.5x20.0f). I would like to translate orthographic coordinates to perspective so i can draw a line using glsl shader :). How to accomplish this task?

Was it helpful?

Solution

You need to move one of your vertices to other matrix space. For example let's move 150x250x0 from orthographic to perspective space. To do this you need to transform your vertex by inverted orthographic matrix. I don't know what math library you use, maybe it already has function for matrix inversion. Otherwise use code from this link: http://www.gamedev.net/topic/180189-matrix-inverse/ . After this step your vertex is in world space.

PS: Matrix inversion takes some significant time for calculations. If you can track trasformations steps (translation, rotation and scale) the easier way should be to invert these steps separately and compose a matrix after that.

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