Mercurial > games > semicongine
comparison tests/test_gltf.nim @ 1248:317bb5a73606
did: continue on gltf importer
author | sam <sam@basx.dev> |
---|---|
date | Thu, 25 Jul 2024 20:23:54 +0700 |
parents | c15770761865 |
children | d83726af7abb |
comparison
equal
deleted
inserted
replaced
1247:c15770761865 | 1248:317bb5a73606 |
---|---|
10 proc test_gltf(time: float32) = | 10 proc test_gltf(time: float32) = |
11 var renderdata = InitRenderData() | 11 var renderdata = InitRenderData() |
12 | 12 |
13 type | 13 type |
14 Material = object | 14 Material = object |
15 color: Vec4f | 15 color: Vec4f = NewVec4f(1, 1, 1, 1) |
16 colorTexture: int32 = -1 | 16 colorTexture: int32 = -1 |
17 metallic: float32 = -1 | 17 metallic: float32 = 0 |
18 roughness: float32 = -1 | 18 roughness: float32 = 0 |
19 metallicRoughnessTexture: int32 = -1 | 19 metallicRoughnessTexture: int32 = -1 |
20 | 20 |
21 normalTexture: int32 = -1 | 21 normalTexture: int32 = -1 |
22 occlusionTexture: int32 = -1 | 22 occlusionTexture: int32 = -1 |
23 emissive: Vec4f = NewVec4f(-1, -1, -1, -1) | 23 emissive: Vec4f = NewVec4f(0, 0, 0, 0) |
24 emissiveTexture: int32 = -1 | 24 emissiveTexture: int32 = -1 |
25 MainDescriptors = object | 25 MainDescriptors = object |
26 material: GPUValue[Material, UniformBuffer] | 26 material: GPUValue[Material, UniformBuffer] |
27 Shader = object | 27 Shader = object |
28 position {.VertexAttribute.}: Vec3f | 28 position {.VertexAttribute.}: Vec3f |
45 color: GPUArray[Vec4f, VertexBuffer] | 45 color: GPUArray[Vec4f, VertexBuffer] |
46 uv: GPUArray[Vec2f, VertexBuffer] | 46 uv: GPUArray[Vec2f, VertexBuffer] |
47 | 47 |
48 let gltfMesh = LoadMeshes[Mesh, Material]( | 48 let gltfMesh = LoadMeshes[Mesh, Material]( |
49 "town.glb", | 49 "town.glb", |
50 baseColorFactor = "color", | 50 MeshAttributeNames( |
51 baseColorTexture = "colorTexture", | 51 POSITION: "position", |
52 metallicFactor = "metallic", | 52 COLOR: @["color"], |
53 roughnessFactor = "roughness", | 53 TEXCOORD: @["uv"], |
54 metallicRoughnessTexture = "metallicRoughnessTexture", | 54 ), |
55 normalTexture = "normalTexture", | 55 MaterialAttributeNames( |
56 occlusionTexture = "occlusionTexture", | 56 baseColorFactor: "color", |
57 emissiveTexture = "emissiveTexture", | 57 baseColorTexture: "colorTexture", |
58 emissiveFactor = "emissive", | 58 metallicFactor: "metallic", |
59 roughnessFactor: "roughness", | |
60 metallicRoughnessTexture: "metallicRoughnessTexture", | |
61 normalTexture: "normalTexture", | |
62 occlusionTexture: "occlusionTexture", | |
63 emissiveTexture: "emissiveTexture", | |
64 emissiveFactor: "emissive", | |
65 ) | |
59 ) | 66 ) |
60 var mesh = gltfMesh.meshes[0] | 67 var mesh = gltfMesh.meshes[0][0] |
61 renderdata.AssignBuffers(mesh) | 68 renderdata.AssignBuffers(mesh) |
62 renderdata.FlushAllMemory() | 69 renderdata.FlushAllMemory() |
63 | 70 |
64 var pipeline = CreatePipeline[Shader](renderPass = vulkan.swapchain.renderPass) | 71 var pipeline = CreatePipeline[Shader](renderPass = vulkan.swapchain.renderPass) |
65 | 72 |