Displaced plane looks fine on NVIDIA, has cracks on ATI

Hi,

my program does some simple displacement mapping using a vertex shader.
It works fine on NVIDIA chips, but not on ATI chips.

Here is the source code and the binary:
http://www.timosoft-software.de/stuff/dmtest.zip
The program uses the NeHe framework. I know that the NeHe samples partly
are of poor quality, but the problem also exists in a more complex
program that doesn't use the NeHe framework, so it must be *my* code
that's wrong.
The interesting things happen in DMTest.cpp. I load the textures, setup
a VBO for drawing a plane consisting of 240k vertexes and setup the
shaders. When drawing, I activate the shader program, load the color map
to texture unit 1 and the displacement map to texture unit 0, setup the
camera, and draw using the VBO.
The vertex shader reads from the (colored) displacement map, grayscales,
and displaces the vertex using the gray value:

gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;
vec4 dv = texture2D(displacementMap, gl_MultiTexCoord0.xy);
float displacement = 0.30 * dv.x + 0.59 * dv.y + 0.11 * dv.z;
vec4 newVertexPos = vec4(gl_Normal * displacement * 100.0, 0.0) + gl_Vertex;
gl_Position = gl_ModelViewProjectionMatrix * newVertexPos;

This is what it looks like on my ATI Radeon HD3300 (Windows Vista x64)
and on an ATI Radeon HD4670 (Windows XP x64):
http://www.timosoft-software.de/stuff/dmtest.png
As you can see, there are cracks. Those cracks aren't there on a NVIDIA
Geforce 8800 GTS (Windows XP), 7300 GT (Windows XP) and 8800 GTX
(Windows Vista x64).
How do I make this work correctly on ATI? I've already tried different
drivers (8.12, 9.3, 9.4), but had no luck.

Thanks in advance
Timo

P.S.: In the sample program, use the arrow keys to rotate the mesh and
the C key to toggle backface culling.
-- 
www.TimoSoft-Software.de - Unicode controls for VB6
"Those who sacrifice freedom for safety deserve neither."
"Demokratie ist per Definition unsicher. Ihr Schutz entsteht aus der
Überzeugung, dass die demokratischen Kräfte überwiegen und sich – auf
demokratischem Wege – durchsetzen."
0
Timo
4/15/2009 4:30:54 PM
comp.graphics.api.opengl 7071 articles. 1 followers. Post Follow

7 Replies
230 Views

Similar Articles

[PageSpeed] 12

For completeness, here's a screenshot from a NVIDIA card:
http://www.timosoft-software.de/stuff/mapping.jpg

Timo
-- 
www.TimoSoft-Software.de - Unicode controls for VB6
"Those who sacrifice freedom for safety deserve neither."
"Demokratie ist per Definition unsicher. Ihr Schutz entsteht aus der
Überzeugung, dass die demokratischen Kräfte überwiegen und sich – auf
demokratischem Wege – durchsetzen."
0
Timo
4/15/2009 5:15:51 PM
Timo Kunze wrote:

> [snip]

For me this looks like a culling problem. Do you use quads or
triangles as to-be-distorted mesh? If it's quads, try changing
into triangles by splitting the quads like

+---------+
|\       /|
| \     / |
|  \   /  |
|   \ /   |
|    +    |
|   / \   |
|  /   \  |
| /     \ |
|/       \|
+---------+

This should rule out any problems that may be caused by the quads
becoming concave, messing up the face direction or similiar.
Also it looks a lot better when used for a heightmap.


Wolfgang

0
Wolfgang
4/15/2009 8:13:04 PM
Hi,

I already use triangles.

Timo
-- 
www.TimoSoft-Software.de - Unicode controls for VB6
"Those who sacrifice freedom for safety deserve neither."
"Demokratie ist per Definition unsicher. Ihr Schutz entsteht aus der
Überzeugung, dass die demokratischen Kräfte überwiegen und sich – auf
demokratischem Wege – durchsetzen."
0
Timo
4/15/2009 8:44:44 PM
Timo Kunze wrote:

> Hi,
> 
> I already use triangles.

Ok, was just a thought.

But still it looks like if something is messing with the face
culling. So next question: Is face culling enabled? If so, try
what happens if you swich the culling mode from
glCullFace(GL_BACK) to glCullFace(GL_FRONT). If the missing
facets appear, then investigate further in that direction.


Wolfgang

0
Wolfgang
4/16/2009 10:13:03 AM
Wolfgang Draxinger schrieb:
> But still it looks like if something is messing with the face
> culling. So next question: Is face culling enabled? If so, try
> what happens if you swich the culling mode from
> glCullFace(GL_BACK) to glCullFace(GL_FRONT). If the missing
> facets appear, then investigate further in that direction.

I call glDisable(GL_CULL_FACE), so culling shouldn't be the problem.

Timo
-- 
www.TimoSoft-Software.de - Unicode controls for VB6
"Those who sacrifice freedom for safety deserve neither."
"Demokratie ist per Definition unsicher. Ihr Schutz entsteht aus der
Überzeugung, dass die demokratischen Kräfte überwiegen und sich – auf
demokratischem Wege – durchsetzen."
0
Timo
4/16/2009 2:17:47 PM
Got it working.
ATI cards have problems to chose the mipmap level when accessing
textures from vertex shaders. So you must use texture2DLod instead of
texture2D.

Timo
-- 
www.TimoSoft-Software.de - Unicode controls for VB6
"Those who sacrifice freedom for safety deserve neither."
"Demokratie ist per Definition unsicher. Ihr Schutz entsteht aus der
Überzeugung, dass die demokratischen Kräfte überwiegen und sich – auf
demokratischem Wege – durchsetzen."
0
Timo
4/17/2009 7:04:18 PM
Timo Kunze schrieb:
> ATI cards have problems to chose the mipmap level when accessing
> textures from vertex shaders. So you must use texture2DLod instead of
> texture2D.
....or don't mipmap the displacement map.

Timo
-- 
www.TimoSoft-Software.de - Unicode controls for VB6
"Those who sacrifice freedom for safety deserve neither."
"Demokratie ist per Definition unsicher. Ihr Schutz entsteht aus der
Überzeugung, dass die demokratischen Kräfte überwiegen und sich – auf
demokratischem Wege – durchsetzen."
0
Timo
4/17/2009 7:45:29 PM
Reply: