Crunched the shader and 3d renderer even more. It can draw 32X32x3 cubes (3000 approximately) at a frame rate of about 46 FPS.
I imagine it won’t lag at all once I implement the system so it only renders the faces pointed towards you! right now it is rendering every face of every cube, even though a maximum of three faces per cube a visible at a time and the entire field is only displayed if you are standing in the corner…
And then I can cut it down even more by using LOD.
Amazing stuff, @KMEB. It looks like you are doing frustum culling, are you also culling internal volumes?
I believe @John wrote a system a while ago that just constructed a surface out of visible cubes, so the internal ones weren’t rendered until you destroyed the top layers.
Right now, Codea renders all faces, but I believe @Simeon mentioned he might add glPolygonMode and glCullFace functions.
Calculating back faces in software will most likely have much more of a performance hit than just drawing them.
Also, I’m not sure how you’re building your mesh() (although I don’t think you’re using one mesh per cube, since you’re drawing 3000).
Are you doing any culling based on what is on the screen ?
If not, then all boxes are computed and pushed to be displayed, even if they’re not drawn. It can be pretty expensive, so you might want to implement a tree structure fitting your needs to test against the view frustum, so that only the visible meshes will be computed and pushed.
The system is almost comically simple. I’ve added e most basic selective face rendering and brought the max cube number with FPS over 40 up to about 10000.
Im not using the mesh function at all in this project- I’ve used the sprite() function exclusively.
I’m going to be implementing a system to only render objects that would show up on camera right now.
The real trick, I’ve found, is to precalculate everything.
After I finish that part, I’ll make a stage designer, and then probably release the code,
Very nice work!
Once upon a time there was a way to simply share project in the far far away kingdom of Codea 3.x. But a very bad queen (let’s call her Cruellapple) decided to kill it because she wanted to be sure to keep all the money for herself. So now the best way to share projects is:
create a github account (free and simple, i could do it).
longpress on you project in codea and choose ‘copy’.
create a public ‘GIST’ in github (not a ‘git repo’, this doesnt work from the ipad). Paste your code in it.
copy and paste the URL in the safari adress bar.
paste this URL in this forum.
then we can easily copy the raw code, and paste it in a new project in codea. Long press on the + project in codea will propose to restore all the tabs when creating the project if there is code in the clipboard.