Sign in to follow this  
arkerone

calculate texture coordinates

Recommended Posts

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![img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
My texture :
[img]http://img842.imageshack.us/img842/1281/terres.jpg[/img]

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

[img]http://img18.imageshack.us/img18/3974/problemecb.jpg[/img]

Share this post


Link to post
Share on other sites
[quote name='arkerone' timestamp='1330195677' post='4916544']
I fix this problem with [code]
DXUTSetIsInGammaCorrectMode(false);
[/code]
[/quote]

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!

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