-
I drew two circles. To increase the z-index of the first circle, I tried to modify its depth, but it seems that the background color has become strange. https://codepen.io/ouzhou-the-bashful/pen/YPKRbXz I tried adjusting the blend parameters, but I haven't found a solution yet. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
You have the wrong offset { shaderLocation: 2, offset: 8, format: "float32" }, // depth should be { shaderLocation: 2, offset: 12, format: "float32" }, // depth note that the normal way to do this is without a depth buffer. Just draw things in order, back to front. That's what the browse does with CSS. |
Beta Was this translation helpful? Give feedback.
Yea, sorting is no fun but it's in most solutions for this kind of thing.
One idea: You're storing much of the data in a vertex buffer which means it's always going to be used in the same order. If you use a storage buffer, then you can choose the order since you can randomly access the data. That means, all you'd have to do is pass in a sorted array of indices. Use
effectiveIndex = sortedIndices[instance_index]
or something like that and then accesss the data you have now in a vertex buffer, in a storage buffer instead.It's probably not worth it. Your circles are only 4 values right now (x, y, depth, size). But just passing it on.
I'm not su…