As an information, Vulkan is a low-level abstraction layer thru modern GPU. It allows programmers to program the GPU and assemble rendering pipeline. On that pipeline, there are modules of program which are called "shaders". As a programmer, we only have control on programmable shaders, not fixed shaders. For simplicity, let's only use two types of programmable shaders:
Vertex Shader
A program for calculating geometric transformation for each point. Every 3 points always represent a triangle, but can be configured to be 3 lines or 3 dots.
Fragment Shader
This is per-pixel program to calculate color for each pixel on that triangles (or lines).
From those shaders, I would like to implement bezier curve (for shape) and scanline algorithm for fill color, rendered with GPU. The planned result would be like this.
The Problem
- To draw Bezier lines, pixel position must be set. Whereas in fragment shader, the pixel position cannot be set by programmer because GPU already set the position.
- As far as I know, generating curved lines is not possible by only set control points as vertices. Any workaround for this problem?
- Even if the bezier can be drawn by GPU, how do I implement scanline algorithm for adding fill color with fragment shader?
NOTE: I already explored learning resources via internet. However, none of them actually talks about bezier curve + scanline algorithm implementation with Vulkan. Perhaps I missed something? Please let me know