Depth sorting breaks on mobile device in viewportframe

Hey,

I have a title screen in my game using a ViewportFrame to create a 3D text effect, consisting of blocks falling down to form the name of the game. The camera is placed far away with a low field of vision to create an isometric effect.

On most platforms where I test, everything looks correct:

However, when I test on my S8+, the depth sorting gets consistently messed up, presumably due to some limitation with how floating points are handled; this is one specific example:

Another possible scenario is that, since each letter is built of individual block parts, sometimes they can incorrectly show their hidden faces through each other:

To be more specific, this is the code which sets up the camera for that viewportframe:

	local isoCamera = Instance.new "Camera"
	isoCamera.FieldOfView = 1
	isoCamera.Focus = CFrame.new(0, 8, 0) 
	isoCamera.CFrame = CFrame.new(Vector3.new(1, 0.8165, 1) * 3000 / isoCamera.FieldOfView, isoCamera.Focus.p)
	isoCamera.Parent = script

And this is the viewportframe containing the model:
logoviewportframe.rbxm (5.5 KB)

Is this possible to fix or improve, or is this unfixable? I would prefer not to sacrifice the isometric effect as it’s used across lots of promotional material.

Thanks in advance :slightly_smiling_face:

4 Likes

This is not a ViewportFrame specific problem. Even the main scene has the same issue. Because the depth buffer precision is not enough for those far away object. We can’t fix it now. But in your case you can try to increase the blocks’ transparency to 0.05 then they will be rendered in order of distance to camera.

1 Like