comparison tests/test_vulkan_wrapper.nim @ 316:b145a05c2459

add: changing rendering system, not finished yet, also upgrading to Nim 2
author Sam <sam@basx.dev>
date Mon, 07 Aug 2023 00:23:00 +0700
parents 4921ec86dcb4
children 30117d8f0052
comparison
equal deleted inserted replaced
315:4921ec86dcb4 316:b145a05c2459
88 vertexInput = @[ 88 vertexInput = @[
89 attr[Vec3f]("position", memoryPerformanceHint=PreferFastRead), 89 attr[Vec3f]("position", memoryPerformanceHint=PreferFastRead),
90 attr[Vec4f]("color", memoryPerformanceHint=PreferFastWrite), 90 attr[Vec4f]("color", memoryPerformanceHint=PreferFastWrite),
91 attr[Vec3f]("translate", perInstance=true) 91 attr[Vec3f]("translate", perInstance=true)
92 ] 92 ]
93 vertexOutput = @[attr[Vec4f]("outcolor")] 93 intermediate = @[attr[Vec4f]("outcolor")]
94 fragOutput = @[attr[Vec4f]("color")]
95 samplers = @[attr[Sampler2DType]("my_little_texture")]
94 uniforms = @[attr[float32]("time")] 96 uniforms = @[attr[float32]("time")]
95 samplers = @[attr[Sampler2DType]("my_little_texture")] 97 (vertexCode, fragmentCode) = compileVertexFragmentShaderSet(
96 fragOutput = @[attr[Vec4f]("color")]
97 vertexCode = compileGlslShader(
98 stage=VK_SHADER_STAGE_VERTEX_BIT,
99 inputs=vertexInput, 98 inputs=vertexInput,
99 intermediate=intermediate,
100 outputs=fragOutput,
101 samplers=samplers,
100 uniforms=uniforms, 102 uniforms=uniforms,
101 samplers=samplers, 103 vertexCode="""gl_Position = vec4(position + translate, 1.0); outcolor = color;""",
102 outputs=vertexOutput, 104 fragmentCode="color = texture(my_little_texture, outcolor.xy) * 0.5 + outcolor * 0.5;",
103 main="""gl_Position = vec4(position + translate, 1.0); outcolor = color;"""
104 )
105 fragmentCode = compileGlslShader(
106 stage=VK_SHADER_STAGE_FRAGMENT_BIT,
107 inputs=vertexOutput,
108 uniforms=uniforms,
109 samplers=samplers,
110 outputs=fragOutput,
111 main="color = texture(my_little_texture, outcolor.xy) * 0.5 + outcolor * 0.5;"
112 ) 105 )
113 var renderPass = engine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode) 106 var renderPass = engine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode)
114 engine.setRenderer(renderPass) 107 engine.setRenderer(renderPass)
115 108
116 # INIT SCENES 109 # INIT SCENES