summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibSoftGPU/PixelQuad.h
AgeCommit message (Collapse)Author
2022-12-17LibSoftGPU: Make output in PixelQuad genericStephan Unverwerth
Same as with inputs, we define outputs as a generic array of floats. This can later be expanded to accomodate multiple render targets or vertex attributes in the case of a vertex shader.
2022-12-17LibSoftGPU: Make input in PixelQuad genericStephan Unverwerth
Previously we would store vertex color and texture coordinates in separate fields in PixelQuad. To make them accessible from shaders we need to store them as a completely generic array of floats.
2022-09-11LibGL+LibGPU+LibSoftGPU: Implement matrix stack per texture unitJelle Raaijmakers
Each texture unit now has its own texture transformation matrix stack. Introduce a new texture unit configuration that is synced when changed. Because we're no longer passing a silly `Vector` when drawing each primitive, this results in a slightly improved frames per second :^)
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
2022-03-07LibSoftGPU: Use `float` instead of `int` for triangle screen coordsJelle Raaijmakers
This replaces the fixed point subpixel precision logic. GLQuake now effectively renders artifact-free. Previously white/gray pixels would sometimes be visible at triangle edges, caused by slightly misaligned triangle edges as a result of converting the vertex window coordinates to `int`. These artifacts were reduced by the introduction of subpixel precision, but not completely eliminated. Some interesting changes in this commit: * Applying the top-left rule for our counter-clockwise vertices is now done with simpler conditions: every vertex that has a Y coordinate lower than or equal to the previous vertex' Y coordinate is counted as a top or left edge. A float epsilon is used to emulate a switch between `> 0` and `>= 0` comparisons. * Fog depth calculation into a `f32x4` is now done once per triangle instead of once per fragment, and only if fog is enabled. * The `one_over_area` value was previously calculated as `1.0f / area`, where `area` was an `int`. This resulted in a lower quality reciprocal value whereas we can now retain floating point precision. The effect of this can be seen in Tux Racer, where the ice reflection is noticeably smoother.
2022-01-19LibGL+LibSoftGPU: Add multiple texture coordinates to vertex structStephan Unverwerth
We now have one set of texture coordinates per texture unit. Texture coordinate generation and texture coordinate assignment is currently only stubbed. This will be rectified in another commit.
2022-01-09LibSoftGPU: Add PixelQuad struct that holds data for each rendered quadStephan Unverwerth