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
 layout (location = 0) in vec3 inPos;
6
 layout (location = 0) in vec3 inPos;
7
 layout (location = 1) in vec3 inColor;
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
 layout (location = 0) out vec3 outColor;
10
 layout (location = 0) out vec3 outColor;
17
 
11
 
24
 void main() 
18
 void main() 
25
 {
19
 {
26
 	outColor = inColor;
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
 		};
39
 		};
40
 		DKArray<Vertex> vertexData =
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
 		uint32_t vertexBufferSize = static_cast<uint32_t>(vertexData.Count()) * sizeof(Vertex);
46
 		uint32_t vertexBufferSize = static_cast<uint32_t>(vertexData.Count()) * sizeof(Vertex);
47
 		DKArray<uint32_t> indexData = { 0, 1, 2 };
47
 		DKArray<uint32_t> indexData = { 0, 1, 2 };
61
 		pipelineDescriptor.colorAttachments.Resize(1);
61
 		pipelineDescriptor.colorAttachments.Resize(1);
62
 		pipelineDescriptor.colorAttachments.Value(0).pixelFormat = swapChain->ColorPixelFormat();
62
 		pipelineDescriptor.colorAttachments.Value(0).pixelFormat = swapChain->ColorPixelFormat();
63
 		pipelineDescriptor.rasterizationEnabled = true;
63
 		pipelineDescriptor.rasterizationEnabled = true;
64
+		pipelineDescriptor.primitiveTopology = DKPrimitiveTopology::Triangles;
64
 		pipelineDescriptor.vertexDescriptor.attributes = {
65
 		pipelineDescriptor.vertexDescriptor.attributes = {
65
 			{ DKVertexFormat::Float3, 0, 0, 0 },
66
 			{ DKVertexFormat::Float3, 0, 0, 0 },
66
 			{ DKVertexFormat::Float3, sizeof(DKVector3), 0, 1 },
67
 			{ DKVertexFormat::Float3, sizeof(DKVector3), 0, 1 },
90
 				encoder->SetVertexBuffer(vertexBuffer, 0, 0);
91
 				encoder->SetVertexBuffer(vertexBuffer, 0, 0);
91
 				encoder->SetIndexBuffer(indexBuffer, 0, DKIndexType::UInt32);
92
 				encoder->SetIndexBuffer(indexBuffer, 0, DKIndexType::UInt32);
92
 				// draw scene!
93
 				// draw scene!
93
-				encoder->DrawIndexed(indexData.Count(), 1, 0, 0, 0);
94
+				encoder->DrawIndexed(indexData.Count(), 1, 0, 0, 1);
94
 				encoder->EndEncoding();
95
 				encoder->EndEncoding();
95
 				buffer->Commit();
96
 				buffer->Commit();
96
 				swapChain->Present();
97
 				swapChain->Present();