Hi all,
A quick bug I just found regarding material z-offset & the depth peeler, here is the PG:
The problem seems to arise only for materials with alpha & a z-offset.
It is not in the known limitations, so I guess it should be posted here.
Hi all,
A quick bug I just found regarding material z-offset & the depth peeler, here is the PG:
The problem seems to arise only for materials with alpha & a z-offset.
It is not in the known limitations, so I guess it should be posted here.
Adding @Evgeni_Popov who can help with OIT.
The depth peeler only deals with transparent objects. When you set alpha=1, the material is not transparent anymore and the corresponding mesh won’t be handled by the depth peeler. You can set alpha to 0.9999 instead if you want it to appear as solid but still be handled by the depth peeler.
Sure, sorry not to be clear enough then.
My goal is that I would like to avoid Z-fighting by adding a z-offset to some carefully choosen mesh materials.
This works like a charm without the depth peeler or with it and alpha = 1 (which is the same as you mentionned). But as soon as the depth peeler is on AND material’s alpha are < 1, z-fighting comes back, as if it was ignoring the z-offset value.
I hope you can see the problem in the PG now, z-fighting should be nowhere to be seen on the left and right cases.
Indeed, the shader code that handles z-peeling itself does depth comparisons and I suppose the calculation should be updated to take z-offset parameters into account. However, I’m not sure how to update this code, and we’d have to pass two new parameters (zOffset
and zOffsetUnits
) to the shader, because these are currently only used by the underlying graphics system (WebGL or WebGPU) without the shader knowing.
This seems a little complicated for such a specific case, as you should try not to use zOffset
in the first place, because zOffset
is often not sufficient to correct all artifacts due to coplanar geometries. Using a reverse depth buffer may help here (but won’t solve all problems), but it only works in WebGPU:
You should really try not to have coplanar geometries in your scene…
So this bug may be in fact just a “known limitation”.
Let me be more specific then about what I try to achieve.
In fact I would like to render some choosen edges on top of meshes.
The main feature I need for performance reasons is to reuse the position buffer from the base mesh to create the line mesh. This lie mesh can then be zOffset.
Here you can find a PG showing what I mean:
You can find 2 bugs (among 4 issues) in my opinion:
What’s your opinion? Are they truly unexpected behaviours?
Yes, no AA and no zOffset support are current known limitations.
Regarding:
- OIT ON, alpha OFF then alpha ON again → the lines are not depth tested anymore.
When you re-set alpha=0.75, you also set it to the line materials, so now the lines are also considered transparent. As they are drawn after the cubes, they appear in full color. You should exclude the line materials when updating the alpha color:
- OIT OFF: zOffset not working on lines
Yes, it’s a WebGL (OpenGL) limitation, it does not work for lines / points.
Oh sure you’re right, sorry for the mistake regarding the third case
Ok so we can conclude that none of this is possible, and registered as limitations.
Thanks very much for your help and your time, I’m very grateful.