instance transform
This commit is contained in:
parent
642cef78b1
commit
83bb8ebd61
4 changed files with 17 additions and 10 deletions
|
|
@ -4,6 +4,7 @@ import Crafter.Graphics;
|
|||
using namespace Crafter;
|
||||
import std;
|
||||
import Crafter.Event;
|
||||
import Crafter.Math;
|
||||
|
||||
typedef VulkanShader<"raygen.spv", "main", VK_SHADER_STAGE_RAYGEN_BIT_KHR, 2, {{{VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, 0}, {VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1}}}> Raygenspv;
|
||||
typedef VulkanShader<"closesthit.spv", "main", VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR, 0, {{}}> Closesthitspv;
|
||||
|
|
@ -39,7 +40,9 @@ int main() {
|
|||
std::array<Vertex, 3> verts {{{-150, -150, 100}, {0, 150, 100}, {150, -150, 100}}};
|
||||
std::array<std::uint32_t, 3> index {{2,1,0}};
|
||||
triangleMesh.Build(verts, index, cmd);
|
||||
RenderingElement3DVulkan::elements.emplace_back(triangleMesh);
|
||||
RenderingElement3DVulkan& el = RenderingElement3DVulkan::elements.emplace_back(triangleMesh);
|
||||
MatrixRowMajor<float, 4, 3, 1> transform = MatrixRowMajor<float, 4, 3, 1>::Identity();
|
||||
std::memcpy(el.instance.transform.matrix, transform.m, sizeof(transform.m));
|
||||
RenderingElement3DVulkan::tlases.resize(1);
|
||||
RenderingElement3DVulkan::BuildTLAS(cmd, 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -28,14 +28,6 @@ using namespace Crafter;
|
|||
std::vector<RenderingElement3DVulkan> RenderingElement3DVulkan::elements;
|
||||
|
||||
RenderingElement3DVulkan::RenderingElement3DVulkan(Mesh& mesh) {
|
||||
VkTransformMatrixKHR identity{};
|
||||
float tmp[3][4] = {
|
||||
{1.f, 0.f, 0.f, 0.f},
|
||||
{0.f, 1.f, 0.f, 0.f},
|
||||
{0.f, 0.f, 1.f, 0.f}
|
||||
};
|
||||
std::memcpy(identity.matrix, tmp, sizeof(tmp));
|
||||
|
||||
VkAccelerationStructureDeviceAddressInfoKHR addrInfo {
|
||||
.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_DEVICE_ADDRESS_INFO_KHR,
|
||||
.accelerationStructure = mesh.accelerationStructure
|
||||
|
|
@ -43,7 +35,6 @@ RenderingElement3DVulkan::RenderingElement3DVulkan(Mesh& mesh) {
|
|||
VkDeviceAddress blasDeviceAddr = VulkanDevice::vkGetAccelerationStructureDeviceAddressKHR(VulkanDevice::device, &addrInfo);
|
||||
|
||||
instance = {
|
||||
.transform = identity,
|
||||
.instanceCustomIndex = 0,
|
||||
.mask = 0xFF,
|
||||
.instanceShaderBindingTableRecordOffset = 0,
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ export module Crafter.Graphics:RenderingElement3DVulkan;
|
|||
import std;
|
||||
import :Mesh;
|
||||
import :VulkanBuffer;
|
||||
import Crafter.Math;
|
||||
|
||||
export namespace Crafter {
|
||||
|
||||
|
|
|
|||
12
project.json
12
project.json
|
|
@ -39,6 +39,10 @@
|
|||
{
|
||||
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Event.git",
|
||||
"configuration":"lib"
|
||||
},
|
||||
{
|
||||
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Math.git",
|
||||
"configuration":"lib"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -48,6 +52,10 @@
|
|||
{
|
||||
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Event.git",
|
||||
"configuration":"lib-timing"
|
||||
},
|
||||
{
|
||||
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Math.git",
|
||||
"configuration":"lib"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -58,6 +66,10 @@
|
|||
{
|
||||
"path":"/home/jorijn/repos/Crafter/Crafter.Event/project.json",
|
||||
"configuration":"lib-debug"
|
||||
},
|
||||
{
|
||||
"path":"/home/jorijn/repos/Crafter/Crafter.Math/project.json",
|
||||
"configuration":"lib-debug"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue