RE: 3D Part Preview added to Parts Tracker
2019-07-25, 6:59 (This post was last modified: 2019-07-25, 7:01 by Lasse Deleuran. Edit Reason: debt -> depth. The buffer does not owe anything. )
2019-07-25, 6:59 (This post was last modified: 2019-07-25, 7:01 by Lasse Deleuran. Edit Reason: debt -> depth. The buffer does not owe anything. )
(2019-07-24, 17:12)Travis Cobbs Wrote: I've never used WebGL, but for rasterizer-based 3D rendering in general (and OpenGL in specific), you typically need to draw the transparent objects last, not first. That's the only way opaque geometry behind them will be visible through them. Furthermore, you typically want to render the transparent geometry from back to front, not from front to back. Once again, that's so that the transparent stuff in back is visible through the stuff in front. (There is a technique called depth peeling that allows you to render transparent geometry in arbitrary order, but it has a maximum number of overlapping transparent polygons that can be drawn correctly.)You are right. It must be drawn back-to-front. And thanks for the pointers. I will look into the depth buffer fix and other algorithms to improve this aspect.
LDView sorts transparent polygons by default (although it does so in multiple threads), and the performance is usually acceptable, since the total number of transparent polygons is usually manageable. Certainly for displaying parts, sorting should be plenty fast. One thing that might improve the results for parts without requiring sorting is to disable Z-buffer writes during transparent polygon drawing. (Leave depth testing enabled, but don't update the depth buffer during transparent drawing.) With non-lit transparent polygons that are the same color, this would (I think) completely fix the problem. If two different colored transparent polygons overlap, the result could be wrong (although it might still be better than what you have now; you'd have to test).
My biggest issue is performance. I am used to write in C++, so the performance aspects of this all being written in Javascript (and GLSL) is an adventure!