Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Black Pixel border around Triangles  (Read 3890 times)
0 Members and 1 Guest are viewing this topic.
Offline Therion__

Junior Member





« Posted 2008-04-05 09:38:40 »

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?




1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
    //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);
         
Online Riven
« League of Dukes »

JGO Overlord


Medals: 757
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2008-04-05 11:47:26 »

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..

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline DzzD
« Reply #2 - Posted 2008-04-05 17:08:33 »

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..

so what is the workaround ? make mipmap by hand ??

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online Riven
« League of Dukes »

JGO Overlord


Medals: 757
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #3 - Posted 2008-04-05 17:29:04 »

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

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline emzic

Senior Member





« Reply #4 - Posted 2008-04-05 20:26:44 »

try using another blend mode, namely:

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

www.embege.com - personal website
webstart blendinspect - OpenGL BlendingModes visualization.
Offline Therion__

Junior Member





« Reply #5 - Posted 2008-04-06 14:43:34 »

Quote
gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE );
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



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!

Offline emzic

Senior Member





« Reply #6 - Posted 2008-04-06 17:57:12 »

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

www.embege.com - personal website
webstart blendinspect - OpenGL BlendingModes visualization.
Offline Therion__

Junior Member





« Reply #7 - Posted 2008-04-06 19:39:12 »

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




Offline DzzD
« Reply #8 - Posted 2008-04-06 19:51:57 »

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

Offline lhkbob

JGO Knight


Medals: 32



« Reply #9 - Posted 2008-04-06 19:59:30 »

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.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Therion__

Junior Member





« Reply #10 - Posted 2008-04-06 20:05:03 »

tanks for your replys Smiley

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.

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


a try to change to  gl.glClearColor(0.0f, 0.0f, 1.0f, 0.0f) from (0,0,0,0) ; brings also black lines

Offline DzzD
« Reply #11 - Posted 2008-04-06 20:06:35 »

yup, i mist you already do two pass Smiley,

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

Offline Therion__

Junior Member





« Reply #12 - Posted 2008-04-06 20:09:56 »

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

blending at layer0 is disabled



 gl.glEdgeFlag(false); is also not working
Online Riven
« League of Dukes »

JGO Overlord


Medals: 757
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #13 - Posted 2008-04-06 23:03:57 »

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

No clue what it is though..

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline ddyer

Senior Member


Medals: 5



« Reply #14 - Posted 2008-04-07 06:45:58 »

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.

Offline DzzD
« Reply #15 - Posted 2008-04-07 08:00:30 »

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

Offline Therion__

Junior Member





« Reply #16 - Posted 2008-04-07 08:26:08 »

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



Offline DzzD
« Reply #17 - Posted 2008-04-07 08:29:51 »

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

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

Offline emzic

Senior Member





« Reply #18 - Posted 2008-04-07 16:13:02 »

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);

www.embege.com - personal website
webstart blendinspect - OpenGL BlendingModes visualization.
Offline Therion__

Junior Member





« Reply #19 - Posted 2008-04-07 19:57:38 »

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);
produces the same lines
Offline Therion__

Junior Member





« Reply #20 - Posted 2008-04-08 12:09:30 »

ok..another information:

when i turn on blendig at the rotating teapot then i got the same dark lines
at the teapot triangles/quads

it seems that the problem has only to do with vertex buffer thing itself
..when disabeling texture and work only with colors  the  line problem stays!

i use the actual release of jogl libs
Online Riven
« League of Dukes »

JGO Overlord


Medals: 757
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #21 - Posted 2008-04-08 19:31:12 »

What happens when you turn off anti-aliasing?
hm, when i download the images, i see there is no anti-aliasing (Opera scales them very smoothly..)

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Therion__

Junior Member





« Reply #22 - Posted 2008-04-09 20:18:45 »

i got it!

on some pc the lines were not visible.
i tested with setting and found..all systems that got
nvidia graphics and setting: "Anti Alaising..setting from software"
 produces the lines!!!!
(after overide the software setting in the driver control to 2xAA all graphic were fine)

so i need to set/activate AA in the application to
prevent such graphic errors
(hope i find a simple explanaition for it)

thanks to all Smiley

Offline ddyer

Senior Member


Medals: 5



« Reply #23 - Posted 2008-04-09 22:37:08 »

Another way to attack the problem might be to render a complete mesh in one operation rather than individual triangles.
Offline Therion__

Junior Member





« Reply #24 - Posted 2008-04-11 08:10:33 »

Quote
Another way to attack the problem might be to render a complete mesh in one operation rather than individual triangles.

i was also thinking about this,but the "teapot"object  example that is included
is rendered in one piece..and with blending its same..

i only need something like this:


gl.glEnable(GL.GL_AntiAlaising,AA);?!?!?!


but i can find anything here via search
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (26 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (13 views)
2014-07-29 10:59:34

E.R. Fleming (34 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (44 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!