目前我正在做3D投影和渲染的第一次經歷。因此,我使用lövelua(ik,不是3D的最佳平臺),並且我可以完美呈現所有多邊形(僅三角形)。因爲按照到攝像機的距離排列多邊形表是一項任務,這需要花費大量時間,因此我正在爲此實現一個z緩衝區。但我不太清楚如何做到這一點。我知道這些原理,但是如何找出三角形中某個點與相機位置的距離? 我目前的解決方案聽起來像這樣:實現z緩衝區的好方法
translate edge points of the triangle to 2D points ->
create polygon of those ->
for every pixel in the polygon: ->
translate 2D point back to 3D vertex (somehow) ->
calculate distance of vertex to camera position ->
if distance is bigger than zbuffer entry, overwrite zbuffer entry and
set pixel to polygon color
這聽起來確實效率低下。我如何加快速度?有沒有人有更好的方式來實現zbuffering?
我認爲你的愛意味着love2d,如果不是的話,可以刪除該標籤 – Schollii