View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Artifacts on Intel HD Hardware

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

4 replies to this topic

### #1plainoldcj  Members

Posted 19 May 2013 - 02:53 PM

Hi everyone!

I'm experiencing strange rendering artifacts when running my program on Intel graphics hardware. According

to Google that's not unusual, so I'm hoping you guys have some advice for me

See the attached image. I have a NVIDIA Optimus laptop setup. On the right side you see the output

of the dedicated NVIDIA GPU, which i consider to be correct. On the left side you see the output of the

Intel HD 3000 onboard GPU, using the most recent drivers, showing some kind of white stripes, which

flimmer when moving the object or the camera. I think this looks like z-fighting.

I'm doing pretty basic multiple pass lighting, with this setup:

0              TRUE          LESS

1              FALSE        EQUAL

>1            FALSE        EQUAL

The problem does not show up if I render only one pass.

I tried to eliminate the most likely reasons for z-fighting:

On both GPUs the depth buffer is 24bit in size. (checked using glGet*(GL_DEPTH_BITS)

and QGLFormat::depthBufferSize())

In my projection matrix, I set [zNear, zFar] to reasonable values, eg. [0.1, 100], [1, 40].

Playing around with glPolygonOffset didn't solve the problem.

The white stripes are still visible, when I draw the mesh in solid black, by setting the lighting

color to black.

When I disable blending, the stripes become black and the problem remains the same.

So basically, I have no idea what to do Do you guys have any advice or idea

what might be the problem?

### #2swiftcoder  Senior Moderators

Posted 20 May 2013 - 06:38 AM

That definitely looks like depth fighting.

Are you sure the depth buffer is *actually* 24-bit? Potentially the driver could be giving you a lower bit-depth than you requested.

Tristam MacDonald - Software Engineer @ Amazon - [swiftcoding] [GitHub]

### #3mhagain  Members

Posted 20 May 2013 - 06:55 AM

Yup, it's almost certainly Z-fighting.

I'd advise forgetting about polygon offset for starters; it's not intended as a general-purpose solution to Z-fighting, and the specification allows it's effects to be implementation-specific - in other words, it's fairly useless.

Instead, have a look at how you're drawing - specifically how you're transforming - the polygons that fight.  Do they share the same geometry as other scene polygons?  Are you using ftransform for one set but matrix multiplication for another?  Or fixed pipeline for one set but programmable for another?  Because OpenGL isn't a pixel-exact specification, and because you may be using paths where invariance isn't guaranteed, it's entirely possible that the Intel behaviour is actually within spec (i.e. not a bug) but just undesirable nonetheless.

Ultimately the solution of last resort may be to adjust your source geometry so that this kind of thing doesn't happen.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

### #4AgentC  Members

Posted 20 May 2013 - 06:56 AM

Yeah, was going to say the same what mhagain just said, are you transforming the vertices the same way in all lighting passes?

Also, if there are actually overlapping polygons in the same model, it may lead to double-lighting artifacts in light passes.

Edited by AgentC, 20 May 2013 - 06:59 AM.

Every time you add a boolean member variable, God kills a kitten. Every time you create a Manager class, God kills a kitten. Every time you create a Singleton...

### #5plainoldcj  Members

Posted 20 May 2013 - 09:06 AM

Hey guys, great tips!

You were right about the vertices being transformed differently in different passes.

Here is what caused the z-fighting:

Pass0:
gl_Position = uProjection * uTransform * aPosition;

Pass1:
vec3 worldPos = (uTransform * aPosition).xyz;
// ...
gl_Position = uProjection * vec4(worldPos, 1.0);


Simply using the same expression for gl_Position in every pass

solves the problem:

(at least in my case, I think it depends on compiler optimizations)

Pass0:

vec3 worldPos = (uTransform * aPosition).xyz;
gl_Position = uProjection * vec4(worldPos, 1.0);


It's even simpler than that. The following code solves the problem

as well and is a great example for non-associativity of floating

point arithmetic:

(glsl multiplication is left-associative)

Pass0:
gl_Position = uProjection * (uTransform * aPosition);


Cool Thank you guys very much!!!

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.