Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

copacetickid

OpenGL OPENGL GURUS PLEASE HELP ME

This topic is 5221 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

artifact (click me) I am rendering a cluster of blocks (touching, or close together) and i''m trying to achive the effect of simple flat shaded sides with nice smoothed black outlines. I go about this by first rendering the blocks in polygon fill mode with blending disabled, and with a polygon offset. Then i do a second pass and enable blending, a blend func of (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA), depth test as GL_LEQUAL, the depth mask off, and finally GL_LINE_SMOOTH enabled. I get decent results, with a very odd exception: if an edge of a block in the forground obscures a block behind it, the line rendered on the edge of the foremost block is horribly aliased. However, it is only aliased on the side that should be blended with the block in the background; it is fine on the inside of the block, and also fine when a block''s edge is on the background color. What is causing this? I know the color of the block in the background is in the framebuffer before i render the line, so why isn''t it using it to blend with?

Share this post


Link to post
Share on other sites
Advertisement
...Looks like z-fighting to me

maybe you want to z-offset a bit (don't ask me how its done though.. i dunno) your lines so they wont z-fight with the neigboring polys

to check if this is whats causing it, disable z-check when drawing the lines. If the alias is gone, then it is z-fighting.

Oh and try a more descriptive topic for posting next time =)
just imagine if the board was full of "help me" posts... you'd just randomly click them.

[edited by - Madster on June 7, 2004 1:00:05 AM]

Share this post


Link to post
Share on other sites
haha, if you''ll look on page 2 for the post "anti-aliasing artifacts (polygon outlining)", you''ll see that it got no replies. I''m desperately seeking a solution and i thought a change of title may help things a bit.

A z-buffer issue was my first thought, and you are right that the aliasing doesn''t occur when the depth test is disabled. The thing is, the value in the z-buffer is behind the line being drawn. If there are no conflicts with the polygon that the line is outlining, why is there a conflict with a polygon that has a greater value in the z-buffer?

The right color is there, the z-buffer value is greater than that of the line being drawn, but it''s not rasterizing it. This is what I don''t understand and have been fighting with for 3 days.

I''ve never heard the term z-fighting, but i''m assuming it means precision errors in the z-buffer. Am i wrong? Also a way to offset a polygon''s depth value is to use glPolygonOffset(...).

Share this post


Link to post
Share on other sites
quote:
Original post by copacetickid
A z-buffer issue was my first thought, and you are right that the aliasing doesn''t occur when the depth test is disabled. The thing is, the value in the z-buffer is behind the line being drawn. If there are no conflicts with the polygon that the line is outlining, why is there a conflict with a polygon that has a greater value in the z-buffer?

How much greater? z-fighting is caused by insufficient precision in the z-buffer - a result of finite and limited representation of depth values, causing problems when values are close.

Try switching to a 24- or 32-bit z-buffer. If that doesn''t work (or you''re already doing so), try increasing the value of your near clip plane. If you''re still having this problem after that, it''s probably not z-fighting.

Share this post


Link to post
Share on other sites
I don''t think this is z-fighting, I think it''s a limitation of the way your OpenGL implementation draws smooth lines. Try drawing smooth lines that partially intersect your blocks, if the intersection is aliased that''s proabably your problem. This could be exaggerated by the fact that you use polygon offset when drawing the blocks instead of the lines.

In short, parts of the smooth line fails the depth test which causes aliasing. This might be due to the implmentation using textured view aligned quads as smooth line primitives.

Share this post


Link to post
Share on other sites
This might not help much, but i''ve seen similar effects on a GF4 Ti 64Meg from creative when activating GL_POLYGON_SMOOTH, so as GameCat says, this does seem an implementation issue... the same program I''m talikng about was tested on a Radeon 9600xt and a TNT2 and got no problems, though.

Try testing on other machine / card combo. I bet that LINE_SMOOTH is whats causing the problem.

Share this post


Link to post
Share on other sites
Thanks for all the responses guys, I'm sorry I haven't responded quickly; it's finals week

Myopic Rhino:
I immediatly changed to 32 bit depth buffer when i thought it could be a z-buffer issue. My near and far planes are set to be as close together as possible without clipping polys. This had no effect, so i'm going to assume it's not a precision issue.

GameCat:
I'm not sure i understand what you said by drawing lines that partially intersect blocks. But without a polygon offset, the aliasing still occurs. I'm leaning towards yours and BahamutCube's suggestion that it's an implementation problem.

BahamutCube:
Thanks, i'll try to see if it happens on an ati card.

mikeman:
No, i'm not rendering them back to front, but i am rendering all of the filled polygons before I draw in the lines so it shouldn't matter.

[edited by - copacetickid on June 8, 2004 1:27:05 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by BahamutCube
This might not help much, but i''ve seen similar effects on a GF4 Ti 64Meg from creative when activating GL_POLYGON_SMOOTH


For *polygon* smooth to work, you need to set up blending a certain way and sort your polygons in back to front order. If it worked on other cards, it was probably because they ignored the hint.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!