How to scan all pixels of a line in openGL

  • Follow


I have to check all pixels of an edge of a polygon for visibility.
What is the best way to scan every pixel of this edge? In other words,
how do I know to which pixels the edge is exactly rasterized.
thx for your time
0
Reply dreamchaser1981 8/12/2003 7:03:43 AM

Hello, Kurt!
You wrote  on 12 Aug 2003 00:03:43 -0700:

 K> I have to check all pixels of an edge of a polygon for visibility.
 K> What is the best way to scan every pixel of this edge? In other
 K> words, how do I know to which pixels the edge is exactly rasterized.

fragments centers of which are inside a polygon are rasterized.

With best regards, Alex Mizrahi aka killer_storm.


0
Reply Alex 8/12/2003 2:05:13 PM


> fragments centers of which are inside a polygon are rasterized.

Don't forget the rule which edge, left or right, is rasterized if the center
of fragment is precisely at the edge of the triangle (so we can't say that
what you say above is universal rule: it has it's exception..)


0
Reply totally 8/12/2003 4:15:24 PM

"Alex Mizrahi" <pmiz@etel.dn.ua> wrote in message news:<bhasta$101451$2@ID-177567.news.uni-berlin.de>...
> Hello, Kurt!
> You wrote  on 12 Aug 2003 00:03:43 -0700:
> 
>  K> I have to check all pixels of an edge of a polygon for visibility.
>  K> What is the best way to scan every pixel of this edge? In other
>  K> words, how do I know to which pixels the edge is exactly rasterized.
> 
> fragments centers of which are inside a polygon are rasterized.
> 
> With best regards, Alex Mizrahi aka killer_storm.

I have to render the edges seperately from the polygons in a different
color for several reasons. So actually, I just want to know for a
given line between 2 3D points in object space to which pixels it is
rasterized in screen space.
0
Reply dreamchaser1981 8/12/2003 8:37:54 PM

dreamchaser1981@hotmail.com (Kurt) wrote in message news:<f7fbf77f.0308112303.21a56b96@posting.google.com>...
> I have to check all pixels of an edge of a polygon for visibility.
> What is the best way to scan every pixel of this edge? In other words,
> how do I know to which pixels the edge is exactly rasterized.
> thx for your time

I'll try to make myself a little bit more clear.

In my current implementation I do it as follows. I calculate the
screen space coordinates of the vertices by using gluProject. I use
floor() to convert these double values to integers (or should i round
them differently to find the exact coordinates as ints?). Then I
scan-convert between these two coordinates by using Bresenhams
algorithm. Most of the pixels rendered by opengl and the ones
generated by Bresenham's algorithm match, but there are still a lot of
pixels where Bresenham finds pixels that are right next to the
according pixel rendered by opengl.

As an example, you can see the image on
http://lumumba.luc.ac.be/~dreamchaser/thesis/images/deer.png
green pixels indicate a match, red pixels are pixels generated by
Bresenham that don't match, and the black pixels are the pixels
rendered by opengl that are missed by Bresenham, so actually the red
pixels should have generated the coordinates of the black pixels to
match my goal.

Any solutions?

thx for your time
0
Reply dreamchaser1981 8/13/2003 2:04:45 AM

Hello, Kurt!
You wrote  on 12 Aug 2003 13:37:54 -0700:

 K>>> I have to check all pixels of an edge of a polygon for visibility.
 K>>> What is the best way to scan every pixel of this edge? In other
 K>>> words, how do I know to which pixels the edge is exactly
 K>>> rasterized.

 >> fragments centers of which are inside a polygon are rasterized.

 >> With best regards, Alex Mizrahi aka killer_storm.

 K> I have to render the edges seperately from the polygons in a
 K> different color for several reasons. So actually, I just want to know
 K> for a given line between 2 3D points in object space to which pixels
 K> it is rasterized in screen space.

you can read about that in OpenGL Specifications. as far as i remember there
can be different ways of rendering lines in different implementations.

With best regards, Alex Mizrahi aka killer_storm.


0
Reply Alex 8/13/2003 10:54:27 AM

> floor() to convert these double values to integers (or should i round
> them differently to find the exact coordinates as ints?). Then I
> scan-convert between these two coordinates by using Bresenhams

Bzzzt. This is where it goes wrong: when you scanconvert, you must not
discard the decimals. Look up keyword: "subpixel" from google, there will be
plenty of appropriate documents popping up.


0
Reply totally 8/13/2003 12:41:16 PM

> I'll try to make myself a little bit more clear.
> 
> In my current implementation I do it as follows. I calculate the
> screen space coordinates of the vertices by using gluProject. I use
> floor() to convert these double values to integers (or should i round
> them differently to find the exact coordinates as ints?). Then I
> scan-convert between these two coordinates by using Bresenhams
> algorithm. Most of the pixels rendered by opengl and the ones
> generated by Bresenham's algorithm match, but there are still a lot of
> pixels where Bresenham finds pixels that are right next to the
> according pixel rendered by opengl.

You should use floatin point numers in your implementation or 
use integers with subpixel accuracy. I think that Bresenham 
algorithm are not used in OpenGL line rendering. Line rendering
depends on hardware vendor implementation. For example, old
Voodoo chips render line as very thin triangle.

Even more, if you use antialiasing in your app, many pixels around 
line center are affected.

yooyo
0
Reply yooyo 8/15/2003 7:44:54 PM

7 Replies
263 Views

(page loaded in 0.105 seconds)

Similiar Articles:













7/22/2012 2:46:41 AM


Reply: