将MVP颠倒后的Vulkan淘汰问题

我在android设备上运行了vulkan渲染器,结果图像颠倒了。 我不想在VkViewport定义中设置负高度,因为有代码和注释建议将矩阵倒置为Y。

我尝试在以下代码中反转mvp [5]矩阵数组的符号,但是在渲染的图像中出现了剔除问题。

<?php


class Academy{
  /*
    other code
  */

    public function __toString(){
      $programsArray = [];
      $programsArray['academy_programs'] = [];

      foreach ($this->getPrograms() as $program) {
        $programsArray['academy_programs'][] = [
          'academy_program' => [
            'program_name' => $program->getProgramName(),'program_price' => $program->getProgramPrice()
          ]
        ];
      }


      return json_encode($programsArray); // json representation
    }
}


$academy = new Academy();
/*
all the other jazz
*/

echo $academy; // this would invoke the __toString() method and will give you the json representation as output.

我知道z轴会以某种方式反转,但是目前我不知道该如何解决。

wangjiaxing85 回答:将MVP颠倒后的Vulkan淘汰问题

要在Y轴上翻转矩阵:

mvp[5] = -mvp[5];
mvp[7] = -mvp[7];

然后,可以在VkPipelineRasterizationStateCreateInfo结构中反转剔除顺序:

// with frontFace field,replace:
createInfo.frontFace = VK_FRONT_FACE_CLOCKWISE;
// by:
createInfo.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;

// OR with cullMode field,replace:
createInfo.cullMode = VK_CULL_MODE_FRONT_BIT;
// by:
createInfo.cullMode = VK_CULL_MODE_BACK_BIT;
本文链接:https://www.f2er.com/3037624.html

大家都在问