Jump to content

  • Log In with Google      Sign In   
  • Create Account


Software Renderer Coordinate Issue


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 ShadowMan777   Members   -  Reputation: 361

Like
1Likes
Like

Posted 20 October 2012 - 07:44 PM

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.

Edited by ShadowMan777, 21 October 2012 - 01:07 AM.


Sponsor:

#2 The_Doc   Members   -  Reputation: 122

Like
0Likes
Like

Posted 22 October 2012 - 01:52 PM

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?

Edited by The_Doc, 22 October 2012 - 01:53 PM.


#3 bmarci   Members   -  Reputation: 369

Like
0Likes
Like

Posted 31 October 2012 - 06:09 AM

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..




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS