• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
timothyjlaird

tiling terrain seam

7 posts in this topic

I'm trying to tile some terrain that I generated using height mapping. Basically I make a plane on the x/z axis and then change the 'y' values based on a height map. In order to make the terrain tile I averaged the 'y' values on sides of each block of terrain (there are 4). Problem is that I end up with a seam that actually lines up well but the lighting is all screwed up along the seam as you can see here...

[img]http://i295.photobucket.com/albums/mm151/coffeeaddict21/seamproblem.jpg[/img]

I'm fairly confident this is because I am not calculating the normals quite right along the seam. This is the code I am using the calculate the normals:

[CODE]
//calc normals for smooth shading
for (int counter = 0; counter < indexData.Length; counter += 3)
{
Vector3 v1 = vertexData[indexData[counter + 0]].Position;
Vector3 v2 = vertexData[indexData[counter + 1]].Position;
Vector3 v3 = vertexData[indexData[counter + 2]].Position;
Vector3 vu = v3 - v1;
Vector3 vt = v2 - v1;
Vector3 normal = Vector3.Cross(vu, vt);
normal.Normalize();
vertexData[indexData[counter]].Normal += normal;
vertexData[indexData[counter + 1]].Normal += normal;
vertexData[indexData[counter + 2]].Normal += normal;
}
for (int counter = 0; counter < vertexData.Length; counter++)
{
vertexData[counter].Normal.Normalize();
}
[/CODE]

Any ideas on how to resolve this?
0

Share this post


Link to post
Share on other sites
How are the tiles buildet up? Each has its own Vertexbuffer?
The code for your normals seems correct, may you are calling it before you change the y-values of the vertices?
That caused the problem in my case, may its the same for you.

What does the code to average the y-values look like? Can you post it please?
Oh, another question I have, how do you make the textures fit together that perfectly in slope-based texturing? Edited by gnomgrol
0

Share this post


Link to post
Share on other sites
[quote name='gnomgrol' timestamp='1340629727' post='4952643']
How are the tiles buildet up? Each has its own Vertexbuffer?
The code for your normals seems correct, may you are calling it before you change the y-values of the vertices?
That caused the problem in my case, may its the same for you.

What does the code to average the y-values look like? Can you post it please?
Oh, another question I have, how do you make the textures fit together that perfectly in slope-based texturing?
[/quote]

The vertex and index buffers are the same for all 4 blocks of terrain. I simply change effect.World (translation matrix) each time, then draw.

Nope. The last thing I do is calculate the normals.

Here is the code I used for averaging the y-values along the edges:

[CODE]
private float[,] getMirroredVertexDataTwoDim(float[,] yvalues, int size)
{
float leftsidey;
float rightsidey;
float avgleftright;
float topsidey;
float bottomsidey;
float avgtopbottom;
for (int zcounter = 0; zcounter < size; zcounter++)
{
leftsidey = yvalues[0, zcounter];
rightsidey = yvalues[size - 1, zcounter];
avgleftright = (leftsidey + rightsidey) / 2.0f;
yvalues[0, zcounter] = avgleftright;
yvalues[size - 1, zcounter] = avgleftright;
}
for (int xcounter = 0; xcounter < size; xcounter++)
{
topsidey = yvalues[xcounter, 0];
bottomsidey = yvalues[xcounter, size - 1];
avgtopbottom = (topsidey + bottomsidey) / 2.0f;
yvalues[xcounter, 0] = avgtopbottom;
yvalues[xcounter, size - 1] = avgtopbottom;
}
return yvalues;
}
[/CODE]

I'm not using slope-based texturing...just one big texture for each tile (2048x2048). A bit crude but effective. I used L3DT to make it for me.
0

Share this post


Link to post
Share on other sites
Im sorry, I cant really figure out whats the cause of your problem.
Here is the code I use to calculate normals (DirectX):

Cant post in sourcetags, buggy somehow:

// GET ALL DA NORMALZ!!!
std::vector<D3DXVECTOR3>* normal_buffer = new std::vector<D3DXVECTOR3>[chunkVnum];

for( int i = 0; i<chunkInum; i += 3 ){
// get the three vertices that make the faces
D3DXVECTOR3 p1 = vertices[indices[i+0]].pos;
D3DXVECTOR3 p2 = vertices[indices[i+1]].pos;
D3DXVECTOR3 p3 = vertices[indices[i+2]].pos;

D3DXVECTOR3 v1 = p2 - p1;
D3DXVECTOR3 v2 = p3 - p1;
D3DXVECTOR3 normal;
D3DXVec3Cross(&normal, &v1, &v2);

D3DXVec3Normalize(&normal, &normal);

// Store the face's normal for each of the vertices that make up the face.
normal_buffer[indices[i+0]].push_back( normal );
normal_buffer[indices[i+1]].push_back( normal );
normal_buffer[indices[i+2]].push_back( normal );
}


// Now loop through each vertex vector, and avarage out all the normals stored.
for( int i = 0; i < chunkVnum; ++i )
{
for( int j = 0; j < normal_buffer[i].size(); ++j ) {
vertices[i].normal += normal_buffer[i][j];
}

vertices[i].normal /= normal_buffer[i].size();
D3DXVec3Normalize(&vertices[i].normal, &vertices[i].normal);
}


May it can help you in some way ;/
How do you load the heightmap on the chunk if you calculate x and z with the effect? Edited by gnomgrol
0

Share this post


Link to post
Share on other sites
Without looking into the code in detail, I assume you only use one block's geometry to calculate the normals. But the normals are affected by the neighbor blocks' geometry too.
1

Share this post


Link to post
Share on other sites
You should really use 2049x2049 textures, with a one pixel overlap on adjacent edges. This would solve this and other problems.
0

Share this post


Link to post
Share on other sites
To be more clear...the heightmap texture is only 256x256. The diffuse texture is 2048x2048. I have attached my terrain code (not everything, just terrain)...maybe that will help.
[quote name='szecs' timestamp='1340696124' post='4952933']
Without looking into the code in detail, I assume you only use one block's geometry to calculate the normals. But the normals are affected by the neighbor blocks' geometry too.
[/quote]
That makes sense. I guess I could just stitch a seam of quads between blocks but then I would not be able to translate them later...in order to give the illusion of infinite terrain.

[attachment=9661:terrain.zip]
0

Share this post


Link to post
Share on other sites
mark ds' suggestion is good, even if (s)he misunderstood you. I think the best thing is to use overlap on the block borders. Better than fetching data from another block (because there is a reason for using blocks instead of one block)
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0