fix: rlgl depth FBO shadows, correct normals, linear gamma, per-channel Fresnel

- 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.
This commit is contained in:
emil28092005
2026-06-17 16:13:46 +03:00
parent f905fe3040
commit c82ff48119
12 changed files with 474 additions and 106 deletions
+31 -5
View File
@@ -220,6 +220,13 @@ public sealed class ImGuiLayer : IDisposable
if (ImGui.CollapsingHeader("Light", ImGuiTreeNodeFlags.DefaultOpen))
{
var type = (int)l.Type;
if (ImGui.Combo("Type", ref type, "Directional\0Point\0"))
{
l.Type = (Engine.Core.Components.LightType)type;
entity.Set(l);
}
var color = l.Color;
if (ImGui.ColorEdit3("Color", ref color))
{
@@ -228,17 +235,36 @@ public sealed class ImGuiLayer : IDisposable
}
var intensity = l.Intensity;
if (ImGui.SliderFloat("Intensity", ref intensity, 0.0f, 5.0f))
if (ImGui.SliderFloat("Intensity", ref intensity, 0.0f, 10.0f))
{
l.Intensity = intensity;
entity.Set(l);
}
var dir = l.Direction;
if (ImGui.DragFloat3("Direction", ref dir, 0.01f, -1f, 1f))
if (l.Type == Engine.Core.Components.LightType.Point)
{
l.Direction = dir;
entity.Set(l);
var pos = l.Position;
if (ImGui.DragFloat3("Position", ref pos, 0.1f))
{
l.Position = pos;
entity.Set(l);
}
var range = l.Range;
if (ImGui.DragFloat("Range", ref range, 0.5f, 1f, 100f))
{
l.Range = range;
entity.Set(l);
}
}
else
{
var dir = l.Direction;
if (ImGui.DragFloat3("Direction", ref dir, 0.01f, -1f, 1f))
{
l.Direction = dir;
entity.Set(l);
}
}
}
}