views:

360

answers:

3

http://img136.imageshack.us/img136/3508/texturefailz.png

This is my current program. I know it's terribly ugly, I found two random textures online ('lava' and 'paper') which don't even seem to tile. That's not the problem at the moment.

I'm trying to figure out the first steps of an RPG. This is a top-down screenshot of a 10x10 heightmap (currently set to all 0s, so it's just a plane), and I texture it by making one pass per texture per quad, and each vertex has alpha values for each texture so that they blend with OpenGL.

The problem is that, notice how the textures trend along diagonals, and even though I'm drawing with GL_QUAD, this is presumably because the quads are turned into sets of two triangles and then the alpha values at the corners have more weight along the hypotenuses... But I wasn't expecting that to matter at all. By drawing quads, I was hoping that even though they were split into triangles at some low level, the vertex alphas would cause the texture to radiate in a circular outward gradient from the vertices.

How can I fix this to make it look better? Do I need to scrap this and try a whole different approach? IS there a different approach for something like this? I'd love to hear alternatives as well.

Feel free to ask questions and I'll be here refreshing until I get a valid answer, so I'll comment as fast as I can. Thanks!!

EDIT: Here is the kind of thing I'd like to achieve. No I'm obviously not one of the billions of noobs out there "trying to make a MMORPG", I'm using it as an example because it's very much like what I want: http://img300.imageshack.us/img300/5725/runescapehowdotheytile.png How do you think this is done? Part of it must be vertex alphas like I'm doing because of the smooth gradients... But maybe they have a list of different triangle configurations within a tile, and each tile stores which configuration it uses? So for example, configuration 1 is a triangle in the topleft and one in the bottomright, 2 is the topright and bottomleft, 3 is a quad on the top and a quad on the bottom, etc? Can you think of any other way I'm missing, or if you've got it all figured out then please share how they do it!

+1  A: 

i think you are doing it right, but you should increase the resolution of your heightmap a lot to get finer tesselation!

for example look at this heightmap renderer:

mdterrain

it shows the same artifacts at low resolution but gets better if you increase the iterations

clamp
well I figured I might be looking too closely, but I was hoping there would be a different solution to just avoid this problem at a low resolution... even ramping it up to 100x100 shows clear diagonals, though this could be played with a little when I actually make this into an editor and not just displaying a random pattern...
Ricket
A: 

I've never done this myself, but I've read several guides (which I can't find right now) and it seems pretty straight-forward and can even be optimized by using shaders.

Create a master texture to control the mixing of 4 sub-textures. Use the r,g,b,a components of the master texture as a percentage mix of each subtextures ( lava, paper, etc, etc). You can easily paint a master texture using paint.net, photostop, gimp and just paint into each color channel. You can compute the resulting texture before hand using all 5 textures OR you can calculate the result on the fly with a fragment shader. I don't have a good example of either, but I think you can figure it out given how far you've come.

The end result will be "pixel" pefect blending (depends on the textures resolution and filtering) and will avoid the vertex blending issues.

basszero
That was actually written on my other question: http://stackoverflow.com/questions/1110844/multiple-texture-images-blended-together-onto-3d-groundI'm trying to avoid having a whole-map alpha map like that, but it may have to be done in the end.... It just seems like, look at that RuneScape image and I don't see any pixels. That's how I want it, and it makes me think my approach is just a little off but I've got the right general concept I think.I don't want pixel-perfect. It's the difference between raster and vector graphics... Vector graphics are what I'm going for.
Ricket
Perhaps you can use this technique for the overall terrain, ex grass, stones, sand. Then use special tiled detail textures for paths, edges, etc.
basszero
A: 

The diagonal artefacts are caused by having all of your quads split into triangles along the same diagonal. You define points [0,1,2,3] for your quad. Each quad is split into triangles [0,1,2] and [1,2,3]. Try drawing with GL_TRIANGLES and alternating your choice of diagonal. There are probably more efficient ways of doing this using GL_TRIANGLE_STRIP or GL_QUAD_STRIP.

Liam
I'll go ahead and give you the accepted answer since I haven't marked one yet and this is indeed what I found. Alternating the triangle direction is something that many heightmap engines don't do, but seems a good trick. I have since found out about "texture splatting", however, and intend to instead store a list of different alphamaps, and each tile will have an alphamap and two textures, and then OpenGL will blend them on-the-fly as described in this post: http://www.gamedev.net/community/forums/viewreply.asp?ID=2456662
Ricket
(in other words, I'm changing my approach from the vertex alphas method, and also avoiding shader approaches as another answer mentioned)
Ricket