Jump to content

Scrolling and scaling textures, How is it done?


BGerman
 Share

Recommended Posts

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

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!

Link to comment
Share on other sites

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

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!

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...