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:
@@ -74,19 +74,7 @@ class Program
|
||||
|
||||
world.Entity("MainLight")
|
||||
.Set(new Transform(new Vector3(0.0f, 0.0f, 0.0f), Quaternion.Identity, Vector3.One))
|
||||
.Set(new Light(new Vector3(0.5f, -1.0f, -0.5f), new Vector3(1.0f, 0.95f, 0.8f), 1.0f));
|
||||
|
||||
world.Entity("FillLight")
|
||||
.Set(new Transform(new Vector3(0.0f, 0.0f, 0.0f), Quaternion.Identity, Vector3.One))
|
||||
.Set(new Light(new Vector3(-0.8f, -0.6f, 0.3f), new Vector3(0.3f, 0.4f, 0.6f), 0.6f));
|
||||
|
||||
world.Entity("FrontLight")
|
||||
.Set(new Transform(new Vector3(0.0f, 0.0f, 0.0f), Quaternion.Identity, Vector3.One))
|
||||
.Set(new Light(new Vector3(0.0f, -0.3f, -1.0f), new Vector3(0.8f, 0.8f, 0.9f), 0.4f));
|
||||
|
||||
world.Entity("GroundLight")
|
||||
.Set(new Transform(new Vector3(0.0f, 0.0f, 0.0f), Quaternion.Identity, Vector3.One))
|
||||
.Set(new Light(new Vector3(0.0f, 1.0f, 0.0f), new Vector3(0.15f, 0.15f, 0.2f), 0.3f));
|
||||
.Set(Light.Directional(new Vector3(0.4f, -1.0f, -0.3f), new Vector3(1.0f, 0.95f, 0.85f), 2.0f));
|
||||
|
||||
ICameraController[] cameraControllers =
|
||||
{
|
||||
@@ -356,6 +344,12 @@ class Program
|
||||
.Set(mesh)
|
||||
.Set(new Material(new Vector3(0.8f, 0.8f, 0.85f), roughness: 0.4f, metallic: 0.0f, texturePath: "Content/checker.png"));
|
||||
|
||||
// Floor plane for shadow visibility
|
||||
world.Entity("Floor")
|
||||
.Set(new Transform(new Vector3(0, -0.02f, 0), Quaternion.Identity, new Vector3(20, 1, 20)))
|
||||
.Set(mesh)
|
||||
.Set(new Material(new Vector3(0.45f, 0.45f, 0.5f), roughness: 0.8f, metallic: 0.0f));
|
||||
|
||||
world.Entity("Grid")
|
||||
.Set(new Transform(new Vector3(0.0f, 0.0f, 0.0f), Quaternion.Identity, Vector3.One))
|
||||
.Set(ProceduralMesh.CreateGrid(20, 1.0f, new Vector3(0.5f, 0.5f, 0.55f)))
|
||||
|
||||
Reference in New Issue
Block a user