# Screen Space Error

This topic is 4971 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello All.I am looking for some algorithm to computer the screen space error of an arbitrary vector in world coordinate. Is there any tutorial or source code? Please help me. thanks

##### Share on other sites
I assume the vector you mean is some vector telling you the difference e.g. of some point on a grid to the same point on some coarser/finer grid. That is, the vector is some error measure.

Lets call the vector d, the first point on the grid P1 and the second point P2. That is, d=P2-P1.

First of all, the screen-space error is dependent on P1 and P2. The closer P1 is to the camera, the larger will be the screen-space error in general.

In order to compute the screen-space error, project the two points P1 and P1+d to the screen. To do this, you have to apply the modelview matrix and then the projection matrix to P1 and P1+d. I assume that the modelview matrix maps world coordinates to eye (i.e. camera) coordinates. Note that both modelview and projection matrix are 4x4, but your points are 3-vectors. You'll need to add a 1 in the fourth component.

So if M is the modelview matrix and P is the projection matrix, you compute
c1 = P*(M*(P1,1))
c2 = P*(M*(P1+d,1))
((P1,1) is the vector (P1[0], P1[1], P1[2], 1).)

The screen-space error is now given by
error = sqrt( (c1[0]/c1[3] - c2[0]/c2[3])^2 + (c1[1]/c1[3] - c2[1]/c2[3])^2 )
(if I didn't mix up the indices).

Lutz

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 9
• 34
• 16
• 11
• 11
• ### Forum Statistics

• Total Topics
634122
• Total Posts
3015646
×