Skip to content

Commit

Permalink
Modified skybox renderer to be more robust
Browse files Browse the repository at this point in the history
made views a processbehaviour so they can be more usefully extended

Signed-off-by: Martin Evans <martindevans@gmail.com>
  • Loading branch information
martindevans committed Oct 7, 2013
1 parent 86bf329 commit 84b9bef
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
24 changes: 12 additions & 12 deletions Myre/Myre.Graphics/Deferred/LightManagers/DeferredSkyboxManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ public class DeferredSkyboxManager
readonly Effect _skyboxEffect;
readonly Quad _quad;

private readonly DepthStencilState _depthState = new DepthStencilState
{
DepthBufferEnable = true,
DepthBufferWriteEnable = false,
DepthBufferFunction = CompareFunction.LessEqual
};

public DeferredSkyboxManager(GraphicsDevice device)
{
_skyboxEffect = Content.Load<Effect>("Skybox");
Expand All @@ -29,25 +36,18 @@ public void Draw(Renderer renderer)
var device = renderer.Device;

var previousDepthState = device.DepthStencilState;
//device.DepthStencilState = DepthStencilState.DepthRead;
device.DepthStencilState = new DepthStencilState()
{
DepthBufferEnable = true,
DepthBufferWriteEnable = false,
DepthBufferFunction = CompareFunction.LessEqual
};
device.DepthStencilState = _depthState;

var previousRasterState = device.RasterizerState;
device.RasterizerState = RasterizerState.CullCounterClockwise;

//device.SetVertexBuffer(vertices);
//device.Indices = indices;
device.RasterizerState = RasterizerState.CullNone;

var part = _model.Meshes[0].MeshParts[0];
device.SetVertexBuffer(part.VertexBuffer);
device.Indices = part.IndexBuffer;

_skyboxEffect.Parameters["View"].SetValue(renderer.Data.GetValue<Matrix>("view"));
var view = renderer.Data.GetValue<Matrix>("view");
view.Translation = Vector3.Zero;
_skyboxEffect.Parameters["View"].SetValue(view);
_skyboxEffect.Parameters["Projection"].SetValue(renderer.Data.GetValue<Matrix>("projection"));

for (int i = 0; i < Behaviours.Count; i++)
Expand Down
7 changes: 5 additions & 2 deletions Myre/Myre.Graphics/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Myre.Graphics
{
[DefaultManager(typeof(Manager))]
public class View
: Behaviour
: ProcessBehaviour
{
private Property<Camera> _camera;
private Property<Viewport> _viewport;
Expand Down Expand Up @@ -41,9 +41,12 @@ public void SetMetadata(RendererMetadata metadata)
_camera.Value.SetMetadata(metadata);
}

protected override void Update(float elapsedTime)
{
}

public class Manager
: BehaviourManager<View>
: Manager<View>
{
public IEnumerable<View> Views
{
Expand Down

0 comments on commit 84b9bef

Please sign in to comment.