Jump to content

Using Arrays With ShaderMaterial


AlexB
 Share

Recommended Posts

I notice that there's a setTextureArray method, but I don't see any corresponding methods for vec2s, vec3s, etc. 

As an example, if I want something like:

(Typescript)

const offsets: Vector2[] = [
new Vector2(1, 1),
new Vector2(2, 1),
new Vector2(3, 1),
new Vector2(4, 1),
]

And I want to be able to use this in my shader, like this:

(GLSL)

uniform offsets vec2[4];

for (int i = 0; i < 4; i++) {
 vec3 tex = texture2D(sampler, uv * offsets[i]);
// do something awesome here
}

I don't see any easy way to do it. Any clues?

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.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...