Software Renderer Coordinate Issue

Started by
1 comment, last by bmarci 11 years, 5 months ago
Hello. I am having issues with my coordinate system for my software renderer. Here is a picture of the issue.

http://imgbin.org/in...e=image&id=9955

This is a plan square with vertices defined as
v -0.5 -0.5 -1.5
v -0.5 0.5 0.0
v 0.5 0.5 0.0
v 0.5 -0.5 0.0


When I move the Z of the bottom left point into the negative z, by -1.5 this is what happens.

http://imgbin.org/in...e=image&id=9956

If I move the bottom left point in the +1.5 z direction, this happens.

http://imgbin.org/in...e=image&id=9957

Another interesting thing is that I have to make the UpVector (0,-1,0) to make the points in the positive Y be drawn above the origin.

Any ideas? It seems that when I modify the Z, the points move in very weird directions. Thanks.
Advertisement
How are you projecting the points? Where on the 2D view-plane do you expect the point to be projected if you do the math by hand?

Another interesting thing is that I have to make the UpVector (0,-1,0) to make the points in the positive Y be drawn above the origin.
Any ideas? It seems that when I modify the Z, the points move in very weird directions. Thanks.


It's because in the screen space the Y increasing downwards, the origin is at the top-left corner, it's easier if you just flip it when projecting.
In the very old days I used this simple formula:

x2d = (fovx * x3d) / z3d + screen_center_x
y2d = -(fovy * y3d) / z3d + screen_center_y
It's not scientific, but worked, the xyz3d are transformed to camera space.

With weird corners behind the screen, you will not get away without cliping. If you draw wireframe, it's enough to cut the edges at a certain distance, but if you draw filled/txtured polygons you'll need to do some extra work. Depending on how many vertices go behind the screen plane you'll get one or two polygons.

hope it helped..

This topic is closed to new replies.

Advertisement