Browse Source

모델 회전, 카메라 위치 변경.

Hongtae Kim 5 years ago
parent
commit
69ba9b67b1
1 changed files with 11 additions and 10 deletions
  1. 11
    10
      Samples/Mesh/Mesh.cpp

+ 11
- 10
Samples/Mesh/Mesh.cpp View File

@@ -243,15 +243,21 @@ public:
243 243
         indexBuffer->Flush();
244 244
 
245 245
 		DKRenderPipelineDescriptor pipelineDescriptor;
246
+        // setup shader
246 247
 		pipelineDescriptor.vertexFunction = vertShaderFunction;
247 248
 		pipelineDescriptor.fragmentFunction = fragShaderFunction;
249
+        // setup color-attachment render-targets
248 250
 		pipelineDescriptor.colorAttachments.Resize(1);
249 251
 		pipelineDescriptor.colorAttachments.Value(0).pixelFormat = swapChain->ColorPixelFormat();
250 252
         pipelineDescriptor.colorAttachments.Value(0).blendingEnabled = false;
251 253
         pipelineDescriptor.colorAttachments.Value(0).sourceRGBBlendFactor = DKBlendFactor::SourceAlpha;
252 254
         pipelineDescriptor.colorAttachments.Value(0).destinationRGBBlendFactor = DKBlendFactor::OneMinusSourceAlpha;
253
-		pipelineDescriptor.depthStencilAttachmentPixelFormat = DKPixelFormat::D32Float; // no depth buffer
254
-		pipelineDescriptor.vertexDescriptor.attributes = {
255
+        // setup depth-stencil
256
+		pipelineDescriptor.depthStencilAttachmentPixelFormat = DKPixelFormat::D32Float;
257
+        pipelineDescriptor.depthStencilDescriptor.depthWriteEnabled = true;
258
+        pipelineDescriptor.depthStencilDescriptor.depthCompareFunction = DKCompareFunctionLessEqual;
259
+        // setup vertex buffer and attributes
260
+        pipelineDescriptor.vertexDescriptor.attributes = {
255 261
 			{ DKVertexFormat::Float3, offsetof(SampleObjMesh::Vertex, inPos), 0, 0 },
256 262
             { DKVertexFormat::Float3, offsetof(SampleObjMesh::Vertex, inColor), 0, 1 },
257 263
 			{ DKVertexFormat::Float2, offsetof(SampleObjMesh::Vertex, intexCoord), 0, 2 },
@@ -259,6 +265,7 @@ public:
259 265
 		pipelineDescriptor.vertexDescriptor.layouts = {
260 266
 			{ DKVertexStepRate::Vertex, sizeof(SampleObjMesh::Vertex), 0 },
261 267
 		};
268
+        // setup topology and rasterization
262 269
 		pipelineDescriptor.primitiveTopology = DKPrimitiveType::Triangle;
263 270
 		pipelineDescriptor.frontFace = DKFrontFace::CCW;
264 271
 		pipelineDescriptor.triangleFillMode = DKTriangleFillMode::Fill;
@@ -266,12 +273,6 @@ public:
266 273
 		pipelineDescriptor.cullMode = DKCullMode::Back;
267 274
 		pipelineDescriptor.rasterizationEnabled = true;
268 275
 
269
-
270
-		pipelineDescriptor.depthStencilDescriptor.depthWriteEnabled = true;
271
-		pipelineDescriptor.depthStencilDescriptor.depthCompareFunction = DKCompareFunction::DKCompareFunctionLess;
272
-		pipelineDescriptor.depthStencilDescriptor.frontFaceStencil.stencilCompareFunction = DKCompareFunction::DKCompareFunctionNever;
273
-		pipelineDescriptor.depthStencilDescriptor.backFaceStencil.stencilCompareFunction = DKCompareFunction::DKCompareFunctionNever;
274
-
275 276
 		DKPipelineReflection reflection;
276 277
 		DKObject<DKRenderPipelineState> pipelineState = device->CreateRenderPipeline(pipelineDescriptor, &reflection);
277 278
 		if (pipelineState)
@@ -333,10 +334,10 @@ public:
333 334
         DKObject<DKTexture> depthBuffer = nullptr;
334 335
 
335 336
         DKCamera camera;
336
-        DKVector3 cameraPosition = { 0, 0, 10 };
337
+        DKVector3 cameraPosition = { 0, 5, 10 };
337 338
         DKVector3 cameraTartget = { 0, 0, 0 };
338 339
 		
339
-        DKAffineTransform3 tm(DKLinearTransform3().Scale(4));
340
+        DKAffineTransform3 tm(DKLinearTransform3().Scale(5).Rotate(DKVector3(-1,0,0), DKGL_PI * 0.5));
340 341
 
341 342
         DKTimer timer;
342 343
 		timer.Reset();