comparison tests/test_gltf.nim @ 1323:3ba2c180e52c

fix: missing changes in tests
author sam <sam@basx.dev>
date Thu, 15 Aug 2024 18:37:00 +0700
parents 385dbd68a947
children df3c075e5dea
comparison
equal deleted inserted replaced
1322:4a1c2b1128bc 1323:3ba2c180e52c
29 # emissiveTexture: int32 = -1 29 # emissiveTexture: int32 = -1
30 MainDescriptors = object 30 MainDescriptors = object
31 materials: array[50, GPUValue[Material, UniformBuffer]] 31 materials: array[50, GPUValue[Material, UniformBuffer]]
32 camera: GPUValue[Camera, UniformBufferMapped] 32 camera: GPUValue[Camera, UniformBufferMapped]
33 Shader = object 33 Shader = object
34 objectData {.PushConstantAttribute.}: ObjectData 34 objectData {.PushConstant.}: ObjectData
35 position {.VertexAttribute.}: Vec3f 35 position {.VertexAttribute.}: Vec3f
36 color {.VertexAttribute.}: Vec4f 36 color {.VertexAttribute.}: Vec4f
37 normal {.VertexAttribute.}: Vec3f 37 normal {.VertexAttribute.}: Vec3f
38 fragmentPosition {.Pass.}: Vec3f 38 fragmentPosition {.Pass.}: Vec3f
39 fragmentColor {.Pass.}: Vec4f 39 fragmentColor {.Pass.}: Vec4f
40 fragmentNormal {.Pass.}: Vec3f 40 fragmentNormal {.Pass.}: Vec3f
41 outColor {.ShaderOutput.}: Vec4f 41 outColor {.ShaderOutput.}: Vec4f
42 descriptors {.DescriptorSets.}: (MainDescriptors, ) 42 descriptors {.DescriptorSet: 0.}: MainDescriptors
43 # code 43 # code
44 vertexCode: string = """ 44 vertexCode: string = """
45 void main() { 45 void main() {
46 mat4 modelView = objectData.transform * camera.view; 46 mat4 modelView = objectData.transform * camera.view;
47 mat3 normalMat = mat3(transpose(inverse(objectData.transform))); 47 mat3 normalMat = mat3(transpose(inverse(objectData.transform)));
109 occlusionTexture: "occlusionTexture", 109 occlusionTexture: "occlusionTexture",
110 emissiveTexture: "emissiveTexture", 110 emissiveTexture: "emissiveTexture",
111 emissiveFactor: "emissive", 111 emissiveFactor: "emissive",
112 ) 112 )
113 ) 113 )
114 var descriptors = asDescriptorSet( 114 var descriptors = asDescriptorSetData(
115 MainDescriptors( 115 MainDescriptors(
116 camera: asGPUValue(Camera( 116 camera: asGPUValue(Camera(
117 view: Unit4, 117 view: Unit4,
118 normal: Unit4, 118 normal: Unit4,
119 projection: Unit4, 119 projection: Unit4,
183 withNextFrame(framebuffer, commandbuffer): 183 withNextFrame(framebuffer, commandbuffer):
184 184
185 withRenderPass(vulkan.swapchain.renderPass, framebuffer, commandbuffer, vulkan.swapchain.width, vulkan.swapchain.height, vec4(0, 0, 0, 0)): 185 withRenderPass(vulkan.swapchain.renderPass, framebuffer, commandbuffer, vulkan.swapchain.width, vulkan.swapchain.height, vec4(0, 0, 0, 0)):
186 186
187 withPipeline(commandbuffer, pipeline): 187 withPipeline(commandbuffer, pipeline):
188 withBind(commandbuffer, (descriptors, ), pipeline): 188 bindDescriptorSet(commandbuffer, descriptors, 0, pipeline)
189 for nodeId in gltfData.scenes[0]: 189 for nodeId in gltfData.scenes[0]:
190 drawNode( 190 drawNode(
191 commandbuffer = commandbuffer, 191 commandbuffer = commandbuffer,
192 pipeline = pipeline, 192 pipeline = pipeline,
193 nodeId = nodeId, 193 nodeId = nodeId,
194 transform = rotate(PI / 2, Z) 194 transform = rotate(PI / 2, Z)
195 ) 195 )
196 196
197 # cleanup 197 # cleanup
198 checkVkResult vkDeviceWaitIdle(vulkan.device) 198 checkVkResult vkDeviceWaitIdle(vulkan.device)
199 destroyPipeline(pipeline) 199 destroyPipeline(pipeline)
200 destroyRenderData(renderdata) 200 destroyRenderData(renderdata)