Browse Source

샘플 코드

Heedong Lee 5 years ago
parent
commit
34e2209cf5
1 changed files with 10 additions and 4 deletions
  1. 10
    4
      Samples/Mesh/Mesh.cpp

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

@@ -250,7 +250,7 @@ public:
250 250
         pipelineDescriptor.colorAttachments.Value(0).blendingEnabled = false;
251 251
         pipelineDescriptor.colorAttachments.Value(0).sourceRGBBlendFactor = DKBlendFactor::SourceAlpha;
252 252
         pipelineDescriptor.colorAttachments.Value(0).destinationRGBBlendFactor = DKBlendFactor::OneMinusSourceAlpha;
253
-		pipelineDescriptor.depthStencilAttachmentPixelFormat = DKPixelFormat::Invalid; // no depth buffer
253
+		pipelineDescriptor.depthStencilAttachmentPixelFormat = DKPixelFormat::D32Float; // no depth buffer
254 254
 		pipelineDescriptor.vertexDescriptor.attributes = {
255 255
 			{ DKVertexFormat::Float3, offsetof(SampleObjMesh::Vertex, inPos), 0, 0 },
256 256
             { DKVertexFormat::Float3, offsetof(SampleObjMesh::Vertex, inColor), 0, 1 },
@@ -263,9 +263,15 @@ public:
263 263
 		pipelineDescriptor.frontFace = DKFrontFace::CCW;
264 264
 		pipelineDescriptor.triangleFillMode = DKTriangleFillMode::Fill;
265 265
 		pipelineDescriptor.depthClipMode = DKDepthClipMode::Clip;
266
-		pipelineDescriptor.cullMode = DKCullMode::None;
266
+		pipelineDescriptor.cullMode = DKCullMode::Back;
267 267
 		pipelineDescriptor.rasterizationEnabled = true;
268 268
 
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
+
269 275
 		DKPipelineReflection reflection;
270 276
 		DKObject<DKRenderPipelineState> pipelineState = device->CreateRenderPipeline(pipelineDescriptor, &reflection);
271 277
 		if (pipelineState)
@@ -329,7 +335,7 @@ public:
329 335
         DKCamera camera;
330 336
         DKVector3 cameraPosition = { 0, 0, 10 };
331 337
         DKVector3 cameraTartget = { 0, 0, 0 };
332
-
338
+		
333 339
         DKAffineTransform3 tm(DKLinearTransform3().Scale(4));
334 340
 
335 341
         DKTimer timer;
@@ -363,7 +369,7 @@ public:
363 369
                 texDesc.mipmapLevels = 1;
364 370
                 texDesc.sampleCount = 1;
365 371
                 texDesc.arrayLength = 1;
366
-                texDesc.usage = DKTexture::UsageShaderWrite | DKTexture::UsageRenderTarget;
372
+                texDesc.usage = DKTexture::UsageRenderTarget;
367 373
                 depthBuffer = device->CreateTexture(texDesc);
368 374
             }
369 375
             rpd.depthStencilAttachment.renderTarget = depthBuffer;