summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibSoftGPU/Triangle.h
AgeCommit message (Collapse)Author
2022-05-09LibGL+LibGPU+LibSoftGPU: Implement point and line drawingJelle Raaijmakers
Implement (anti)aliased point drawing and anti-aliased line drawing. Supported through LibGL's `GL_POINTS`, `GL_LINES`, `GL_LINE_LOOP` and `GL_LINE_STRIP`. In order to support this, `LibSoftGPU`s rasterization logic was reworked. Now, any primitive can be drawn by invoking `rasterize()` which takes care of the quad loop and fragment testing logic. Three callbacks need to be passed: * `set_coverage_mask`: the primitive needs to provide initial coverage mask information so fragments can be discarded early. * `set_quad_depth`: fragments survived stencil testing, so depth values need to be set so depth testing can take place. * `set_quad_attributes`: fragments survived depth testing, so fragment shading is going to take place. All attributes like color, tex coords and fog depth need to be set so alpha testing and eventually, fragment rasterization can take place. As of this commit, there are four instantiations of this function: * Triangle rasterization * Points - aliased * Points - anti-aliased * Lines - anti-aliased In order to standardize vertex processing for all primitive types, things like vertex transformation, lighting and tex coord generation are now taking place before clipping.
2022-05-05LibSoftGPU: Move back to `i32`-based subpixelsJelle Raaijmakers
Our move to floating point precision has eradicated the pixel artifacts in Quake 1, but introduced new and not so subtle rendering glitches in games like Tux Racer. This commit changes three things to get the best of both worlds: 1. Subpixel logic based on `i32` types was reintroduced, the number of bits is set to 6. This reintroduces the artifacts in Quake 1 but fixes rendering of Tux Racer. 2. Before triangle culling, subpixel coordinates are calculated and stored in `Triangle`. These coordinates are rounded, which fixes the Quake 1 artifacts. Tux Racer is unaffected. 3. The triangle area (actually parallelogram area) is also stored in `Triangle` so we don't need to recalculate it later on. In our previous subpixel code, there was a subtle disconnect between the two calculations (one with and one without subpixel precision) which resulted in triangles incorrectly being culled. This fixes some remaining Quake 1 artifacts.
2022-04-06LibGL+LibGPU+LibSoftGPU: Move Vertex.h to LibGPUStephan Unverwerth
2021-12-24LibGL+LibSoftGPU: Move Vertex and Triangle structs to LibSoftGPUStephan Unverwerth