PDA

View Full Version : Showing polygons that are perpendicular to camera (orthographic view)



audi02
12-01-2015, 03:39 AM
Hi all,
If a face is perpendicular to the camera (lets say in orthographic view), its thickness is zero and therefor the rasterizer doesn't draw any pixel for it.

What I would like to have, is that a line of one pixel width will be drown against such polygon. This line should also have the relevant colors -means that if there is a texture for this polygon, the appropriate colors of the texture appear on this line.

How can this achieved ?

Thanks

haikarainen
12-01-2015, 05:13 AM
Hi all,
If a face is perpendicular to the camera (lets say in orthographic view), its thickness is zero and therefor the rasterizer doesn't draw any pixel for it.

What I would like to have, is that a line of one pixel width will be drown against such polygon. This line should also have the relevant colors -means that if there is a texture for this polygon, the appropriate colors of the texture appear on this line.

How can this achieved ?

Thanks

Render lines instead (or in combination with triangles if you want both possibilities). I'd imagine textures would work pretty much the same way (point to texture coordinates in your VAO with glVertexAttribPointer and sample the texture using those UVs in the shader program).

Might be a better solution to this, I've never had the need to render stuff like this before so I wouldnt know.

audi02
12-01-2015, 07:19 AM
Render lines instead (or in combination with triangles if you want both possibilities). I'd imagine textures would work pretty much the same way (point to texture coordinates in your VAO with glVertexAttribPointer and sample the texture using those UVs in the shader program).

Might be a better solution to this, I've never had the need to render stuff like this before so I wouldnt know.


Thanks, this is a method I tried, and it is good only when the polygons are not clipped.

If a polygon is clipped (say there is a clip plan that cut it), then its front lines are not exist, and its back lines are covered by the polygon it share edges with, so they won't always be seen.

I tried to load an image to show this, but the system says that it is not valid image (jpg of size of 250x250)..

GClements
12-01-2015, 07:58 AM
In theory, another option is to enable anti-aliasing (GL_POLYGON_SMOOTH) but without any blending. Unfortunately, it's common for that option to be silently ignored.

audi02
12-01-2015, 08:09 AM
In theory, another option is to enable anti-aliasing (GL_POLYGON_SMOOTH) but without any blending. Unfortunately, it's common for that option to be silently ignored.

I'm not familiar with the GL_POLYGON_SMOOTH as I understand there are side effects of using it (slowing, depth issues , cracks where triangles are joined ) so I use multisample buffer for antialiasing.

GClements
12-01-2015, 11:23 AM
I'm not familiar with the GL_POLYGON_SMOOTH as I understand there are side effects of using it (slowing, depth issues , cracks where triangles are joined ) so I use multisample buffer for antialiasing.
I'm not suggesting using it for anti-aliasing.

The point about GL_POLYGON_SMOOTH is that (when it actually works), it renders each fragment which intersects the polygon, regardless of whether the fragment's centre is inside the polygon. The generated alpha value varies according to the (estimated) proportion of the fragment which is inside the polygon. But the alpha value doesn't matter unless you actually enable blending or alpha tests.

audi02
12-02-2015, 02:13 AM
I'm not suggesting using it for anti-aliasing.

The point about GL_POLYGON_SMOOTH is that (when it actually works), it renders each fragment which intersects the polygon, regardless of whether the fragment's centre is inside the polygon. The generated alpha value varies according to the (estimated) proportion of the fragment which is inside the polygon. But the alpha value doesn't matter unless you actually enable blending or alpha tests.

Thanks.

After re-thinking, the method of drawing lines won't help for clipping case (as I mention in the older message) as even if we can see the back line.. it will present the texture colors that exist at the back line. not the colors exist in the part cut by the clipping plan.