- Shadow mapping via rlgl: custom depth FBO (2048x2048, 24-bit depth texture) instead of color-attachment approach. Proper depth-only render pass. - Shadow map bound via MaterialMapIndex.Emission (texture unit 1), sampled in shadow receiver shader with PCF 3x3 soft shadows. - Fixed inverted normals: Cross(ac, ab) for CW winding in OBJ files. - Linear workflow: pow(albedo, 2.2) before lighting, pow(result, 1/2.2) after. - Per-channel Fresnel: vec3 F0 + (1-F0)*pow(1-HdotV,5) instead of F0.x. - Single CollectLights call after BeginMode3D. - Shadow pass after BeginDrawing (inside frame). - Backface culling disabled globally for mixed-winding meshes. - Point light support: Light.Point/Directional factory methods, attenuation, ImGui inspector with type combo, position/range for point lights. - Floor rendered for both light types (shadow receiver or main shader). - 66/66 tests passing.
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using System.Numerics;
|
|
using Engine.Core;
|
|
using Engine.Core.Components;
|
|
|
|
namespace Engine.Tests;
|
|
|
|
public class MeshAndLightTests
|
|
{
|
|
[Fact]
|
|
public void Mesh_Stores_Vertices_And_Indices()
|
|
{
|
|
var vertices = new[]
|
|
{
|
|
new Vertex(new Vector3(0, 0, 0), Vector3.One, Vector3.UnitY),
|
|
new Vertex(new Vector3(1, 0, 0), Vector3.One, Vector3.UnitY),
|
|
new Vertex(new Vector3(1, 1, 0), Vector3.One, Vector3.UnitY),
|
|
};
|
|
var indices = new uint[] { 0, 1, 2 };
|
|
var mesh = new Mesh(vertices, indices);
|
|
|
|
Assert.Equal(3, mesh.Vertices.Length);
|
|
Assert.Equal(3, mesh.Indices.Length);
|
|
}
|
|
|
|
[Fact]
|
|
public void Light_Direction_Is_Normalized()
|
|
{
|
|
var light = Light.Directional(new Vector3(0, 2, 0), Vector3.One, 1.0f);
|
|
|
|
Assert.Equal(1f, light.Direction.Length(), 0.001f);
|
|
}
|
|
|
|
[Fact]
|
|
public void Light_With_Zero_Direction_Defaults_To_UnitY()
|
|
{
|
|
var light = Light.Directional(Vector3.Zero, Vector3.One, 1.0f);
|
|
|
|
Assert.Equal(Vector3.UnitY, light.Direction);
|
|
}
|
|
}
|