rviney

06-18-2004, 06:22 AM

Hi,

I'm trying to get my software rasterizer to fill the same pixels as OpenGL, but sometimes it gets a pixel or two wrong.

I'm doing all the transforms on the CPU and just passing OpenGL the clip coordinates with the OpenGL modelview and projection matrices set to identity in order to eliminate the transform stage as a source of the error.

My rasterization algorithm is as follows:

* Subtract 0.5f from the vertices in order to align with pixel centers

* Sort the vertices in y

* Construct edges, converting the y coordinates into integers using ceil(), and adjusting the x coordinates to account for the rounding

* Step up the edges, interpolating x values, and drawing each scanline, using ceil() to convert the left/right x coordinates into integer coordinates.

This gets pretty close, but doesnt always fill exactly the same pixels as GL. Any help would be appreciated, as I'm relatively new to software rendering. Could it just be floating point inaccuracy, and if so, should I change to fixed point? I can post some code if that would help.

Thanks,

- Richard

I'm trying to get my software rasterizer to fill the same pixels as OpenGL, but sometimes it gets a pixel or two wrong.

I'm doing all the transforms on the CPU and just passing OpenGL the clip coordinates with the OpenGL modelview and projection matrices set to identity in order to eliminate the transform stage as a source of the error.

My rasterization algorithm is as follows:

* Subtract 0.5f from the vertices in order to align with pixel centers

* Sort the vertices in y

* Construct edges, converting the y coordinates into integers using ceil(), and adjusting the x coordinates to account for the rounding

* Step up the edges, interpolating x values, and drawing each scanline, using ceil() to convert the left/right x coordinates into integer coordinates.

This gets pretty close, but doesnt always fill exactly the same pixels as GL. Any help would be appreciated, as I'm relatively new to software rendering. Could it just be floating point inaccuracy, and if so, should I change to fixed point? I can post some code if that would help.

Thanks,

- Richard