clean up renderer a bit + README
parent
314b308840
commit
8cb7601717
|
@ -0,0 +1,24 @@
|
||||||
|
# Kav
|
||||||
|
|
||||||
|
A 3D renderer built on top of FNA.
|
||||||
|
|
||||||
|
## Roadmap
|
||||||
|
|
||||||
|
Essential
|
||||||
|
|
||||||
|
- [x] PBR shading
|
||||||
|
- [x] Deferred rendering
|
||||||
|
- [x] Point lighting
|
||||||
|
- [x] Directional lighting
|
||||||
|
- [x] Directional shadow maps
|
||||||
|
- [x] Cascading shadow maps
|
||||||
|
- [ ] Frustum culling
|
||||||
|
- [ ] Shadow-casting point lights
|
||||||
|
- [ ] Parabolic lights
|
||||||
|
- [ ] Skyboxes
|
||||||
|
- [ ] Screen-space reflection
|
||||||
|
|
||||||
|
Nice-To-Haves
|
||||||
|
|
||||||
|
- [ ] Volumetric lighting
|
||||||
|
- [ ] Volumetric smoke
|
25
Renderer.cs
25
Renderer.cs
|
@ -210,32 +210,7 @@ namespace Kav
|
||||||
IEnumerable<(Model, Matrix)> modelTransforms,
|
IEnumerable<(Model, Matrix)> modelTransforms,
|
||||||
DirectionalLight directionalLight
|
DirectionalLight directionalLight
|
||||||
) {
|
) {
|
||||||
// set up global light matrix
|
|
||||||
|
|
||||||
var right = Vector3.Cross(Vector3.Up, directionalLight.Direction);
|
|
||||||
var up = Vector3.Cross(directionalLight.Direction, right);
|
|
||||||
var cameraBoundingFrustum = new BoundingFrustum(camera.View * camera.Projection);
|
|
||||||
Vector3[] frustumCorners = cameraBoundingFrustum.GetCorners();
|
|
||||||
|
|
||||||
Vector3 frustumCenter = Vector3.Zero;
|
|
||||||
for (var i = 0; i < frustumCorners.Length; i++)
|
|
||||||
{
|
|
||||||
frustumCenter += frustumCorners[i];
|
|
||||||
}
|
|
||||||
frustumCenter /= 8f;
|
|
||||||
|
|
||||||
var lightView = Matrix.CreateLookAt(frustumCenter, frustumCenter - directionalLight.Direction, camera.View.Right);
|
|
||||||
|
|
||||||
for (var i = 0; i < frustumCorners.Length; i++)
|
|
||||||
{
|
|
||||||
frustumCorners[i] = Vector3.Transform(frustumCorners[i], lightView);
|
|
||||||
}
|
|
||||||
|
|
||||||
BoundingBox lightBox = BoundingBox.CreateFromPoints(frustumCorners);
|
|
||||||
Vector3 lightPosition = frustumCenter + directionalLight.Direction * -lightBox.Min.Z;
|
|
||||||
|
|
||||||
// render the individual shadow maps
|
// render the individual shadow maps
|
||||||
|
|
||||||
var previousFarPlane = camera.NearPlane;
|
var previousFarPlane = camera.NearPlane;
|
||||||
for (var i = 0; i < NumShadowCascades; i++)
|
for (var i = 0; i < NumShadowCascades; i++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue