Jump to content



calculate texture coordinates

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

#1 arkerone   Members   -  Reputation: 100

Like
0Likes
Like

Posted 25 February 2012 - 09:57 AM

Hello everyone,
I created a map using a heightmap and i have a question
how to correctly calculate texture coordinates for a texture that will be repeated on my map?

Thx!Posted Image

Ad:

#2 kauna   Members   -  Reputation: 384

Like
0Likes
Like

Posted 25 February 2012 - 10:26 AM

Hi,

You can use the position of the vertex multiplied by some factor to get a texture to repeat over the terrain.

If you are using shaders you may so something like this in the vertex shader:

out.texcoord.xy = world_space_position.xy * factor;

where factor tells how many times the texture is repeated per 1 unit. If your units are meters and the factor is 1 , then the texture is repeated once every meter.

Cheers!

#3 arkerone   Members   -  Reputation: 100

Like
0Likes
Like

Posted 25 February 2012 - 11:49 AM

Thx , i have another problem, the texture isn't the same color as on my original image. an idea of the problem?

#4 kauna   Members   -  Reputation: 384

Like
0Likes
Like

Posted 25 February 2012 - 12:15 PM

Hi,

Can you be a bit more specific? Like are the colors totally different than you expect (for example some of the RGB channels are swapped) or the texture is too bright / too dark (for example issue with gamma correction).

A screen shot also could help out a lot. Like, what you have and what you are supposed to have.

Cheers!

#5 arkerone   Members   -  Reputation: 100

Like
0Likes
Like

Posted 25 February 2012 - 12:43 PM

My texture :
Posted Image

And my map with the texture, the color is different :

Posted Image

#6 arkerone   Members   -  Reputation: 100

Like
0Likes
Like

Posted 25 February 2012 - 12:47 PM

I fix this problem with
DXUTSetIsInGammaCorrectMode(false);


#7 kauna   Members   -  Reputation: 384

Like
0Likes
Like

Posted 25 February 2012 - 12:59 PM

View Postarkerone, on 25 February 2012 - 12:47 PM, said:

I fix this problem with
DXUTSetIsInGammaCorrectMode(false);

Probably that's enough for now, but if you want to do things correctly, you should load your diffuse textures using the sRGB flag.

Cheers!






We are working on generating results for this topic
PARTNERS