feat(render): implement Campaign AR and terrain fidelity
This commit is contained in:
parent
99cf26e00c
commit
7a5f96ede5
368 changed files with 50611 additions and 950 deletions
|
|
@ -0,0 +1,90 @@
|
|||
using System.Numerics;
|
||||
using AcDream.App.Rendering;
|
||||
using AcDream.App.Rendering.Gpu;
|
||||
|
||||
namespace AcDream.App.Tests.Rendering;
|
||||
|
||||
public sealed class RetailDetailTextureContractTests
|
||||
{
|
||||
private static readonly TerrainAtlas.RetailDetailTextureBinding Available = new(
|
||||
new GpuTextureSlot(7),
|
||||
Tiling: 4f,
|
||||
SurfaceTextureId: 0x05001787,
|
||||
RenderSurfaceId: 0x06006D58,
|
||||
Width: 256,
|
||||
Height: 256);
|
||||
|
||||
[Fact]
|
||||
public void ExistingBuildingDetailSettingIsTheLivePassGate()
|
||||
{
|
||||
Assert.False(RetailDetailTextureContract.ShouldRender(false, Available));
|
||||
Assert.True(RetailDetailTextureContract.ShouldRender(true, Available));
|
||||
Assert.False(RetailDetailTextureContract.ShouldRender(true, default));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OpaqueDetailUsesDepthEqualityWhileTransparentDetailDoesNot()
|
||||
{
|
||||
Assert.Equal(
|
||||
GpuCompareOp.Equal,
|
||||
RetailDetailTextureContract.DetailDepthCompare(transparent: false));
|
||||
Assert.Equal(
|
||||
GpuCompareOp.LessOrEqual,
|
||||
RetailDetailTextureContract.DetailDepthCompare(transparent: true));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0f, 1f)]
|
||||
[InlineData(10f, 1f)]
|
||||
[InlineData(30f, 0.5f)]
|
||||
[InlineData(50f, 0f)]
|
||||
[InlineData(80f, 0f)]
|
||||
public void DistanceFadeUsesPositiveViewDepthInMetres(
|
||||
float depthMetres,
|
||||
float expected)
|
||||
{
|
||||
Assert.Equal(
|
||||
expected,
|
||||
RetailDetailTextureContract.FadeForPositiveViewDepthMetres(depthMetres),
|
||||
precision: 5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FadeZeroIsExactNoOpAndNeutralRgbEqualsAlpha()
|
||||
{
|
||||
var brighteningSample = new Vector4(0.459f, 0.459f, 0.459f, 0.282f);
|
||||
Assert.Equal(
|
||||
Vector3.One,
|
||||
RetailDetailTextureContract.FramebufferFactor(brighteningSample, fade: 0f));
|
||||
|
||||
var neutral = new Vector4(0.4f, 0.4f, 0.4f, 0.4f);
|
||||
Vector3 neutralFactor = RetailDetailTextureContract.FramebufferFactor(neutral, fade: 1f);
|
||||
Assert.Equal(1f, neutralFactor.X, precision: 5);
|
||||
Assert.Equal(1f, neutralFactor.Y, precision: 5);
|
||||
Assert.Equal(1f, neutralFactor.Z, precision: 5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RetailBlendPreservesMeasuredBrightening()
|
||||
{
|
||||
var measured = new Vector4(0.459f, 0.459f, 0.459f, 0.282f);
|
||||
Vector3 factor = RetailDetailTextureContract.FramebufferFactor(measured, fade: 1f);
|
||||
|
||||
Assert.Equal(1.177f, factor.X, precision: 5);
|
||||
Assert.Equal(1.177f, factor.Y, precision: 5);
|
||||
Assert.Equal(1.177f, factor.Z, precision: 5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnabledDerethCategoryTextureKeepsItsMeasuredBrightening()
|
||||
{
|
||||
var derethCategory = new Vector4(0.165f, 0.165f, 0.165f, 0.132f);
|
||||
Vector3 factor = RetailDetailTextureContract.FramebufferFactor(
|
||||
derethCategory,
|
||||
fade: 1f);
|
||||
|
||||
Assert.Equal(1.033f, factor.X, precision: 5);
|
||||
Assert.Equal(1.033f, factor.Y, precision: 5);
|
||||
Assert.Equal(1.033f, factor.Z, precision: 5);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue