deferred skybox

pull/1/head
cosmonaut 2020-10-17 13:53:52 -07:00
parent 1486ba6625
commit 896dc6676b
10 changed files with 116 additions and 33 deletions

2
Kav

@ -1 +1 @@
Subproject commit 19a61985ca25a7562a7f62e03186f0ccfdc1c8ef
Subproject commit 06e552399600be4b706249bab54740eae4fd8e6b

View File

@ -0,0 +1,15 @@
using Encompass;
using Microsoft.Xna.Framework.Graphics;
namespace KavTest.Components
{
public struct SkyboxComponent : IComponent
{
public TextureCube Skybox { get; }
public SkyboxComponent(TextureCube skybox)
{
Skybox = skybox;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 723 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 KiB

View File

@ -119,6 +119,56 @@ namespace KavTest
)
);
Texture2D.TextureDataFromStreamEXT(
File.OpenRead("Content/Skybox/front.jpg"),
out var skyboxSize,
out _,
out byte[] frontPixels
);
Texture2D.TextureDataFromStreamEXT(
File.OpenRead("Content/Skybox/back.jpg"),
out _,
out _,
out byte[] backPixels
);
Texture2D.TextureDataFromStreamEXT(
File.OpenRead("Content/Skybox/right.jpg"),
out _,
out _,
out byte[] rightPixels
);
Texture2D.TextureDataFromStreamEXT(
File.OpenRead("Content/Skybox/left.jpg"),
out _,
out _,
out byte[] leftPixels
);
Texture2D.TextureDataFromStreamEXT(
File.OpenRead("Content/Skybox/top.jpg"),
out _,
out _,
out byte[] topPixels
);
Texture2D.TextureDataFromStreamEXT(
File.OpenRead("Content/Skybox/bottom.jpg"),
out _,
out _,
out byte[] bottomPixels
);
var skybox = new TextureCube(GraphicsDevice, skyboxSize, false, SurfaceFormat.Color);
skybox.SetData(CubeMapFace.PositiveZ, frontPixels);
skybox.SetData(CubeMapFace.NegativeZ, backPixels);
skybox.SetData(CubeMapFace.PositiveX, rightPixels);
skybox.SetData(CubeMapFace.NegativeX, leftPixels);
skybox.SetData(CubeMapFace.PositiveY, topPixels);
skybox.SetData(CubeMapFace.NegativeY, bottomPixels);
WorldBuilder.AddEngine(new InputEngine(this));
WorldBuilder.AddEngine(new AngularVelocityEngine());
WorldBuilder.AddEngine(new MoveAlongCurve3DEngine());
@ -150,40 +200,52 @@ namespace KavTest
// rustyBallModel
// ));
// WorldBuilder.SendMessage(new StaticModelSpawnMessage(
// new Transform3D(new Vector3(0, -3, 0), Quaternion.Identity, new Vector3(10f, 1f, 10f)),
// floorModel
// ));
// WorldBuilder.SendMessage(new StaticModelSpawnMessage(
// new Transform3D(
// new Vector3(-3, 1, 0),
// Quaternion.CreateFromAxisAngle(
// Vector3.Right,
// -Microsoft.Xna.Framework.MathHelper.PiOver2
// ),
// new Vector3(1f, 1f, 1f)
// ),
// blueTorusModel
// ));
// WorldBuilder.SendMessage(new StaticModelSpawnMessage(
// new Transform3D(
// new Vector3(3, 1, 0),
// Quaternion.CreateFromAxisAngle(
// Vector3.Right,
// -Microsoft.Xna.Framework.MathHelper.PiOver2
// ),
// new Vector3(1f, 1f, 1f)
// ),
// cubeModel
// ));
WorldBuilder.SendMessage(new StaticModelSpawnMessage(
Transform3D.Identity,
toonShadeRuinsModel
new Transform3D(new Vector3(0, -3, 0), Quaternion.Identity, new Vector3(10f, 1f, 10f)),
floorModel
));
WorldBuilder.SendMessage(new StaticModelSpawnMessage(
new Transform3D(
new Vector3(0, 1, 0),
Quaternion.CreateFromAxisAngle(
Vector3.Right,
-Microsoft.Xna.Framework.MathHelper.PiOver2
),
new Vector3(1f, 1f, 1f)
),
redCylinderModel
));
WorldBuilder.SendMessage(new StaticModelSpawnMessage(
new Transform3D(
new Vector3(-3, 1, 0),
Quaternion.CreateFromAxisAngle(
Vector3.Right,
-Microsoft.Xna.Framework.MathHelper.PiOver2
),
new Vector3(1f, 1f, 1f)
),
blueTorusModel
));
WorldBuilder.SendMessage(new StaticModelSpawnMessage(
new Transform3D(
new Vector3(3, 1, 0),
Quaternion.CreateFromAxisAngle(
Vector3.Right,
-Microsoft.Xna.Framework.MathHelper.PiOver2
),
new Vector3(1f, 1f, 1f)
),
cubeModel
));
// WorldBuilder.SendMessage(new StaticModelSpawnMessage(
// Transform3D.Identity,
// toonShadeRuinsModel
// ));
for (var i = 0; i < 1; i++)
{
var start = RandomHelper.RandomVector3(-5, 5);
@ -236,6 +298,11 @@ namespace KavTest
100f
));
var skyboxEntity = WorldBuilder.CreateEntity();
WorldBuilder.SetComponent(skyboxEntity, new SkyboxComponent(
skybox
));
World = WorldBuilder.Build();
}

View File

@ -143,7 +143,8 @@ namespace KavTest.Renderers
camera,
ModelTransforms,
AmbientLight,
DirectionalLight()
DirectionalLight(),
ReadComponent<SkyboxComponent>().Skybox
);
// foreach (var directionalLight in DirectionalLights)