6 ms·
I don't think your algorithm is correct. At least on the checkerboard example on the cube face the diagonals are curved. Perspective transformation doesn't do t
by badmintonbaseba 1y ago
I don't think your algorithm is correct. At least on the checkerboard example on the cube face the diagonals are curved. Perspective transformation doesn't do that.
Possibly you do the subdivisions along the edges uniformly in the target space, and map them to uniform subdivisions in the source space, but that's not correct.
edit:
Comparison of the article's and the correct perspective transform:
https://imgur.com/RbRuGxD https://imgur.com/RbRuGxD
- Karliss 1y agoConsidering that the author considers math below his pay-grade not a huge surprise that it is wrong.
- frizlab 1y agoYES! I was taken aback by that statement too. I think the opposite: in this age of AI, actually knowing things will be a huge bonus IMHO.
- fc417fc802 1y ago> math below his pay-grade Completely backwards. Math is much more difficult than programming and LLMs still can't consistently add numbers correctly last I checked. What a strange attitude to take.
- jeremyscanvic 1y agoAlso known as the good ol' straight lines remain straight in perspective drawing!
- ricardobeat 1y agoIs it actually possible to draw the correct perspective using only affine transformations? I thought that was the point of the article.
- badmintonbaseba 1y agoIt is possible to approximate perspective using piecewise affine transformations. It is certainly possible to match the perspective transformation at the vertices of the subdivisions, and only be somewhat off within.
- itishappy 1y agoWith 6 degrees of freedom, you can only fit 3 2d points at a time. Triangulation causes the errors shown in the article, hence why subdivision is needed.
- jeremyscanvic 1y agoI think GP's point is that besides the unavoidable distortions coming from approximating a perspective transform by a piece-wise affine transform, the implementation remains incorrect.
- mistercow 1y agoEven more obviously, the squares in the front aren’t bigger than the squares in the back. It looks like each square has equal area even as their shapes change. It’s fascinating how plausible it looks at a glance while being so glaringly wrong once you look at it more closely.
- seveibar 1y agoI've updated the article with the fixed projection transform! I had to make an animation as well just to validate it- I fooled myself!
- jeremyscanvic 1y agoThe fixed rendering looks really nice. Good job!
- mistercow 1y agoVery nice! I wasn’t even sure that the approach could be fixed without major rethinking. Great job figuring that out.
- seveibar 1y agoAuthor here: I don’t think the commenter here has set the same focal length, the focal length can make a surface appear curved, I set it explicitly to a low value to test the algorithm’s ability to handle the increased distortion. You can google “focal length distortion cube” to see examples of how a focal length distorts a grid or you can google “fish eye lens cube” etc. Edit: I think there’s a lot of confusion because the edges of the cube (the black lines), do not incorporate the perspective transform all along their edge. The texture is likely correct given the focal length, and the cube’s edge is misleadingly straight. My bad, the technique is valid, but the black lines of the cube’s edge are misleadingly straight (they are not rendered the same way as the texture)
- Masterjun 1y agoI think the original commenter is correct that there is a mistake in the perspective code. It seems the code calculates the linear interpolation for the grid points too late. It should be before projecting, not after. I opened an issue ticket on the repository with a simple suggested fix and a comparison image. https://github.com/tscircuit/simple-3d-svg/issues/14 https://github.com/tscircuit/simple-3d-svg/issues/14
- seveibar 1y agoThat admittedly looks a lot more correct! Thanks for digging in, i will absolutely test and submit a correction to the article (i am still concerned the straight edges are misleading here)! And thanks to the original commentor as well! I think I will try to quickly output an animated version of each subdivision level, the animation would make it a lot more clear for me!
- deleted 1y ago[deleted]
- jeremyscanvic 1y agoI might be missing something but you sound genuinely confused to me. The perspective in your post is linear perspective. It's the one used in CSS and it doesn't curve straight lines/planes. It's not the perspective of fish-eye images (curvilinear perspective).