• Advertisement

Archived

This topic is now archived and is closed to further replies.

texture coor

This topic is 5189 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there I have a terrain map that i use indices to draw. The index buffer creates blocks for culling, there is only one index buffer that is used.I then use drawindexprimitive and the basevertexindex value to navagate the array of vertices(Only works in hardware vertex processing).The problem is texture coordinates.Is it posible to get a texture that is the same size or larger than the map to lay across the map evenly.(instead of tileing a texture) I use something like this for the blocks but it shrinks the map TexU = (float)((float)PosX / TILE_SIZE)/(float)uiGroundWidth; TexV = 0.0f;

Share this post


Link to post
Share on other sites
Advertisement
I''m a little confused. You are setting TexV to 0 always?

You can stretch a texture over the entire terrain anytime, as long as the top left corner texture coord of the terrain is at (0,0) and the bottom right corner texture coord is at (1,1).

The higher the resolution of the texture, the better it will look of course. Your hardware will only support textures up to a certain resolution. I think I''ve read that about 2048x2048 as a max is typical now days, not sure.

Chris

Share this post


Link to post
Share on other sites
quote:
Original post by Supernat02
I''m a little confused. You are setting TexV to 0 always?

You can stretch a texture over the entire terrain anytime, as long as the top left corner texture coord of the terrain is at (0,0) and the bottom right corner texture coord is at (1,1).

The higher the resolution of the texture, the better it will look of course. Your hardware will only support textures up to a certain resolution. I think I''ve read that about 2048x2048 as a max is typical now days, not sure.

Chris


I am sorry its

TexU = (float)((float)PosX / TILE_SIZE)/(float)uiGroundWidth;
TexV = (float)((float)colomn / TILE_SIZE)/(float)uiGroundWidth;

each vertex of the block gets a different texture coor that is suppose to corrospond to the position in the texture;
this is just a test i removed some code but it shows where i am going


for(wz = 0; wz < uiBlockWidth; wz++)
{

for(wx = 0; wx < uiBlockWidth; wx++)
{
pVertices[a].tu = (float)((float)a * TILE_SIZE )/(float)m_uiGroundWidth;
pVertices[a].tv = (float)((float)wz * TILE_SIZE )/(float)m_uiGroundWidth;


a++;
b++;
c++;
}



i am not sure if this is right can you explane the process.

Share this post


Link to post
Share on other sites
Hi again

i will try and explane what it is i am doing;

if i draw a patch of my terrain, i want the patch to draw that section of the texture.
So texV = (1.0 / texturewidth)* patch_vertex_position would be the position in texture.If this is wrong please give me an idea

Share this post


Link to post
Share on other sites
Hi again
i finally got the texture to draw evenlly but now the terrain seems to be fixed to screen size the spaceing var for the vertex positon no longer has an effect .





for(z = 0; z <= m_uiGroundWidth; z++)
{

for(x = 0; x <= m_uiGroundWidth; x++)
{

pVertices[i].v.x = (x * TILE_SIZE) - (float)(m_uiGroundWidth / 2);

if((z == 0.0) || (z == m_uiGroundWidth) || (x == 0.0) || (x == m_uiGroundWidth))
{
pVertices[i].v.y = 0.0;
}
else
{
//Set height for y

pVertices[i].v.y = m_acHeightMap[(int)z * m_uiGroundWidth + (int)x] / 3;
}

pVertices[i].v.z = (z * TILE_SIZE) - (float)(m_uiGroundWidth / 2);

pVertices[i].tu = z / (float)(m_uiGroundWidth);
pVertices[i].tv = x / (float)(m_uiGroundWidth);

i++;
}
}

Share this post


Link to post
Share on other sites

  • Advertisement