20.6 C
New York
Thursday, June 12, 2025

Vulkan vertex from behind wanting via


I’m making an attempt to render a .obj Mannequin with Vulkan 1.4. The thing turns with a quaternion over time. He "brow" The geometry of the mannequin is represented as anticipated, however when the mannequin rotates and reveals the again, some elements of the geometry from the entrance are peeked via the mannequin. I’ve tried a mannequin with a texture, and the again of the mannequin appears clear.

He VkPipeline I’ve configured the one which follows the depth code of the vulkan-tutorial khronos 1

VkPipelineShaderStageCreateInfo shader_stages(info->shader_count);
for (size_t i = 0; i < info->shader_count; ++i) {
    shader_stages(i) = (VkPipelineShaderStageCreateInfo) {
        .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
        .stage = (VkShaderStageFlagBits)info->shaders(i)->module.shader_stage,
        .module = info->shaders(i)->deal with,
        .pName = "essential",
    };
}

const VkPipelineVertexInputStateCreateInfo vertex_input = {
    .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
};

const VkPipelineInputAssemblyStateCreateInfo input_assembly = {
    .sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
    .topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
    .primitiveRestartEnable = VK_FALSE,
};

const VkPipelineViewportStateCreateInfo viewport = {
    .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
    .viewportCount = 1,
    .scissorCount = 1,
};

const VkPipelineRasterizationStateCreateInfo rasterization = {
    .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
    .depthClampEnable = VK_FALSE,
    .rasterizerDiscardEnable = VK_FALSE,
    .polygonMode = VK_POLYGON_MODE_FILL,
    .cullMode = VK_CULL_MODE_BACK_BIT,
    .frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE,
    .lineWidth = 1.f,
    .depthBiasEnable = VK_FALSE,
};

const VkPipelineMultisampleStateCreateInfo multisampling = {
    .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
    .sampleShadingEnable = VK_FALSE,
    .rasterizationSamples = VK_SAMPLE_COUNT_1_BIT,
    .minSampleShading = 0.0f,
    .pSampleMask = NULL,
    .alphaToCoverageEnable = VK_FALSE,
    .alphaToOneEnable = VK_FALSE,
};

const VkPipelineDepthStencilStateCreateInfo depth_stencil = {
    .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
    .depthTestEnable = VK_TRUE,
    .depthWriteEnable = VK_TRUE,
    .depthCompareOp = VK_COMPARE_OP_GREATER_OR_EQUAL,
    .depthBoundsTestEnable = VK_FALSE,
    .stencilTestEnable = VK_FALSE,
};

const VkPipelineColorBlendAttachmentState color_blend =  VK_COLOR_COMPONENT_A_BIT,
    .blendEnable = VK_FALSE,
;

const VkPipelineColorBlendStateCreateInfo color_blending = {
    .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
    .logicOpEnable = VK_FALSE,
    .logicOp = VK_LOGIC_OP_COPY,
    .attachmentCount = 1,
    .pAttachments = &color_blend,
    .blendConstants(0) = 0.f,
    .blendConstants(1) = 0.f,
    .blendConstants(2) = 0.f,
    .blendConstants(3) = 0.f,
};

const VkDynamicState dynamic_states() = {
    VK_DYNAMIC_STATE_VIEWPORT,
    VK_DYNAMIC_STATE_SCISSOR,
};

const VkPipelineDynamicStateCreateInfo dynamic_state = {
    .sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
    .dynamicStateCount = ARRAY_SIZE(dynamic_states),
    .pDynamicStates = dynamic_states,
};

const VkPipelineRenderingCreateInfo rendering = {
    .sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO,
    .colorAttachmentCount = 1,
    .pColorAttachmentFormats = &info->shade,
    .depthAttachmentFormat = VK_FORMAT_D32_SFLOAT,
};

const VkGraphicsPipelineCreateInfo pipeline_info = {
    .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
    .pNext = &rendering,
    .stageCount = ARRAY_SIZE(shader_stages),
    .pStages = shader_stages,
    .pVertexInputState = &vertex_input,
    .pInputAssemblyState = &input_assembly,
    .pViewportState = &viewport,
    .pRasterizationState = &rasterization,
    .pMultisampleState = &multisampling,
    .pDepthStencilState = &depth_stencil,
    .pColorBlendState = &color_blending,
    .pDynamicState = &dynamic_state,
    .format = pipeline->format,
    .renderPass = NULL,
    .basePipelineHandle = VK_NULL_HANDLE,
};

The colour accent is utilizing the format VK_FORMAT_R8G8B8A8_SRGB and depth VK_FORMAT_D32_SFLOAT When rendering with VkRenderingInfo.

Right here is the entrance of a shade Suzanne, you possibly can see that the ear seems by way of the face to the precise

And the again, with the geometry of the face that appeared.

Enter the image description here

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles