mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 19:12:43 +00:00 
			
		
		
		
	 526390ec06
			
		
	
	
		526390ec06
		
	
	
	
	
		
			
			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.
		
			
				
	
	
		
			28 lines
		
	
	
	
		
			662 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
	
		
			662 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/SIMD.h>
 | |
| #include <LibGfx/Vector2.h>
 | |
| #include <LibGfx/Vector3.h>
 | |
| #include <LibGfx/Vector4.h>
 | |
| #include <LibSoftGPU/Config.h>
 | |
| 
 | |
| namespace SoftGPU {
 | |
| 
 | |
| struct PixelQuad final {
 | |
|     Vector2<AK::SIMD::i32x4> screen_coordinates;
 | |
|     Vector3<AK::SIMD::f32x4> barycentrics;
 | |
|     AK::SIMD::f32x4 depth;
 | |
|     Vector4<AK::SIMD::f32x4> vertex_color;
 | |
|     Array<Vector4<AK::SIMD::f32x4>, GPU::NUM_SAMPLERS> texture_coordinates;
 | |
|     Vector4<AK::SIMD::f32x4> out_color;
 | |
|     AK::SIMD::f32x4 fog_depth;
 | |
|     AK::SIMD::i32x4 mask;
 | |
| };
 | |
| 
 | |
| }
 |