Not work in progress anymore. Use turbowarp if you enjoy resolutions higher than 15 scratch units and framerates higher than 7fps: https://turbowarp.org/1035370397 Mouse - look Arrows - look R, F - roll W, A, S, D, Q, E - move Hover your mouse at the top of the screen to see framerate and change resolution. I'm currently experimenting with some raster 3d stuff that can be used to make a game engine/game. This engine is right now super-simple and super-slow, but I hope to be able to improve the performance (mostly tri-filler optimizations). The lighting has to be pre-baked into the texture using some 3D software (I use Blender), though I'm thinking of adding a (Blinn-)Phong shader in the future (?), just to have something that is different from the other engines on Scratch :) And also I'll probably have to rewrite the tri rasterizer completely because there are holes in the tris and strange black areas everywhere. And it's also too slow, I just chose the most intuitive solution for these first tests.
Inspiration from @alltrue and @awesome-llama These articles were helpful with all the 3d rotation stuff: https://en.wikipedia.org/wiki/Rotation_matrix https://en.wikipedia.org/wiki/Matrix_multiplication https://danceswithcode.net/engineeringnotes/rotations_in_3d/rotations_in_3d_part1.html (I have to admit I don't understand it completely myself, I just copied the formulas.) This article was helpful when trying to understand perspective correct z and uv interpolation: https://www.scratchapixel.com/lessons/3d-basic-rendering/rasterization-practical-implementation/visibility-problem-depth-buffer-depth-interpolation.html And this one for the barycentric coordinates: https://users.csc.calpoly.edu/~zwood/teaching/csc471/2017F/barycentric.pdf All code by me. Suzanne model not by me (obviously).