![]() Tessellation evaluation shader is the actual workhorse of the whole application - all the magic happens here.įirst, we specify tesselation rules: domain ( quads), spacing ( fractional_odd_spacing), and winding order ( cw - clockwise). And the number of executions of this shader is equal to the number of specified points per patch times the number of patches, i.e. we don’t change the amount (yes, this stage can generate new points as well as remove some). Next, we tell the GPU that this stage produces 16 control points for the patch, i.e. You can see in PushConst definition that the tessellation level is a float variable. For now, it’s enough to know that it’s a fast and simple way to update data and later we’ll see what this means exactly when we’ll reach this in the code. I decided to use a so-called Push Constant - a feature that allows passing a constant directly in a command buffer. The first one is how the tessellation level (how many new triangles a tessellator should create) is updated. But still, it has a couple of interesting moments. The next shader - tessellation control shader - is simple as well and it doesn’t do a lot of work. I decided to use a storage buffer instead of vertex attributes - it simplifies the code a bit. Since there are 28 patches, 16 points each, it will be called at most 28 * 16 = 448 times or less because of caching (it’s not important information, just for fun). This stage will be executed for every point (vertex). Looking at the teapot data, we know what information needs to be passed - since we’re using patches, we need points to describe them - 16 points per patch.Ī patch point arrives in the shader via ControlPointBuffer in a binding slot 0 (resources are bound to special positions or slots - more on this in next tutorials) and is simply passed through to the next stage. Vertex shader is the first programmable stage in the pipeline, and it’s pretty simple. ![]() Let’s step over all of our shaders, briefly explaining the purpose of each. In the app, we will use 4 shader stages - Vertex, Tesselation Control, Tesselation Evaluation, Fragment. After all, this is exactly what GPU executes, and we’re here to program the GPU. I’d suggest starting from the heart of every graphics application - shaders. ![]() The main question for now - where to start? There are so many things to do, there are so many ways to do it. The window is put in a separate category because the presentation of the picture is controlled by an OS and not by an application or a GPU. For now, it’s enough to know that there’s a CPU, which controls the application and sends commands to the GPU a GPU itself, which does the magic and produces nice pictures (not necessarily) a window that should present these pictures. The diagram is pretty empty for now but it will grow as we progress through the tutorials. Here is the diagram of the current state of the application: In the previous lesson, we made all necessary preparations to start exploring Vulkan. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |