Files
Cortex_Engine/tests/Engine.Tests/ShadowShaderTests.cs
T
emil28092005 a2000b55b5 feat: cubemap shadows with R32_SFLOAT color attachment — linear distance
Root cause of broken shadows: depth buffer stores non-linear NDC depth,
not linear distance. closestDepth * 60.0 was wrong conversion.

Fix: switch from depth-only to R32_SFLOAT color attachment approach:
- Shadow vertex shader outputs world position to fragment
- Shadow fragment shader writes length(fragPos - lightPos) / farPlane
- Main fragment shader samples cubemap, multiplies by FAR_PLANE=60
- Separate color cube (R32_SFLOAT, sampled) + depth cube (D32_SFLOAT, depth test)
- Shadow pipeline: 1 color attachment (R) + depth attachment
- Color clear = 1.0 (max distance), depth clear = 1.0

Tests: 227 total, all pass
- ShadowMapFaceDirectionTests: 6 face directions, 90° FOV, up vectors,
  valid matrices, far plane consistency
- ShadowShaderTests: all 6 SPIR-V shaders exist
2026-06-18 21:27:48 +03:00

45 lines
1.4 KiB
C#

using System.IO;
using Engine.Graphics.Vulkan;
namespace Engine.Tests;
public class ShadowShaderTests
{
[Fact]
public void Shadow_Vertex_Shader_Exists()
{
Assert.True(File.Exists("Shaders/shadow.vert.spv") ||
File.Exists(Path.Combine(AppContext.BaseDirectory, "Shaders/shadow.vert.spv")));
}
[Fact]
public void Shadow_Fragment_Shader_Exists()
{
Assert.True(File.Exists("Shaders/shadow.frag.spv") ||
File.Exists(Path.Combine(AppContext.BaseDirectory, "Shaders/shadow.frag.spv")));
}
[Fact]
public void Main_Vertex_Shader_Exists()
{
Assert.True(File.Exists("Shaders/triangle.vert.spv") ||
File.Exists(Path.Combine(AppContext.BaseDirectory, "Shaders/triangle.vert.spv")));
}
[Fact]
public void Main_Fragment_Shader_Exists()
{
Assert.True(File.Exists("Shaders/triangle.frag.spv") ||
File.Exists(Path.Combine(AppContext.BaseDirectory, "Shaders/triangle.frag.spv")));
}
[Fact]
public void ImGui_Shaders_Exist()
{
Assert.True(File.Exists("Shaders/imgui.vert.spv") ||
File.Exists(Path.Combine(AppContext.BaseDirectory, "Shaders/imgui.vert.spv")));
Assert.True(File.Exists("Shaders/imgui.frag.spv") ||
File.Exists(Path.Combine(AppContext.BaseDirectory, "Shaders/imgui.frag.spv")));
}
}