-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new sample - dynamic line rasterization
- Loading branch information
1 parent
4d0eb95
commit 954bbf8
Showing
9 changed files
with
881 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
samples/extensions/dynamic_line_rasterization/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright (c) 2023, Mobica Limited | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 the "License"; | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
get_filename_component(FOLDER_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) | ||
get_filename_component(PARENT_DIR ${CMAKE_CURRENT_LIST_DIR} PATH) | ||
get_filename_component(CATEGORY_NAME ${PARENT_DIR} NAME) | ||
|
||
add_sample( | ||
ID ${FOLDER_NAME} | ||
CATEGORY ${CATEGORY_NAME} | ||
AUTHOR "Khronos" | ||
NAME "dynamic_line_rasterization" | ||
DESCRIPTION "Sample description" | ||
SHADER_FILES_GLSL | ||
"dynamic_line_rasterization/base.vert" | ||
"dynamic_line_rasterization/base.frag" | ||
"dynamic_line_rasterization/grid.vert" | ||
"dynamic_line_rasterization/grid.frag" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
//// | ||
- Copyright (c) 2023, Mobica Limited | ||
- | ||
- SPDX-License-Identifier: Apache-2.0 | ||
- | ||
- Licensed under the Apache License, Version 2.0 the "License"; | ||
- you may not use this file except in compliance with the License. | ||
- You may obtain a copy of the License at | ||
- | ||
- http://www.apache.org/licenses/LICENSE-2.0 | ||
- | ||
- Unless required by applicable law or agreed to in writing, software | ||
- distributed under the License is distributed on an "AS IS" BASIS, | ||
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
- See the License for the specific language governing permissions and | ||
- limitations under the License. | ||
- | ||
//// | ||
= Dynamic line rasterization | ||
|
||
== Overview | ||
|
||
This sample demonstrates functions from various extensions related to dynamic line rasterization. These functions can be useful for developing CAD applications. | ||
|
||
* From the `VK_EXT_line_rasterization` extension: | ||
** `vkCmdSetLineStippleEXT` - sets the stipple pattern. | ||
* From the `VK_EXT_extended_dynamic_state3` extension: | ||
** `vkCmdSetPolygonModeEXT` - sets how defined primitives should be rasterized. | ||
** `vkCmdSetLineRasterizationModeEXT` - sets the algorithm for line rasterization. | ||
** `vkCmdSetLineStippleEnableEXT` - toggles stippling for lines. | ||
* And also from the core Vulkan: | ||
** `vkCmdSetLineWidth` - sets the line width. | ||
** `vkCmdSetPrimitiveTopologyEXT` - defines which type of primitives is being drawn. | ||
|
||
== The sample | ||
|
||
Dynamic line rasterization contains a wireframed cube whose appearance can be modified by the user. The cube edges and filling are rendered in a single pipeline, using a different set of indices. The `vkCmdSetPrimitiveTopologyEXT` and `vkCmdSetPolygonModeEXT` functions are used to change the way they are rendered. | ||
|
||
Users can modify the line width (`vkCmdSetLineWidth`) and choose how the line is drawn (`vkCmdSetLineRasterizationModeEXT`). The sample also demonstrates the ability to stipple the line. Stippling is defined by two variables: | ||
|
||
** `lineStipplePattern` - a `uint16_t` where each bit represents whether a point on the line is colored (1) or transparent (0). | ||
** `lineStippleFactor` - a factor used to determine how many consecutive points are affected by a single pattern bit. | ||
|
||
The sample also contains a grid rendered beneath the cube using a different pipeline. This grid represents another approach to line rasterization based on the fragment shader. Consequently, the appearance of the gridlines cannot be modified by the user. | ||
|
||
== Credits | ||
|
||
The infinite grid shader is based on the code from the https://asliceofrendering.com/scene%20helper/2020/01/05/InfiniteGrid/[asliceofrendering.com] blog. | ||
|
||
== Documentation links | ||
|
||
https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdSetLineStippleEXT.html | ||
|
||
https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdSetPolygonModeEXT.html | ||
|
||
https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdSetLineRasterizationModeEXT.html | ||
|
||
https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdSetLineStippleEnableEXT.html | ||
|
||
https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdSetLineWidth.html |
Oops, something went wrong.