Jump to content

Recommended Posts

Posted (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 by BGerman
Posted

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.

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!

Posted

Just multiply the texcoord with a number in the shader, and you have scaling. Add a number to it for offseting the coord.

  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

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);

  • Upvote 3
Posted

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.

  • Upvote 1

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!

Posted

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 ?

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...