Dawoodoz / DFPSR

Fast realtime softare rendering library for C++14 using SSE/AVX/NEON. 2D, 3D and isometric rendering with minimal system dependencies.
https://dawoodoz.com/dfpsr.html
78 stars 6 forks source link

Separate camera from triangle rendering (while still allowing infinite far clip plane) #4

Closed Dawoodoz closed 2 years ago

Dawoodoz commented 4 years ago

The 3D camera is a bit strange and nested into 3D rendering instead of just having a standard 4x4 matrix. This is because being allowed to have an infinite far clip plane means not being able to normalize the camera space. Everything would become zero after dividing by infinity if applying the traditional GPU math. If there is another clean mathematical representation capable of expressing the camera's projection with the clip planes, it could be a simple pre-transforming step. This would then allow regression testing the pre-transformed triangle rasterization without the camera and make the core methods easier to understand.

Powerful transform One possible use of a more powerful camera transformation is stereoscopic views where the center of perspective is shifted in 2D, without having to crop on side of the image. Global functions for generating camera transformation packets can then return the perspective center point within some kind of flexible yet fast transformation. Maybe normalize X and Y to -1..+1 while the Z depth remains in the original length system.

Optional near and far clip planes For orthogonal systems, the near clip plane can also be disabled.

Dawoodoz commented 4 years ago

An alternative to dividing algorithm responsibility can be to create a custom rendering pipeline to test each individual function in isolation.

Dawoodoz commented 2 years ago

I decided to just give the camera as an argument to individual triangle drawing function, with a requirement to use the same camera for the clipping as when positions were projected.