Jump to content

  • Log In with Google      Sign In   
  • Create Account


Shader based heightmap tears wholes in the terrain.


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.

  • You cannot reply to this topic
8 replies to this topic

#1 Wilhelm van Huyssteen   Members   -  Reputation: 924

Like
0Likes
Like

Posted 27 June 2012 - 10:58 AM

Hi.

Im trying to create a Heightmap by deforming a flat grid mesh in the vertex shader. I do a texture loopkup using the vertexes x and y position.

vec4 vpos = vec4(a_position,1.0);
vpos.z = vpos.z + texture2D(tex,vec2(vpos.x/64.0,vpos.y/64.0).r;
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vpos;

Heres the heightmap
Posted Image

And heres the result. Any idea why the terrain is full of holes?

Posted Image

Sponsor:

#2 mark ds   Members   -  Reputation: 1117

Like
0Likes
Like

Posted 27 June 2012 - 04:12 PM

I'd guess you're getting your front and back faces mixed up. Are you using a triangle strip?

#3 Wilhelm van Huyssteen   Members   -  Reputation: 924

Like
0Likes
Like

Posted 27 June 2012 - 04:23 PM

No im not using a triangle strip and I dont think its a front/back face problem. Or at least if I disable back face culling the problem persists.

#4 slicer4ever   Crossbones+   -  Reputation: 3304

Like
0Likes
Like

Posted 27 June 2012 - 04:29 PM

texture filtering?
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#5 mark ds   Members   -  Reputation: 1117

Like
0Likes
Like

Posted 27 June 2012 - 04:43 PM

how are you creating the mesh?

#6 Wilhelm van Huyssteen   Members   -  Reputation: 924

Like
0Likes
Like

Posted 27 June 2012 - 05:05 PM

@slicer4ever:


GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, 8);

seemed a little redudnet to me for heightmap textures but would it cause any actual problems?

@mark ds

I made the mesh in blender by just taking a plane and subdividing it 7 times. I then exported it to my engines format.

Edited by Wilhelm van Huyssteen, 27 June 2012 - 05:09 PM.


#7 DemonRad   Members   -  Reputation: 290

Like
1Likes
Like

Posted 27 June 2012 - 05:07 PM

mipmaps could be the issue only if vertices are duplicated, doesn't blender automatically generates shared vertices? (anyway in blender I usually create a grid mesh plane, with already the desired number of lines and columns, try to run the function "remove duplicates" and see what happens Posted Image ) or just create a grid mesh plane without subdividing it.

Edited by DemonRad, 27 June 2012 - 05:11 PM.

Peace and love, now I understand really what it means! Guardian Angels exist! Thanks!


#8 slicer4ever   Crossbones+   -  Reputation: 3304

Like
1Likes
Like

Posted 27 June 2012 - 05:25 PM

it might potentially be texture lookup with mipmapped texture, i'd recommend doing just linear texture filtering for now, also, if possible, can you get a closer look at the problem area, it's a bit difficult to make 100% certain what might be causing the artifacts from your viewing angle.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#9 Wilhelm van Huyssteen   Members   -  Reputation: 924

Like
0Likes
Like

Posted 27 June 2012 - 05:41 PM

Indeed it was. Using only linear filtering fixed the problem. Thnx a lot!




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.



PARTNERS