LeDark Lua, on 17 November 2015 - 12:35 PM, said:
Simple fix with z coordinates:
for i=1, #world do
for pol, _ in pairs(world[i]) {
if pol.z>0 then
--Draw polygons
end
}
end
I do cull triangles that are outside the render region, but I was under the impression that the z coordinate was between -1 and 1 - though I might be mistaken - everything does break when z reaches 0. I'm kinda stuck on this, because if z > 0, then you are dividing the x and y coordinates by a negative number, so the image is going to flip. This doesn't matter if the entire polygon is outside, but if one point's z > 0 and the other points aren't, then everything blows up.
ardera, on 17 November 2015 - 12:44 PM, said:
There's Frustum Culling, that not only fixes this, but also excludes things that are not in your Field of View, alias "View Frustum". This will improve performance, but it takes some time to implement. Minecraft uses Frustum Culling too.
The code I'm currently is a mixture of GlesCraft and my own Minecraft clone. The both
implement some form of frustum culling, as does this, its just
commented out at the moment because I think it is broken.
ardera, on 17 November 2015 - 12:44 PM, said:
Are you using a Z-Buffer? I got some ideas on how to implement partly transparent polygons. (Transparency is not possible with standard Z-Buffers)
That would be awesome! Transparency does work, you just have to sort the polygons which is a pain. I did some reading on order independent transparency but got confused.
ardera, on 17 November 2015 - 12:44 PM, said:
Also, there's another performance improvement I have, if you're not already using it: Since most polygons in the world space share some vectors, you can give vectors with exactly the same position an index, and apply the transformations for every index. This way you don't transform the same point more than one time.
Already doing this - though the matrix transformations are pretty minimal, I guess it would add up.
Edited by SquidDev, 17 November 2015 - 01:20 PM.