Created
January 5, 2014 14:27
-
-
Save tgjones/8268812 to your computer and use it in GitHub Desktop.
HlslUnit prototype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public void CanExecuteVertexShader() | |
{ | |
// Arrange. | |
var shader = new Shader("Shaders/VS/BasicHLSL.fx", "RenderSceneVS", "vs_4_0"); | |
shader.SetConstantBuffer("$Globals", new BasicHlsl.ConstantBufferGlobals | |
{ | |
WorldViewProjection = | |
Matrix.LookAtRH(Vector3.UnitZ, Vector3.Zero, Vector3.UnitY) * | |
Matrix.PerspectiveFovRH(MathUtil.PiOverFour, 1, 1, 10) | |
}); | |
var vertexInput = new BasicHlsl.VertexShaderInput | |
{ | |
Position = new Vector4(3, 0, 2, 1), | |
Normal = new Vector3(0, 1, 0), | |
TextureCoordinate = new Vector2(0, 1) | |
}; | |
// Act. | |
var output = shader.Execute<BasicHlsl.VertexShaderOutput>(vertexInput); | |
// Assert. | |
Assert.That(output.Position, Is.EqualTo(new Vector4(7.24264f, 0, -3.222222f, 1))); | |
Assert.That(output.Diffuse, Is.EqualTo(new Vector4(0, 0, 0, 1))); | |
Assert.That(output.TextureUV, Is.EqualTo(new Vector2(0, 0))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment