Rendered at 07:05:12 GMT+0000 (Coordinated Universal Time) with Cloudflare Workers.
kbruner 2 hours ago [-]
I don't see clipping in homogeneous space, which seems like a big omission. Can't beat good old Foley/van Dam - "Computer Graphics Principals & Practice" for stuff like this.
AlexeyBrin 10 hours ago [-]
This is a great tutorial. I also bought the book published by No Starch Press.
vivzkestrel 4 hours ago [-]
- a few major questions from a guy who is absolutely not familiar with this subject
- is x axies increasing towards right, y axis towards top, z axis into the screen
?
- are there other alignments for x,y,z?
- does every object have coordinates defined in the -1 to 1 range?
- what is local coordinate system compared to world coordinate system and does it also stick to -1 to 1 range? let us say I have a 3d Cube 5 units think, what does the local coordinate system for this look like and if I wanted to place it at 0,0,0 what do we do? multply local x world space in matrix form?
Frotag 2 hours ago [-]
(amateur explanation incoming, should probably double check elsewhere)
I think of it as the world is biggest possible 3d-space. The camera is a 3d volume within the world, often a pyramid called the "frustrum" [0]. The screen is a 2d rectangle generated from the 3d camera frustrum. Loosely speaking, the pyramid is stretched into a rect prism and flattened. Or in other words, only objects inside the camera volume are rendered.
> is x axies increasing towards right, y axis towards top, z axis into the screen ?
When referring to the world, yes a lot of rendering software uses the y-up convention, with x being horizontal and z being into / out of the screen.
I think y-up is the most common but sometimes its z-up like in Blender. I'm not super familiar with the history / how older software like directx does it.
> does every object have coordinates defined in the -1 to 1 range?
The world, camera, and screen (and object) all have different coordinate systems.
The camera actually has a bunch of them: view space, clip space, normalized device coordinates (NDC).
View space mostly just applies a translation (and possible rotation if camera is rotated) to the world space coordinates of each object. So the camera (the tip of the frustrum / pyramid) is at origin now, still y-up and z in/out of screen (again assuming no camera rotation).
Clip space maps the view-space pyramid to a new pyramid where the rectangular cross-sections become square and the height of pyramid along z get's warped too. Both the final side-length of the squares and new pyramid height are usually configurable constants. This "handles" the effects of FOV (the slope of pyramid edges) and camera aspect ratio (the aspect ratio of rect cross sections in view space). [1]
NDC maps each square xy cross-section of the clip space pyramid to the same size square and stacks these cross-sections to form a cube. This models perspective (far objects need to be bigger (occupy same % of cross-section) to render at same size as something closer to camera / tip of pyramid). This is also where the coordinates get normalized to [-1,1]. [2]
And then screen space is rendered by flattening the NDC cube (ie draw on screen using xy, use z as order for drawing). There's also stretching involved since NDC is a cube but your screen is probably a rectangle.
> - what is local coordinate system compared to world coordinate system and does it also stick to -1 to 1 range? let us say I have a 3d Cube 5 units think, what does the local coordinate system for this look like and if I wanted to place it at 0,0,0 what do we do? multply local x world space in matrix form?
Hopefully the previous blurb mostly answers this, with model space -> world space being the same as world space -> view space. That is, convert coordinates such that the origin changes from middle of object to the world's origin. And again, model space doesn't require normalizing anything to [-1,1], only NDC asks for that.
--
[0] When modeled by pyramid volume, they're called perspective cameras. When modeled by a rectangular prism, they're called orthographic cameras.
[1] I implied clip space is 3d but there's really a 4th dimension to make the math easy.
[2] Not sure why z has to be normalized to same range (ie why cant result be a rect prism instead of cube) but that's the convention I guess.
vivzkestrel 49 minutes ago [-]
- first of all thank you for the absolute detail on this one
- when i searched books i only see web GL, open GL, directX, vulkan etc and most resources online are also dedicated to these
- are you aware of a resource that teaches these things from scratch like without using any of the libraries above, it explains all these coordinate spaces, then vector math associated and starts drawing / rendering 3d objects that may eventually turn into discussions of collisions, physics , raytracing, shaders etc? (eventually gamedev)
Frotag 23 minutes ago [-]
No sorry, I don't remember seeing any all-in-one tutorials. For just the rendering / raytracing / shaders I remember using the OP and the github link below a lot.
- is x axies increasing towards right, y axis towards top, z axis into the screen ?
- are there other alignments for x,y,z?
- does every object have coordinates defined in the -1 to 1 range?
- what is local coordinate system compared to world coordinate system and does it also stick to -1 to 1 range? let us say I have a 3d Cube 5 units think, what does the local coordinate system for this look like and if I wanted to place it at 0,0,0 what do we do? multply local x world space in matrix form?
I think of it as the world is biggest possible 3d-space. The camera is a 3d volume within the world, often a pyramid called the "frustrum" [0]. The screen is a 2d rectangle generated from the 3d camera frustrum. Loosely speaking, the pyramid is stretched into a rect prism and flattened. Or in other words, only objects inside the camera volume are rendered.
> is x axies increasing towards right, y axis towards top, z axis into the screen ?
When referring to the world, yes a lot of rendering software uses the y-up convention, with x being horizontal and z being into / out of the screen.
https://www.gabrielgambetta.com/computer-graphics-from-scrat...
> are there other alignments for x,y,z?
I think y-up is the most common but sometimes its z-up like in Blender. I'm not super familiar with the history / how older software like directx does it.
> does every object have coordinates defined in the -1 to 1 range?
The world, camera, and screen (and object) all have different coordinate systems.
The camera actually has a bunch of them: view space, clip space, normalized device coordinates (NDC).
View space mostly just applies a translation (and possible rotation if camera is rotated) to the world space coordinates of each object. So the camera (the tip of the frustrum / pyramid) is at origin now, still y-up and z in/out of screen (again assuming no camera rotation).
Clip space maps the view-space pyramid to a new pyramid where the rectangular cross-sections become square and the height of pyramid along z get's warped too. Both the final side-length of the squares and new pyramid height are usually configurable constants. This "handles" the effects of FOV (the slope of pyramid edges) and camera aspect ratio (the aspect ratio of rect cross sections in view space). [1]
NDC maps each square xy cross-section of the clip space pyramid to the same size square and stacks these cross-sections to form a cube. This models perspective (far objects need to be bigger (occupy same % of cross-section) to render at same size as something closer to camera / tip of pyramid). This is also where the coordinates get normalized to [-1,1]. [2]
And then screen space is rendered by flattening the NDC cube (ie draw on screen using xy, use z as order for drawing). There's also stretching involved since NDC is a cube but your screen is probably a rectangle.
> - what is local coordinate system compared to world coordinate system and does it also stick to -1 to 1 range? let us say I have a 3d Cube 5 units think, what does the local coordinate system for this look like and if I wanted to place it at 0,0,0 what do we do? multply local x world space in matrix form?
Hopefully the previous blurb mostly answers this, with model space -> world space being the same as world space -> view space. That is, convert coordinates such that the origin changes from middle of object to the world's origin. And again, model space doesn't require normalizing anything to [-1,1], only NDC asks for that.
--
[0] When modeled by pyramid volume, they're called perspective cameras. When modeled by a rectangular prism, they're called orthographic cameras.
[1] I implied clip space is 3d but there's really a 4th dimension to make the math easy.
[2] Not sure why z has to be normalized to same range (ie why cant result be a rect prism instead of cube) but that's the convention I guess.
- when i searched books i only see web GL, open GL, directX, vulkan etc and most resources online are also dedicated to these
- are you aware of a resource that teaches these things from scratch like without using any of the libraries above, it explains all these coordinate spaces, then vector math associated and starts drawing / rendering 3d objects that may eventually turn into discussions of collisions, physics , raytracing, shaders etc? (eventually gamedev)
https://natethegreat2525.github.io/projects/software_rendere...