PDA

View Full Version : Stitches alon triangle borders



towsim
08-19-2013, 01:38 AM
With the help of the forum it was possible for me to control the render quality of the graphical output out of an application. The only missing color in my rainbow is a problem, that has no adequate solution up to now. Most of the objects I display are rendered as GL_TRIANGLE_STRIP. The result in the screen has always stitches as diagonal lines along the triangle borders. Even tesselated surfaces like a font set created with 'wglUseFontOutlines' show stitches. The only possibility for the moment is to set the graphics adapter hardware (NVIDIA) to at least 4 times anitaliasing. I think, it cannot be a solution for a user to adjust the hardware to get rid of this problem. So I assume there is a possibility to set OGL into a mode which let the stitches disappear. My question is: What black magic do I have to use to get rid of stitches along triangle borders?
Thanks in advance,
Mike

Nowhere-01
08-19-2013, 01:42 AM
try to begin with an image of whatever you are talking about. and then, supply code if requested.

towsim
08-19-2013, 06:36 AM
The attached image shows the stitches I am talking about. Especially the red, vertical bus box. The yellow text inside is not readable anymore because of the stitches. The preparation of the OGL window is nothing special but may include errors:


void OGL_GRAPHICS::SetUpOGLwindow(HWND OGLwnd,double HorizontaDim, double VerticalDim, DWORD projection, DWORD bkColor)
{
int pf,w,h,buf;

memset(&pfd,0,sizeof(PIXELFORMATDESCRIPTOR));
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_TYPE_RGBA;
pfd.cColorBits = 32;
pfd.cDepthBits = 32;
pfd.cStencilBits = 1;
pfd.cAuxBuffers = 0;
pfd.iLayerType = PFD_MAIN_PLANE;
glWnd = OGLwnd;
oWinDc = GetDC(glWnd);
pf = ChoosePixelFormat(oWinDc,&pfd);
SetPixelFormat(oWinDc,pf,&pfd);
if(!arbMultisampleSupported)
{
pf = ChoosePixelFormat(oWinDc,&pfd);
}
else
{
pf = arbMultisampleFormat;
}
OGLhdc = wglCreateContext(oWinDc); // create GL device context
wglMakeCurrent(oWinDc,OGLhdc); // and make it to the current
GetClientRectDimensions(glWnd,&w,&h);
glViewport(0,0,w,h); // define a view over the whole screen
glMatrixMode(GL_PROJECTION); // prepare and set Set Projection matrix
glLoadIdentity(); // initialize the matrix
glShadeModel(GL_SMOOTH);
if(!projection)
glOrtho(-HorizontaDim / 2.0,HorizontaDim / 2.0,-VerticalDim / 2.0,VerticalDim / 2.0,-10.0,10.0); // switch to orthographic projection
glWidth = HorizontaDim;
glHight = VerticalDim;
glMatrixMode(GL_MODELVIEW); // Switch back to model view matrix
glLoadIdentity(); // and initialize
glPixelStorei(GL_UNPACK_ALIGNMENT,1); // define pixel handling
glEnable(GL_STENCIL_TEST); // we will use the help of the stencil buffer
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); // set the global blending logic
glEnable(GL_MULTISAMPLE);
glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST);

glGetIntegerv(GL_SAMPLE_BUFFERS_ARB,&buf);


CreateColor(bkColor,&BackGroundRed,&BackGroundGreen,&BackGroundBlue);
glClearColor(BackGroundRed,BackGroundGreen,BackGro undBlue,0.0f); // define the clear color for the panel
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); // clear video buffer and stencil buffer
glEnable(GL_LINE_SMOOTH);
glEnable(GL_POINT_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
glEnable(GL_POLYGON_SMOOTH);
glHint(GL_POLYGON_SMOOTH_HINT,GL_NICEST);
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
glEnable(GL_BLEND);
defaultFontID = PrepareOGLfonts(oWinDc,"Arial");
}
http://ariescon.com/stitches.jpg

Nowhere-01
08-19-2013, 07:04 AM
vBulletin Message

Invalid Attachment specified.

just upload it to imageshack or something.

towsim
08-19-2013, 07:42 AM
just inserted a link to view the picture,
sorry

Nowhere-01
08-19-2013, 07:54 AM
first of all, try disabling multisampling and line\polygon smoothing.

towsim
08-19-2013, 09:54 AM
I experimented a bit with the smooth values and, unbelievable, it worked. Disabling the polygon smooth brought the success. The other settings like line smooth and multisampling made no change. It is a bit confusing that setting like polygon smooth causes this. There is no explanation in any documentation describing such a result. The output has now an acceptable result. The only little disadvantage is the antialiasing. The curved and diagonal objects have small steps. Nevertheless, I thank you very much for the help.
Regards
Mike

Nowhere-01
08-19-2013, 10:10 AM
try setting blending to (SRC_ALPHA_SATURATE, GL_ONE). but the real solution here is to use proper antialiasing. polygon smoothing is slow, obsolete and unreliable. and i don't get, why are you trying to use it with multisampling.

towsim
08-19-2013, 10:49 AM
I had some issues to get a good texture quality. Especially the fonts created with 'PrepareOGLfonts' looked like a nightmare. Some thin characters disappeared completely. So I used multisampling and had an acceptable result on different machines. I would like to use antialiasing application controlled, but have no idea how to do it.