resonte dabbles in 3d code

Author Topic: resonte dabbles in 3d code  (Read 4059 times)

turns out when you're starting from not much, the normal is pretty sensitive to the order of the input vertexes, which also screws up brightness

some earlier attempts had pretty janky-but-cool brightness effects because of it but i already fixed em and didn't record it


looks like sonic 3d blast


screwed up normals


mixed up line buffer with vertex buffer... the vertexes for the normal lines [2 vertexes] were instead being used as vertexes for faces [3 vertexes]


attempt at rudimentary lighting, comparing a light-direction vector with the normal vectors to determine brightness


instead of printing debug data on the top-left corner of the screen, it rendered it in 3d space instead and upside down


instead of printing debug data on the top-left corner of the screen, it rendered it in 3d space instead and upside down
JoJ

Now make in Vulkan :^)
The retro style your going for looks absolutely sick, keep it up.

turns out when you're starting from not much, the normal is pretty sensitive to the order of the input vertexes, which also screws up brightness
Yes, winding order is pretty important but your normal is mostly going to come down how you're calculating your cross-product as well as if your view matrix is left or right-handed. I personally stick to CCW as it's the default for both DirectX and OpenGL.


instead of printing debug data on the top-left corner of the screen, it rendered it in 3d space instead and upside down
You've probably already found a solution to this but I'll go ahead and mention it anyway: if you're using shaders you can just submit an identity matrix for what would normally be your model-view-projection.
If you're using OpenGL's internal pipeline this is as simple as popping all matrices on the stack or just doing
Code: [Select]
glPushMatrix();
glLoadIdentity();

For a debugging UI I'd recommend getting ImGui as it should integrate with whatever rendering library you're using. It's a very useful library and I use it in all my little projects all the time. But, it's not a necessity- one can understand if you want to roll your own if not just for the learning experience.

Lastly, based off your GIFs I can tell you have face culling disabled or that it's disabled by default and you don't have it enabled. Either way, I recommend you have it enabled as it provides a small performance boost as the GPU doesn't have to render and shade triangles the player wouldn't see anyway. It also helps you identify triangles that may have an incorrect winding order, as lighting isn't always a good indicator. You can enable it with glEnable(GL_CULL_FACE); and put it wherever you do your graphics initialization.

ive always been curious about building a 3d engine from constructive solid geometry brushes rather than vertices and indices


[img ]https://imgur.com/DPdkSfO.gif[/img]
screwed up normals
blockland moment