Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeat texture across a Plane? #37

Closed
leota opened this issue Apr 30, 2020 · 2 comments
Closed

Repeat texture across a Plane? #37

leota opened this issue Apr 30, 2020 · 2 comments

Comments

@leota
Copy link

leota commented Apr 30, 2020

Is it possible to repeat the same texture, on a Plane, across a specified axis?
Something like Three.js does: https://threejs.org/docs/#api/en/textures/Texture.repeat

Or what would be a possible workaround?

@leota leota changed the title Repeat texture across XY axis? Repeat texture across a Plane? Apr 30, 2020
@martinlaxenaire
Copy link
Owner

martinlaxenaire commented Apr 30, 2020

Hi @leota,

at the moment there is indeed no method to set a texture repeat values.
I had a quick look at this, this is definitely doable (by using texture scale values lower than 1 for example) but we'd need to test for non power of 2 textures when using a WebGL1 context and resize the texture like three.js does it. Seems a bit overkill to me for now.

Anyway you can achieve something similar by using this in your fragment shader:

// whatever repeat values you want, could be passed as a uniform
vec2 repeat = vec2(4.0, 4.0);
vec2 textCoords = vec2(mod(vTextureCoord.x * repeat.x, 1.0), mod(vTextureCoord.y * repeat.y, 1.0));

Let me know if that suits you.

Cheers,

@leota
Copy link
Author

leota commented Apr 30, 2020

Yeah, I was thinking that I could have been done in the fragment shader. Thanks a lot for the suggestion

@leota leota closed this as completed Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants