groverburger / g3d

Simple and easy 3D engine for LÖVE.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Z order and aspect ratio

IS4Code opened this issue · comments

commented

The Z order of vertices in the example file is inverted, unlike in the screenshots in the repo:
image

Additionally, the rendering aspect ratio is incorrectly set: squares appear as rectangles:
image

Rotated 90 ° to the right:
image

Tested on the latest version of LÖVE.

commented

Aspect ratio problem was fixed by setting the aspect ratio by default to love.graphics.getWidth()/love.graphics.getHeight(). You can however change your own aspect ratio by modifying line 50 of camera.lua, or doing something like this:

Camera.aspectRatio = some number
CameraShader:send("projectionMatrix", GetProjectionMatrix(Camera.fov, Camera.nearClip, Camera.farClip, Camera.aspectRatio))

Your Z ordering problem seems to be specific to your situation, I'm unsure of the solution and have not encountered the same problems with others. You can however set the depth mode to try to fix this issue, g3d by default initializes the depth mode as such: love.graphics.setDepthMode("lequal", true)

Hope that helps, I'm now closing this issue.

commented

Thanks for fixing the aspect ratio, but the second problem still persists. I have tried all values for setDepthMode, but it has no effect.

It also persists for the new example:
image

I was a bit imprecise - the Z order isn't simply inverted, it almost seems simply ignored. Objects are drawn in front of each other regardless of their distance from the camera. The moon here is always drawn first, but the issue seems to happens on the polygon level.