I am currently working on building a 3d engine using love as a frame work. Currently I am following this tutorial series here by javidx9:
https://www.youtube.com/watch?v=ih20l3pJoeU
https://www.youtube.com/watch?v=XgMWc6LumG4&t=967s
the second link includes the timestamp where I started experiencing my problem
So far I haven't had any issues; however, I did have some qualms with how love was drawing triangles. When my cube was rotating I saw some slight artifacting. It got worse when I tried to draw the cube so that it only draws the faces that you can see. I checked on chatgpt and apparently this is just how love2d draws graphics on the screen. Is there a method that I can use to mitigate or outright solve this issue? At least in the scope of love2d.
test here:
Issues with 3D graphics and Artifacting in love2d
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Issues with 3D graphics and Artifacting in love2d
This is the main problem. Look closely, you're not squaring the z component correctly.
But you're also calculating the cross product slightly wrong, though you've compensated by negating the incorrect value so it actually works fine.
if copied verbatim from javid's repo should be
Code: Select all
l = math.sqrt(normal.x * normal.x + normal.y * normal.y + normal.x * normal.z)
Code: Select all
vec3d.new(line1.y * line2.z - line1.z * line2.y,
-(line1.x * line2.z - line1.z * line2.x),
line1.x * line2.y - line1.y * line2.x)
Code: Select all
vec3d.new(line1.y * line2.z - line1.z * line2.y,
line1.z * line2.x - line1.x * line2.z,
line1.x * line2.y - line1.y * line2.x)
Re: Issues with 3D graphics and Artifacting in love2d
Thanks for your insight! My main issue right now is just the artifacting(small "sparks" on the screen), but when I shade in the triangles with the fill operator, I don't see the issue anymore. Do you think love is still a good tool for what I am trying to do?marclurr wrote: ↑Thu Dec 19, 2024 12:04 am This is the main problem. Look closely, you're not squaring the z component correctly.
But you're also calculating the cross product slightly wrong, though you've compensated by negating the incorrect value so it actually works fine.Code: Select all
l = math.sqrt(normal.x * normal.x + normal.y * normal.y + normal.x * normal.z)
if copied verbatim from javid's repo should beCode: Select all
vec3d.new(line1.y * line2.z - line1.z * line2.y, -(line1.x * line2.z - line1.z * line2.x), line1.x * line2.y - line1.y * line2.x)
Code: Select all
vec3d.new(line1.y * line2.z - line1.z * line2.y, line1.z * line2.x - line1.x * line2.z, line1.x * line2.y - line1.y * line2.x)
Re: Issues with 3D graphics and Artifacting in love2d
I wasn't able to see any artifacts that looked like sparks but when i set the line mode to rough it sometimes looked like line segments were extending too far.
I changed the code to make three calls to love.graphics.line and this didn't produce the problem. There may be some quirks with the polygon function but I don't know enough to say anything useful.
If you're going to take this series to its conclusion you'll end up writing your own triangle rasteriser anyway so I wouldn't worry too much.
As for whether love is a good tool for what you're doing. I'd say it's fine. I'm not sure how practical a software 3D renderer is aside from an interesting learning tool though. Definitely continue with it but if you want to do any serious 3D work you can make use of the GPU very easily with love - I like to think of it as a premade OpenGL application with a nicer API.
If you really want to use a software renderer "just because" (which is a fine reason), you'll have a lot of optimisation to make it workable, which its self will be a worthwhile learning experience
I changed the code to make three calls to love.graphics.line and this didn't produce the problem. There may be some quirks with the polygon function but I don't know enough to say anything useful.
If you're going to take this series to its conclusion you'll end up writing your own triangle rasteriser anyway so I wouldn't worry too much.
As for whether love is a good tool for what you're doing. I'd say it's fine. I'm not sure how practical a software 3D renderer is aside from an interesting learning tool though. Definitely continue with it but if you want to do any serious 3D work you can make use of the GPU very easily with love - I like to think of it as a premade OpenGL application with a nicer API.
If you really want to use a software renderer "just because" (which is a fine reason), you'll have a lot of optimisation to make it workable, which its self will be a worthwhile learning experience
Re: Issues with 3D graphics and Artifacting in love2d
Thanks for the advice! I initially wanted to use OpenGL with c++ but it ended up being way too complicated just to draw a triangle on the screen. I assumed love2d would have been a better option for me since it has OpenGL prebuilt, and now since I know I could make better use of GPU rendering I can optimize my code even better! I will still continue on it, but for now I am using it as a prototyping tool in case I do want to build it in c++.marclurr wrote: ↑Thu Dec 19, 2024 7:11 am I wasn't able to see any artifacts that looked like sparks but when i set the line mode to rough it sometimes looked like line segments were extending too far.
I changed the code to make three calls to love.graphics.line and this didn't produce the problem. There may be some quirks with the polygon function but I don't know enough to say anything useful.
If you're going to take this series to its conclusion you'll end up writing your own triangle rasteriser anyway so I wouldn't worry too much.
As for whether love is a good tool for what you're doing. I'd say it's fine. I'm not sure how practical a software 3D renderer is aside from an interesting learning tool though. Definitely continue with it but if you want to do any serious 3D work you can make use of the GPU very easily with love - I like to think of it as a premade OpenGL application with a nicer API.
If you really want to use a software renderer "just because" (which is a fine reason), you'll have a lot of optimisation to make it workable, which its self will be a worthwhile learning experience
Who is online
Users browsing this forum: No registered users and 5 guests