ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Without knowing exactly what you want to do, there is no one formula I can give you. Especially with a perspective projection where things further away are going to be smaller. Take for instance a textured quad that is right up by the near clip plane. Say the near clip plane is big enough to create a 4x4 tile of your texture if you calculate it pixel-by-pixel. Now when you start moving that quad back, if you still want it to be exactly pixel-by-pixel, you are going to have to change the texcoords. If you don't it will still be a tiled 4x4 texture, but it will just get smaller as you move further away.
It seems highly unlikely that what you really want is for it to display the texture's pixel data at the same size no matter what the distance, but without knowing more I really can't say for sure. It seems more likely that you have an object that you want to have the texture repeated across x number of times. In that case, you just supply the desired texture coordinates.
But how will I know how much times I want it to repeat? Don't you know how this is done in games? Is it hardcoded?
I just don't know how to do this. Should I hardcode it or use any formula.
What do you advise?
Without knowing exactly what you are texturing, I can't give you any one answer to your question. In most cases, you just know... Like say you are texturing the floor of a room. You probably don't want those texture coordinates changing on you or it won't look very realistic. How many times should you make it repeat to make it look good? Well... that depends on what your texture looks like, how big the floor is, and any other number of variables. Certain patterns will look good, others will not. You have to figure out what will look good and go with that. It's all really subjective.
Typically, in games, the texture coordinates are stored as part of the model information. The texture mapping is done with a modeling program of some sort, and then those texcoords are loaded up and used in the game. There are a few cases where texcoords might be dynamically generated; sky maps, tesselating models further using some level of detail algorithm, etc.
Thanks, deiussum.
I've just understood that we'll be using models from Blender, so there'll be no need to texture ready models. They'll be textured in Blender.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.