BGerman Posted December 7, 2012 Share Posted December 7, 2012 (edited) I have been trying to scale a texture on a cube, but i'm not having luck so far. Is there any way i can access the UV mapping and change it ingame to scale the texture? (repeating textures) Thank you all, I already solved the problem. Solution is below on post #8. Edited December 7, 2012 by BGerman Quote Link to comment Share on other sites More sharing options...
fumanshoo Posted December 7, 2012 Share Posted December 7, 2012 Isn't there a function like TextureHeight and TextureWidth? yes, there is... http://www.leadwerks.com/wiki/index.php?title=Textures#TextureWidth I have not used that before but I think it will be helpful for what you're doing... Quote Link to comment Share on other sites More sharing options...
BGerman Posted December 7, 2012 Author Share Posted December 7, 2012 Yes, those functions do return the texture width and height, but it does not allow me to change it. Its some sort of getter from what i see Quote Link to comment Share on other sites More sharing options...
fumanshoo Posted December 7, 2012 Share Posted December 7, 2012 eh sorry. Like I said, I have not used them before, I have no idea how to use them haha Quote Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted December 7, 2012 Share Posted December 7, 2012 If you mean scrolling and scaling textures on a mesh then there is no simple command for it. You either need to make a shader to do it (though I don't know how myself).. Or you need to change the texture every frame to make an animated textures. It is possible to change the UV's of an object to scroll and scale a texture on a mesh. However, this is incredibly slow... I think it's possibly the slowest thing that a graphics card can do so I wouldn't recommend it. Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
BGerman Posted December 7, 2012 Author Share Posted December 7, 2012 Yes, i think it can be done with a shader too, i will continue investigating and see what i can come up with. Quote Link to comment Share on other sites More sharing options...
Josh Posted December 7, 2012 Share Posted December 7, 2012 Just multiply the texcoord with a number in the shader, and you have scaling. Add a number to it for offseting the coord. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
BGerman Posted December 7, 2012 Author Share Posted December 7, 2012 Great! Thank you so much for pointing me in the right direction Josh. For anyone who is interested, i managed to get the results i wanted. Since i use the "mesh.vert" shader on most of the objects, i went to experiment with it. I first renamed shaders.pak to shaders.zip to access the shaders. I added scale and offset uniform variables: uniform vec2 texscale = vec2(1.0,1.0);; uniform vec2 texoffset; and modified two lines of code to add, and multiply the texcoords: texcoord0=gl_MultiTexCoord0.xy*texscale+texoffset; texcoord1=gl_MultiTexCoord1.xy*texscale+texoffset; To access, scale and offset textures i use: SetShaderVec2(shader,"texscale",Vec2(scaleU,scaleV)); SetShaderVec2(shader,"texoffset",Vec2(scrollU,scrollV)); And it works great. Any suggestions or questions are welcome. Note that this will affect the material you grabbed the shader of, using: TShader shader=GetMaterialShader(yourMaterial); 3 Quote Link to comment Share on other sites More sharing options...
Josh Posted December 7, 2012 Share Posted December 7, 2012 Quick learner! That's exactly how it's done. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted December 7, 2012 Share Posted December 7, 2012 Nice one! I've been staying away from cosmetic things so far in the development in my game and concentrating on mechanics and game play but the time is coming soon when I will be doing stuff like this so it's great to know. 1 Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
joachim Posted December 7, 2012 Share Posted December 7, 2012 Texture mapping and using a texture atlas seems to be a complex subject. I will have to change textures at run time using a texture atlas and would appreciate a detailed tutorial about it. What do you think Josh ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.