Skip to main content
gamedev.net
🔒 Locked

Unsharp polygons

Started by Woltan 10 replies 1.8k views
Original Post
Woltan
Woltan
Hey guys, once again I rely on your help. This time concerning th sharpnes of polygons in different distances from the camera. As you can see in the picture of the link below, the red circled elements are what my question is about. Why is it, that the line is not realy straight? And why is it impossible to read the font? Everything you see is made out of polygons, the fov is 45. Since I am a real noob with openGL I dont know why OpenGL is doing that to me ; ) Can I somehow change the resolution? or does it has something to do with anti aliasing? Or do I have to go into ortho mode? Any help, hint anything! is greatly appreciated! Oh here the link: http://home.arcor.de/mark.foti/nik/pic.jpg Thanks in advance cherio Woltan
jkleinecke
jkleinecke
The problem you are seeing is called aliasing. Try increasing the screen resolution and/or turning on anti-aliasing.
-----------------------------------Indium Studios, Inc.
MARS_999
MARS_999
If you are using a font texture for the fonts increase the texture resolution. e.g. 128x128 512x512 and see if that helps with the text clarity...
Palidine
Palidine
the short answer is you can't have a straight diagonal line on a 2D array of pixels. You create the illusion of straightness either by increasing the resolution or doing what's called aliasing which is basically fading pixels at the edges of the line. But even with aliasing, if you zoom to a sufficient resolution, the straightness disappear. Try doing a printscreen of some application with a "straight" diagonal line and copying the image into MSPaint and then zooming in.

For fun and understanding, draw out a 2D grid and try to draw a straight line along a diagonal obeying the rule that a pixel is either on or off.

-me
Woltan
Woltan
Hey ho,
thanks for your help so far. I have a couple of questions about your comments.

1: Increasing screen resolution
How is this done? Does it have to do with the aspect ratio, or simply with the window size? How would it work in fullscreen mode?

2. Anti Aliasing
How exactly do you do that in OpenGL?
I found a couple of line smoother things in the references like
glEnable(GL_LINE_SMOOTH / GL_POLYGON_SMOOTH);
or
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
But I am not realy sure if this is anti aliasing.

and @ MARS:
No I am not using a font texture. What I did, I built this image with Anim8or and exported it into a *.c file. All the text and the rest are polygons.

I hope you can help me some more
regards Woltan
Ezbez
Ezbez
Quote:
Original post by Woltan
1: Increasing screen resolution
How is this done? Does it have to do with the aspect ratio, or simply with the window size? How would it work in fullscreen mode?


Somewhere in your program, you already have the numbers 800 and 600 which have defined the resolution. Change those to change the resolution. If you want more help than that, tell us what API you're using to create a window (Eg: Win32, SDL, Allegro, etc.).
LtJax
LtJax
Quote:
Original post by Woltan
2. Anti Aliasing
How exactly do you do that in OpenGL?
I found a couple of line smoother things in the references like
glEnable(GL_LINE_SMOOTH / GL_POLYGON_SMOOTH);
or
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
But I am not realy sure if this is anti aliasing.


Yes, those are some forms of per-primitive anti-aliasing. It's not commonly used tho. The most commonly used way to do AA is full-scene anti-aliasing via multisampling. Basically your images are (virtually) rendered in a higher resolution and then sampled down. Depending on your driver, there might be an option to force it on - or you can set it via the platform dependant MULTISAMPLE extensions.
Woltan
Woltan
Quote:
Original post by Ezbez
If you want more help than that, tell us what API you're using to create a window (Eg: Win32, SDL, Allegro, etc.).


I am using Win32.
Somehow I think it is not clear to me what resolution is.
Lets say I have a resizable window. And I change the size by draging the edges. Do I change the resolution with that?
And doe the dmPelsWidth / Hight parameters define the resolution in fullscreen mode?

Quote:
Original post by LtJax
Depending on your driver, there might be an option to force it (anti aliasing) on - or you can set it via the platform dependant MULTISAMPLE extensions.

How exactly is this done? I have never heard of those extensions.

Thanks for your help guys!
cherio Woltan
ff8
ff8
try 2 passes and use GL_BLEND between them
Nitrogen
Nitrogen
I think your easiest answer is to use textures instead of polygons. There isnt much you can do to polygons except antialias them, but this depends on the graphics card and driver settings on the computer it's running on, which isnt idea.

Using texture mapping, you'll be able to set it that it automatically smooths out your text and lines and it will work on ANY graphics card.

Here is an excellent tutorial on texture mapping:
NeHe Lesson 06

Pay special attention to this line:
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);

it sets the texture up so that it performs Linear interpolation between colours on your texture (ie. antialiasing)
Delphi C++ OpenGL Development: www.nitrogen.za.org
Woltan
Woltan
Hey Nitrogen,
thanks for the hint, and you are absolutly right! I rendered the stuff to a bitmap and it looks a lot nicer that way. However doing it like that I loose the material information of the single polygons. But I bet there is something out there that can cope with that too.
The thing I still dont get: Why on earth does it look that ugly when you try it the polygon way? I mean all the data is there, every exact location. But some edges are not displayed at all, and when you move the camera they pop back up and other edges dissapear.
But I bet there is a reasonable explenation for that out there as well.
Anyway I got what I wanted so thanks again
cherio Woltan

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.