fix(rendering): restore retail terrain texture tiling
Carry TerrainTex.TexTiling through the terrain atlas and upload a layer-indexed table to the modern bindless shader so base, overlay, and road textures repeat at retail scale. Keep alpha masks cell-scaled and preserve retail's verified source-level-zero high-detail selection. Add the named-retail pseudocode, WorldBuilder/ACE/ACME cross-reference, adapter conformance tests, and inventory documentation so a future renderer migration keeps the contract. Co-Authored-By: Codex <noreply@openai.com>
This commit is contained in:
parent
84b7d2d7cd
commit
bb5acab9e6
7 changed files with 297 additions and 7 deletions
|
|
@ -0,0 +1,66 @@
|
|||
using AcDream.App.Rendering;
|
||||
|
||||
namespace AcDream.App.Tests.Rendering;
|
||||
|
||||
public sealed class TerrainTextureTilingTableTests
|
||||
{
|
||||
[Fact]
|
||||
public void Build_MapsDatRepeatCountsToAtlasLayers()
|
||||
{
|
||||
var table = TerrainTextureTilingTable.Build(
|
||||
[
|
||||
(Layer: 0u, RepeatCount: 4u),
|
||||
(Layer: 7u, RepeatCount: 2u),
|
||||
(Layer: 32u, RepeatCount: 8u),
|
||||
]);
|
||||
|
||||
Assert.Equal(TerrainTextureTilingTable.LayerCapacity, table.Length);
|
||||
Assert.Equal(4f, table[0]);
|
||||
Assert.Equal(2f, table[7]);
|
||||
Assert.Equal(8f, table[32]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Build_DefaultsOnlyUnusedLayersToOne()
|
||||
{
|
||||
var table = TerrainTextureTilingTable.Build(
|
||||
[
|
||||
(Layer: 3u, RepeatCount: 0u),
|
||||
]);
|
||||
|
||||
Assert.Equal(1f, table[2]);
|
||||
Assert.Equal(0f, table[3]);
|
||||
Assert.Equal(1f, table[4]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Build_RejectsLayersTheShaderCannotAddress()
|
||||
{
|
||||
var ex = Assert.Throws<InvalidOperationException>(() =>
|
||||
TerrainTextureTilingTable.Build(
|
||||
[
|
||||
(Layer: (uint)TerrainTextureTilingTable.LayerCapacity, RepeatCount: 1u),
|
||||
]));
|
||||
|
||||
Assert.Contains("exceeds the shader capacity", ex.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ModernShader_AppliesTheOwningLayersRepeatCountToEveryTerrainSample()
|
||||
{
|
||||
string shaderPath = Path.Combine(
|
||||
AppContext.BaseDirectory,
|
||||
"Rendering",
|
||||
"Shaders",
|
||||
"terrain_modern.frag");
|
||||
string shader = File.ReadAllText(shaderPath);
|
||||
|
||||
Assert.Contains("uniform float uTexTiling[36];", shader);
|
||||
Assert.Contains("baseUV * terrainTiling(pOverlay0.z)", shader);
|
||||
Assert.Contains("baseUV * terrainTiling(pOverlay1.z)", shader);
|
||||
Assert.Contains("baseUV * terrainTiling(pOverlay2.z)", shader);
|
||||
Assert.Contains("baseUV * terrainTiling(pRoad0.z)", shader);
|
||||
Assert.Contains("vBaseUV * terrainTiling(vBaseTexIdx)", shader);
|
||||
Assert.DoesNotContain("const float TILE", shader);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue