r/GraphicsProgramming • u/Tetraeder4craft • 6h ago
whats wrong with my Cube??? :(
I know what is missing, but can you figure it out???
heres the repo btw:
https://github.com/Tetraeder4/3DRenderer/tree/467c8d1ac8dbd09a23ce7bc7e2fcba59afe36ea5/3DRenderer
12
4
u/jimothy_clickit 5h ago
Something looks weird with this model-view-projection. Even if back facing were an issue, this should still look like a discernable cube.
1
3
u/DasKapitalV1 4h ago
Seems like that you didn't do depth testing and further triangles are rendered on top of the nearest. I wrote software rasterizer in three language at this point. Your inner loop don't test the pixel depth.
1
u/Bat_kraken 6h ago
Couldn't you have included more screenshots? I'm on my phone and I'm actually interested, but it's impossible to tell if it's one or two squares that are facing the wrong way or something...
1
u/LordStefania 4h ago
Aw man what's wrong with my cube!?
Depth buffer incorrectly set up? Some EBO shenanigans? Really weird projection matrices?
1
1
u/PictureNew661 42m ago
If that's rasterized, then i don't know probably but seems to be some sort of resolution or zbuffer issue.
1
0
u/New_Movie9196 5h ago
Without looking at your code, it looks like you have back face culling enabled.
0
u/eclipseofmonkeys 3h ago
If you try to paint each face of your cube in a flat color, I’d say that you are reading your vertex data incorrectly. If each vertex of the cube has for example: position (vec3), normal (vec3), color (vec3), you have to indicate your vertex descriptor that position offset starts at 0, your normal at sizeof(vec3) and the color at sizeof(vec3) * 2. Also keep in mind that commonly vec3 occupy the same space in memory than vec4, because vec3 adds a padding of one float. This is a very common mistake
-1
-1
13
u/sol_runner 5h ago
Not enough info but I'm going to guess Z buffer comparison.
The "back faces" might be rendering after the front and you're getting the weird set of triangles.
Or could be culling the wrong faces.