Black Pixel border around Triangles

i made a brute force landscape but i got a simple problem

the first layer is without alpha… the other are with alpha,
that work absolut perfect…the only thing, i got around the
triangles of layer1 after activate blend a black border around

how can i remove this?


    //Layer 0
      texture[7].bind();
      gl.glTexCoordPointer   (2, GL.GL_FLOAT, 0, ot);
      gl.glNormalPointer     (GL.GL_FLOAT,0,ono);
      gl.glVertexPointer     (3, GL.GL_FLOAT, 0, ov);
      gl.glColorPointer      (4, GL.GL_FLOAT, 0, oc);
      flachen_c=count*4; //dreiecke * 4
      gl.glDrawElements(GL.GL_TRIANGLES, flachen_c, GL.GL_UNSIGNED_INT, indices);
     
     gl.glEnable( GL.GL_BLEND );
      gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA );
     
      //Layer 1 ((Alpha blended)
      texture[7].bind();
      gl.glTexCoordPointer   (2, GL.GL_FLOAT, 0, ot);
      gl.glNormalPointer     (GL.GL_FLOAT,0,ono);
      gl.glVertexPointer     (3, GL.GL_FLOAT, 0, ov);
      gl.glColorPointer      (4, GL.GL_FLOAT, 0, oc1);
      flachen_c=count*4; //dreiecke * 4
      gl.glDrawElements(GL.GL_TRIANGLES, flachen_c, GL.GL_UNSIGNED_INT, indices);
         

This is often related to the data in your texture.

Some gfx-apps make all 100% transparant pixels black.
When you start mipmapping, or filtering your texels, you get a lerp between [any color + any alpha] --> [black, 100% alpha], which obviously has [dark color + more alpha] in between, causing the black edges…

[quote]Some gfx-apps make all 100% transparant pixels black.
When you start mipmapping, or filtering your texels, you get a lerp between [any color + any alpha] --> [black, 100% alpha], which obviously has [dark color + more alpha] in between, causing the black edges…
[/quote]
so what is the workaround ? make mipmap by hand ??

You can write a little app that reads the image, figuring out where the gfx-app removed the colors, and then copy a few neighbouring pixels around in those black pixels, until the image is filled again. Then save that as PNG or TIFF with ImageIO, and you’re back in business

try using another blend mode, namely:

gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE );

[quote]gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE );
[/quote]
still produces the same border things

[quote]You can write a little app that reads the image, figuring out where the gfx-app removed the colors, and then copy a few neighbouring pixels around in those black pixels, until the image is filled again. Then save that as PNG or TIFF with ImageIO, and you’re back in business
[/quote]
i rember years ago when i first startet with opengl in c++ that
there i got same problem…but there was another solution…
i lost all my backups so i cant look at it.

i try some other research… i tell you if i got it!

can we have a screenshot to see the artifacts you mean?

ok, here a shot…
the source is like you see in first posting
with
gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE );

you see layer 1 …layer 0 below is not visible in this example…

layer 1 uses blending and there i got all this borders around the triangle
at layer 0(without blend) is every fine…

the textures got size of 256x256pixels and are jpg format

http://www.unterhaltungsuniversum.de/img/pic1.jpg

http://www.unterhaltungsuniversum.de/img/pic2.jpg

yep so maybe this is a normal issue :
imagine that you only render one triangle it is blended with your background on the border, try a different background color, i guess border will be tinted with this new background color no?

EDIT:
I would recommend to make two pass : first render all triangle layer0 than second pass render all triangle layer 1 with blend

You could try using edge flags to tell opengl that certain triangles shouldn’t have their edges blended with the background, that way you shouldn’t get the black lines.

tanks for your replys :slight_smile:

[quote]You could try using edge flags to tell opengl that certain triangles shouldn’t have their edges blended with the background, that way you shouldn’t get the black lines.
[/quote]
how do i implement this?

[quote]yep so maybe this is a normal issue :
imagine that you only render one triangle it is blended with your background on the border, try a different background color, i guess border will be tinted with this new background color no?

EDIT:
I would recommend to make two pass : first render all triangle layer0 than second pass render all triangle layer 1 with blend
[/quote]
a try to change to gl.glClearColor(0.0f, 0.0f, 1.0f, 0.0f) from (0,0,0,0) ; brings also black lines

http://www.unterhaltungsuniversum.de/img/pic3.jpg

yup, i mist you already do two pass :),

ps: also think to disable blend (as you enable it for layer1) before rendering your first layer gldisable(GL_BLEND)

[quote]ps: also think to disable blend (as you enable it for layer1) before rendering your first layer gldisable(GL_BLEND)
[/quote]
blending at layer0 is disabled

gl.glEdgeFlag(false); is also not working

Seeing these screenshots, I can assure you it has nothing to do with black pixels in your texture.

No clue what it is though…

The location of edge pixels in triangles is tricky - at the lowest level you have to use exactly
the right drawing algorithm and boundary conditions to arrange that when you break a scene
into triangles and render each triangle separately, they will all mesh perfectly to make each
pixel a member of exactly one triangle. One can hope that rendering packages are aware
of this, but it’s a fragile thing.

Two things come to mind. (1) The most common way to lose is if some of the triangles are would
clockwise and some are anticlickwise. (2) Try not mixing rendering modes for the layers. Use
alpha on every pass even though it is unnecessary on the first pass.

Three - three things come to mind - attempting to antialias the edges will definitely screw you. I vaguely
recall that openGL has a way to designate which edges of the triangles should not be antialiased, and
interior edges where an adjacent triangle continues the same pattern should definitely not be.

can you put something webstartable plz ? I would like to see this artifact running as it is disapointing me.

i will do a runable webdemo after work tonight (german time).

blending enable including layer0 will also bring this lines…

but another thing…this night i code the same thing in opengl with c++,
basic program …same calls and the same layers…result: its without
this dark lines around the triangles…so i think
it must be any declaration inside jogl(textures,vertext etc) that is wrong or missing by default

good I will look your demo, need to go working too.

that’s interristing, you may have found a bug.

ah, now that i see the screenshot, i think this issue has nothing to do with blending but more with the texture-wrap-mode.

try setting it to:

	texture.setTexParameteri(GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
	texture.setTexParameteri(GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);

ok,here we go:

http://www.unterhaltungsuniversum.de/demo/demo.zip

viewcontrol with mousemove

pressing left mouse button to run forward
right mouse button to run back
middle mousebutton to stop
ESC to exit

5 Layers (Layer 0 without blend)

[quote]texture.setTexParameteri(GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
texture.setTexParameteri(GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);
[/quote]
produces the same lines