Browse Source

update shader

Hongtae Kim 6 years ago
parent
commit
d0baf008f5
3 changed files with 6 additions and 11 deletions
  1. 1
    7
      Data/triangle.vert
  2. BIN
      Data/triangle.vert.spv
  3. 5
    4
      TestApp1/TestApp1.cpp

+ 1
- 7
Data/triangle.vert View File

@@ -6,12 +6,6 @@
6 6
 layout (location = 0) in vec3 inPos;
7 7
 layout (location = 1) in vec3 inColor;
8 8
 
9
-layout (binding = 0) uniform UBO 
10
-{
11
-	mat4 projectionMatrix;
12
-	mat4 modelMatrix;
13
-	mat4 viewMatrix;
14
-} ubo;
15 9
 
16 10
 layout (location = 0) out vec3 outColor;
17 11
 
@@ -24,5 +18,5 @@ out gl_PerVertex
24 18
 void main() 
25 19
 {
26 20
 	outColor = inColor;
27
-	gl_Position = ubo.projectionMatrix * ubo.viewMatrix * ubo.modelMatrix * vec4(inPos.xyz, 1.0);
21
+	gl_Position = vec4(inPos.xyz, 1.0);
28 22
 }

BIN
Data/triangle.vert.spv View File


+ 5
- 4
TestApp1/TestApp1.cpp View File

@@ -39,9 +39,9 @@ public:
39 39
 		};
40 40
 		DKArray<Vertex> vertexData =
41 41
 		{
42
-			{ { 1.0f,  1.0f, 0.0f },{ 1.0f, 0.0f, 0.0f } },
43
-			{ { -1.0f,  1.0f, 0.0f },{ 0.0f, 1.0f, 0.0f } },
44
-			{ { 0.0f, -1.0f, 0.0f },{ 0.0f, 0.0f, 1.0f } }
42
+			{ {  0.0f, -0.5f, 0.0f },{ 1.0f, 1.0f, 1.0f } },
43
+			{ {  0.5f,  0.5f, 0.0f },{ 0.0f, 1.0f, 0.0f } },
44
+			{ { -0.5f,  0.5f, 0.0f },{ 0.0f, 0.0f, 1.0f } }
45 45
 		};
46 46
 		uint32_t vertexBufferSize = static_cast<uint32_t>(vertexData.Count()) * sizeof(Vertex);
47 47
 		DKArray<uint32_t> indexData = { 0, 1, 2 };
@@ -61,6 +61,7 @@ public:
61 61
 		pipelineDescriptor.colorAttachments.Resize(1);
62 62
 		pipelineDescriptor.colorAttachments.Value(0).pixelFormat = swapChain->ColorPixelFormat();
63 63
 		pipelineDescriptor.rasterizationEnabled = true;
64
+		pipelineDescriptor.primitiveTopology = DKPrimitiveTopology::Triangles;
64 65
 		pipelineDescriptor.vertexDescriptor.attributes = {
65 66
 			{ DKVertexFormat::Float3, 0, 0, 0 },
66 67
 			{ DKVertexFormat::Float3, sizeof(DKVector3), 0, 1 },
@@ -90,7 +91,7 @@ public:
90 91
 				encoder->SetVertexBuffer(vertexBuffer, 0, 0);
91 92
 				encoder->SetIndexBuffer(indexBuffer, 0, DKIndexType::UInt32);
92 93
 				// draw scene!
93
-				encoder->DrawIndexed(indexData.Count(), 1, 0, 0, 0);
94
+				encoder->DrawIndexed(indexData.Count(), 1, 0, 0, 1);
94 95
 				encoder->EndEncoding();
95 96
 				buffer->Commit();
96 97
 				swapChain->Present();