three.js - Can I call a shader with a different array for each call or should I make multiple shaders? -


i'm trying determine best way handle custom dashed lines using shaders in three.js (webgl). there different patterns these dashed lines have. hope able write single shader handle kind of dash pattern. pattern given array of values (eg [0.125, -0.125, 0.250, -0.250]), negative value length of space, , positive length of dash.

i'm new shaders , i'm not sure if above possible. if understand correctly, uniform array not appropriate because want array change according pattern being drawn on particular line entity. don't think attribute array appropriate because seems array of values associate vertices. want possible or have dynamically make shaders each pattern?

am understanding correctly far? suggestions? first (and only) need work shaders.

you have use either uniform or attribute; there nothing “in between” 2 in webgl, , other possible implementations in end going depend on uniform or attribute (or constant) data.

  • if use uniform, can set dash pattern lines in draw call, not individual lines within it.

  • if use attribute, must duplicate selection of dash pattern each vertex in line. no different usual handling of e.g. colored lines, must give (same) color @ each vertex.

    if concern total data size, indirection such storing several dash patterns in uniform array or texture, , using attribute lookup desired pattern. allow use 1 number instead of 4 per vertex.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -