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