Wireframe material issue

wireframe
materials

#1

I’ve implemented a fixed buffer chunk pool for a engine i’m working on. It works fine so far, but the wireframe material seems to get messed up. Once a batch is dropped (geometry not rendered anymore) it’ll push buffers back to a worker, incoming will then replace the array of the buffer attribute (recycle, not copy). It works fine with own shaders but the wireframe seems to use wrong buffer references or something.

Here’s a short clip, after first batches get reused the wireframe of reused ones will get messed up but partially remain fragments or their last state, while the same mesh will look correct applying other shaders. I wonder if it’s any issue grabbing the buffer attribute arrays and transfering out of main thread, or references for the renderer somewhere. (wireframe messes up the quality, sorry)


#2

Yeah, there may be an issue with the internal buffer for wireframe not updating when the geometry changes. I guess we need to look for index.needsUpdaet and position.needsUpdate?

Any chance you could create a jsfiddle testing this?


#3

Thanks for your reply. All are flagged to update, it seems it was a similar issue with the element count in BufferAttribute, i recently said in a issue. I use WebGL2 and adapted the renderer for it, the most extensions are native now so i removed a lot here too, and there was a bug i spotted, but that didn’t fixed it in the first place. I need to further investigate everything to tell what was the exact issue.


#4

@mrdoob @lekxi Also just experienced this issue.

Will make a codepen/jsfiddle demo highlighting the issue as soon as I can.


#5

@robnov actually it appeared again.

It appears it might be in WebGLObjects in getWireframeAttribute. When wireframe is used a extra index buffer is generated and cached for this geometry, but it seems it won’t get updated.

@mrdoob i see what you meant. Wouldn’t it be easier to use a shader that renders wireframe with barycentric coordinates? This wouldn’t require an extra buffer i didn’t even noticed before, but i did noticed a short lagg when first switching to wireframe. It would give smooth lines with depth and the possibility to render above solid shading.


#6

Doing it in the shader doesn’t look as crisp:
https://threejs.org/examples/#webgl_materials_wireframe