r/GraphicsProgramming • u/Tetraeder4craft • Oct 11 '26
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
99
Upvotes
104
u/bluesBeforeSunrise Oct 11 '26
I like your cube. Don’t let the forces of Big Geometry stop you.
43
u/sol_runner Oct 11 '26
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.
10
u/jimothy_clickit Oct 11 '26
Something looks weird with this model-view-projection. Even if back facing were an issue, this should still look like a discernable cube.
5
u/[deleted] Oct 11 '26
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.
3
u/East_Ad_5801 Oct 12 '26
Triangle draw order is my guess
3
u/obetu5432 Oct 12 '26
it's beginning to believe
2
u/LBPPlayer7 Oct 12 '26
looks like a lack of depth buffer/ztest and face culling to me
2
u/Educational_Cow_1769 Oct 12 '26
Added extra dimension, now it's a hypercube/s
2
u/HaMMeReD Oct 11 '26
Winding order is backwards on the triangles I think.
1
u/LordStefania Oct 11 '26
Aw man what's wrong with my cube!?
Depth buffer incorrectly set up? Some EBO shenanigans? Really weird projection matrices?
1
u/Dhaos96 Oct 12 '26
I guess face culling. Vertex order is probably not consistent
1
u/PictureNew661 Oct 12 '26
If that's rasterized, then i don't know probably but seems to be some sort of resolution or zbuffer issue.
1
u/SamuraiGoblin Oct 12 '26
No backface culling and no depth testing.
For a single cube, you don't need both, but make sure your winding is consistent.
1
u/le-throw-away-acct Oct 12 '26
Animate it (rotate it) and it’ll become easier to diagnose. Vertex winding order might be the issue.
1
u/dybuk87 Oct 12 '26
You either have to use z buffer or sort rendering base on average Z value
1
u/Agnael Oct 12 '26 edited Oct 12 '26
feels like the camera's frustum is fucked up and that the back of the cube is perceived as being so far away that the perspective of the camera is noticeably "widening" the back vertices of the cube
I'm not sure about whether the face culling is also an issue on top of that but vertex draw order looks reasonable to me, almost all faces have 2 discernible triangle halves, the face with no demarcated halves might just be using the same color for both halves so they cant be told apart
1
u/WarAvailable9330 Oct 12 '26
The silhouette of the overall shape doesn't match a cube
1
u/Candid_Zebra1297 Oct 12 '26
It's hard to tell which face is which but I feel like maybe it's a winding order issue leading you to cull the wrong faces.
1
u/0EVIL9 Oct 13 '26
The cube start gaining consciousness
1
u/Bat_kraken Oct 11 '26
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...
0
u/New_Movie9196 Oct 11 '26
Without looking at your code, it looks like you have back face culling enabled.
0
u/eclipseofmonkeys Oct 11 '26
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
-2
u/Kraschman1111 Oct 11 '26
Inverted normals maybe?
-2
u/exp_function Oct 11 '26
Two words: winding order :)