# HG changeset patch # User sam # Date 1734159088 -25200 # Node ID ec9f19151d440b1599cc1c31d276ae6e2ffdd04f # Parent c8d1b87cf6c89fa7439127d5c8debd20a8a080cb sync to notebook in bedroom diff -r c8d1b87cf6c8 -r ec9f19151d44 semicongine/rendering/shaders.nim --- a/semicongine/rendering/shaders.nim Thu Dec 12 23:54:49 2024 +0700 +++ b/semicongine/rendering/shaders.nim Sat Dec 14 13:51:28 2024 +0700 @@ -492,6 +492,7 @@ if l.Valid: layouts.add l + # TODO: only add pushConstants if shader actually uses them let pushConstant = VkPushConstantRange( stageFlags: VkShaderStageFlags(VK_SHADER_STAGE_ALL_GRAPHICS), offset: 0, diff -r c8d1b87cf6c8 -r ec9f19151d44 semicongine/text.nim --- a/semicongine/text.nim Thu Dec 12 23:54:49 2024 +0700 +++ b/semicongine/text.nim Sat Dec 14 13:51:28 2024 +0700 @@ -98,13 +98,14 @@ const int[6] indices = int[](0, 1, 2, 2, 3, 0); const int[4] i_x = int[](0, 0, 2, 2); const int[4] i_y = int[](1, 3, 3, 1); -const vec2[4] pp = vec2[](vec2(-0.1, -0.1), vec2(-0.1, 0.1), vec2(0.1, 0.1), vec2(0.1, -0.1)); +// const float epsilon = 0.000000000000001; +const float epsilon = 0.01; void main() { int vertexI = indices[gl_VertexIndex]; vec3 pos = vec3(glyphData.pos[glyphIndex][i_x[vertexI]], glyphData.pos[glyphIndex][i_y[vertexI]], 0); vec2 uv = vec2(glyphData.uv[glyphIndex][i_x[vertexI]], glyphData.uv[glyphIndex][i_y[vertexI]]); - gl_Position = vec4(pos * scale + position, 1.0); + gl_Position = vec4(pos * scale + position, 1.0) + vec4(0, 0, 0, gl_VertexIndex * epsilon); fragmentUv = uv; fragmentColor = color; } """ @@ -112,10 +113,12 @@ """void main() { float v = texture(fontAtlas, fragmentUv).r; // CARFULL: This can lead to rough edges at times - if(v == 0) { - discard; - } - outColor = vec4(fragmentColor.rgb, fragmentColor.a * v); + // if(v == 0) { + // discard; + // } + // outColor = vec4(fragmentColor.rgb, fragmentColor.a * v); + // outColor = fragmentColor; + outColor = vec4(1, 1, 1, v); }""" proc `=copy`(dest: var FontObj, source: FontObj) {.error.} diff -r c8d1b87cf6c8 -r ec9f19151d44 tests/test_text.nim --- a/tests/test_text.nim Thu Dec 12 23:54:49 2024 +0700 +++ b/tests/test_text.nim Sat Dec 14 13:51:28 2024 +0700 @@ -24,11 +24,11 @@ createPipeline[GlyphShader[N_GLYPHS]](renderPass = vulkan.swapchain.renderPass) var (ds, glyphtable) = glyphDescriptorSet(font, N_GLYPHS) var glyphs = Glyphs( - position: asGPUArray([vec3(), vec3()], VertexBufferMapped), + position: asGPUArray([vec3(0, 0, 0), vec3(0, 0, 0)], VertexBufferMapped), scale: asGPUArray([1'f32, 1'f32], VertexBufferMapped), color: asGPUArray([vec4(1, 1, 1, 1), vec4(1, 1, 1, 1)], VertexBufferMapped), glyphIndex: - asGPUArray([glyphtable[Rune('Q')], glyphtable[Rune('H')]], VertexBufferMapped), + asGPUArray([glyphtable[Rune('A')], glyphtable[Rune('B')]], VertexBufferMapped), ) assignBuffers(renderdata, glyphs) @@ -49,7 +49,14 @@ vec4(0, 0, 0, 0), ): withPipeline(commandbuffer, pipeline): - render(commandbuffer, pipeline, EMPTY(), glyphs, fixedVertexCount = 6) + render( + commandbuffer, + pipeline, + EMPTY(), + glyphs, + fixedVertexCount = 6, + fixedInstanceCount = 2, + ) # cleanup checkVkResult vkDeviceWaitIdle(vulkan.device)