Is it possible to use this with InstacedMesh?
trusktr opened this issue · 3 comments
For example either the one from three-instanced-mesh
, or the builtin THREE.InstancedMesh
? In particular, I would like each line to be instanced, but having different point values. Seems this may not be possible with the current InstancedMesh
classes.
I´m not sure you understand the idea behind instancing. It's useful to render multiple instances of the same mesh. If you want multiple lines, with different point values, there's really not a lot of advantages. And also, setting up instancing rendering is slightly more costly. Instacing could be used at a low level to render each individual segment of a line, but i don´t think there's a lot to win here.
I´m not sure you understand the idea behind instancing
I am familiar with instancing.
not a lot of advantages
If it is possible, 1 GPU call for 1000 lines would be better than 1000 GPU calls for 1000 lines.
I don't know three.meshline implementation enough. And I also don't know how feasible it would be to instance lines with such varying characteristics. Seems the shader would need to understand not only which part of a line it is operating on, but which instance it is operating on.
If all the lines have the same number of vertices, it could make sense.
Right now, as an alternative, adding some kind of segmentation in a big single geometry rather than instancing could work: if you need to draw a 1000 (different) lines, i would still create one single geometry, and add vertices like:
firstOfLine1 ... lastOfLine1, lastOfLine1, firstOfLine2, firstOfLine2, ... lastOfLine2, etc.
and set the width to be 0 in the segment lastOfLine(n-1)
to firstOfLine(n)
. The repeated vertices are there to make the transition look correct.
Just an idea.