Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 9 of 9

Thread: Stitches alon triangle borders

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2013
    Posts
    12

    Stitches alon triangle borders

    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

  2. #2
    Member Regular Contributor Nowhere-01's Avatar
    Join Date
    Feb 2011
    Location
    Novosibirsk
    Posts
    251
    try to begin with an image of whatever you are talking about. and then, supply code if requested.

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2013
    Posts
    12
    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:

    Code :
    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,BackGroundBlue,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
    Last edited by towsim; 08-19-2013 at 07:39 AM.

  4. #4
    Member Regular Contributor Nowhere-01's Avatar
    Join Date
    Feb 2011
    Location
    Novosibirsk
    Posts
    251
    vBulletin Message

    Invalid Attachment specified.
    just upload it to imageshack or something.

  5. #5
    Junior Member Newbie
    Join Date
    Jun 2013
    Posts
    12
    just inserted a link to view the picture,
    sorry

  6. #6
    Member Regular Contributor Nowhere-01's Avatar
    Join Date
    Feb 2011
    Location
    Novosibirsk
    Posts
    251
    first of all, try disabling multisampling and line\polygon smoothing.

  7. #7
    Junior Member Newbie
    Join Date
    Jun 2013
    Posts
    12
    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

  8. #8
    Member Regular Contributor Nowhere-01's Avatar
    Join Date
    Feb 2011
    Location
    Novosibirsk
    Posts
    251
    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.

  9. #9
    Junior Member Newbie
    Join Date
    Jun 2013
    Posts
    12
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •