├── .gitmodules ├── README.md └── assets ├── breather.png ├── complex-surface.png ├── complex-surface1.png ├── klein-bottle.png ├── multiple-objects.png ├── sievert-enneper.png ├── sinc.png ├── snail-shell.png ├── textures.png ├── webgpu01.png ├── wellenkugel.png ├── wgpu01.png ├── wgpuexamples01.png └── wgpupy01.png /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "wgpu02"] 2 | path = wgpu02 3 | url = https://github.com/jack1232/wgpu02 4 | [submodule "wgpu03"] 5 | path = wgpu03 6 | url = https://github.com/jack1232/wgpu03 7 | [submodule "wgpu04"] 8 | path = wgpu04 9 | url = https://github.com/jack1232/wgpu04 10 | [submodule "wgpu06"] 11 | path = wgpu06 12 | url = https://github.com/jack1232/wgpu06 13 | [submodule "wgpu07"] 14 | path = wgpu07 15 | url = https://github.com/jack1232/wgpu07 16 | [submodule "wgpu08"] 17 | path = wgpu08 18 | url = https://github.com/jack1232/wgpu08 19 | [submodule "wgpu09"] 20 | path = wgpu09 21 | url = https://github.com/jack1232/wgpu09 22 | [submodule "wgpu10"] 23 | path = wgpu10 24 | url = https://github.com/jack1232/wgpu10 25 | [submodule "wgpu11"] 26 | path = wgpu11 27 | url = https://github.com/jack1232/wgpu11 28 | [submodule "wgpu12"] 29 | path = wgpu12 30 | url = https://github.com/jack1232/wgpu12 31 | [submodule "wgpu13"] 32 | path = wgpu13 33 | url = https://github.com/jack1232/wgpu13 34 | [submodule "wgpu14"] 35 | path = wgpu14 36 | url = https://github.com/jack1232/wgpu14 37 | [submodule "wgpu15"] 38 | path = wgpu15 39 | url = https://github.com/jack1232/wgpu15 40 | [submodule "wgpu16"] 41 | path = wgpu16 42 | url = https://github.com/jack1232/wgpu16 43 | [submodule "wgpu17"] 44 | path = wgpu17 45 | url = https://github.com/jack1232/wgpu17 46 | [submodule "wgpu18"] 47 | path = wgpu18 48 | url = https://github.com/jack1232/wgpu18 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wgpu Graphics Programming in Rust: Step-by-Step 2 | 3 | $$\textcolor{red}{\text{Good news: all code examples have been updated from wgpu 0.13.1 to 0.17.}}$$ 4 | 5 | 6 | 7 | *wgpu* is based on the WebGPU standard. It is a cross-platform, safe, pure Rust graphics API that runs natively on Vulkan, Metal, DirectX 12, DirectX 11, and OpenGLES, as well as on the web via WebAssembly. I have created a YouTube video series about *wgpu* programming in Rust, presenting an easy-to-follow wgpu application in each video episode. This repository contains all the code examples used in this video series. 8 | 9 | In this YouTube video series, I use real-world sample apps to explain the basics of wgpu, including shader programs, GPU buffers, and rendering pipelines. Throughout the series, you will learn how to create primitives and simple objects in Rust with wgpu. As you progress, you will delve into advanced wgpu topics, such as 3D transformations, lighting calculations, colormaps, and textures. Simultaneously, you will discover how to create advanced 3D wgpu objects, including various 3D wireframes, 3D shapes, simple and parametric 3D surfaces with colormaps and textures, and 3D surface plots. Additionally, you will explore new wgpu features, such as compute shaders and storage buffers, and learn how to use them to 3D graphics. 10 | 11 | By the end of this video series, you will have the solid skills you need to build your own GPU-accelerated graphics and computing applications on native devices and the web using the wgpu API in Rust. 12 | 13 |
14 | 15 | ## Books on Rust wgpu 16 | Most of the examples used in this video series are taken from my recently published books **"Practical GPU Graphics with wgpu and Rust"** and **"WGPU by Examples"** 17 | 18 | [![wgpu Rust Book](assets/wgpu01.png)](https://drxudotnet.com)    19 | 20 | 21 | Please see details about these books at https://drxudotnet.com. 22 | 23 |
24 | 25 | ## YouTube Video Links: 26 | 27 | Please visit my YouTube channel: [Practical Programming with Dr. Xu](https://www.youtube.com/c/PracticalProgrammingWithDrXu) 28 | 29 | 30 | 31 | ### Video Series for Rust wgpu Step-by-Step: 32 | 33 | 1. Introduction to *wgpu*: https://youtu.be/i6WMfY-XTZE 34 | 2. Set up Development Environment: https://youtu.be/LULQtc5CUJ8 35 | 3. Create a Colorful Triangle: https://youtu.be/hOojFOho_lI 36 | 4. Create Point and Line Primitives: https://youtu.be/-QXj0UexUw0 37 | 5. Create Triangle Primitives: https://youtu.be/TFVjMmSRDxs 38 | 6. Create a Square using GPU Buffer: https://youtu.be/GIEjzG2wwJY 39 | 7. Create a 3D Cube: https://youtu.be/ai53VFoqdJQ 40 | 8. Animate a 3D Cube: https://youtu.be/9SsjhrxH08o 41 | 9. Light Model: https://youtu.be/YF6VepGkUJs 42 | 10. Cube with Lighting: https://youtu.be/mPbsgFYb2z8 43 | 11. Sphere with Lighting: https://youtu.be/2bW_uCOKiKc 44 | 12. Torus with Lighting: https://youtu.be/CC3stU82iZg 45 | 13. Colormap: https://youtu.be/D0wrVy7lAcg 46 | 14. 3D Simple Surfaces: https://youtu.be/XfVeMrumi7o 47 | 15. 3D Sinc Surface: https://youtu.be/O7xIQudPKmA 48 | 16. 3D Peaks Surface: https://youtu.be/6d5l2huTm9E 49 | 17. Parametric 3D Surfaces: https://youtu.be/ODLGjzR9mWY 50 | 18. Parametric 3D Surface Examples: https://youtu.be/AjDU7eegt4g 51 | 52 |
53 | 54 | ## Sample Objects 55 | Here are some sample objects created using the *wgpu* API, which I will discussed in my video series. 56 | 57 | ### Klein Bottle and Wellenkugel Surface: 58 | ![klein-bottle](assets/klein-bottle.png)        ![wellenkugel](assets/wellenkugel.png) 59 | 60 | ### Snail Shell and Sievert-Enneper Surface: 61 | ![snail-shell](assets/snail-shell.png)     ![sievert-enneper](assets/sievert-enneper.png) 62 | 63 | ### Breather Surface and 3D Sinc Surface: 64 | ![breather](assets/breather.png)     ![sinc](assets/sinc.png) 65 | 66 | ### Multiple-Textures: 67 | ![textures](assets/textures.png) 68 | 69 |
70 | 71 | ## License 72 | 73 | The MIT License (MIT). 74 | 75 | Copyright (c) 2022 Jack Xu. 76 | 77 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 78 | 79 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 80 | 81 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 82 | 83 | -------------------------------------------------------------------------------- /assets/breather.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jack1232/wgpu-step-by-step/cf57a6e110409803f2b84bb220d58456659b1c02/assets/breather.png -------------------------------------------------------------------------------- /assets/complex-surface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jack1232/wgpu-step-by-step/cf57a6e110409803f2b84bb220d58456659b1c02/assets/complex-surface.png -------------------------------------------------------------------------------- /assets/complex-surface1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jack1232/wgpu-step-by-step/cf57a6e110409803f2b84bb220d58456659b1c02/assets/complex-surface1.png -------------------------------------------------------------------------------- /assets/klein-bottle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jack1232/wgpu-step-by-step/cf57a6e110409803f2b84bb220d58456659b1c02/assets/klein-bottle.png -------------------------------------------------------------------------------- /assets/multiple-objects.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jack1232/wgpu-step-by-step/cf57a6e110409803f2b84bb220d58456659b1c02/assets/multiple-objects.png -------------------------------------------------------------------------------- /assets/sievert-enneper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jack1232/wgpu-step-by-step/cf57a6e110409803f2b84bb220d58456659b1c02/assets/sievert-enneper.png -------------------------------------------------------------------------------- /assets/sinc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jack1232/wgpu-step-by-step/cf57a6e110409803f2b84bb220d58456659b1c02/assets/sinc.png -------------------------------------------------------------------------------- /assets/snail-shell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jack1232/wgpu-step-by-step/cf57a6e110409803f2b84bb220d58456659b1c02/assets/snail-shell.png -------------------------------------------------------------------------------- /assets/textures.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jack1232/wgpu-step-by-step/cf57a6e110409803f2b84bb220d58456659b1c02/assets/textures.png -------------------------------------------------------------------------------- /assets/webgpu01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jack1232/wgpu-step-by-step/cf57a6e110409803f2b84bb220d58456659b1c02/assets/webgpu01.png -------------------------------------------------------------------------------- /assets/wellenkugel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jack1232/wgpu-step-by-step/cf57a6e110409803f2b84bb220d58456659b1c02/assets/wellenkugel.png -------------------------------------------------------------------------------- /assets/wgpu01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jack1232/wgpu-step-by-step/cf57a6e110409803f2b84bb220d58456659b1c02/assets/wgpu01.png -------------------------------------------------------------------------------- /assets/wgpuexamples01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jack1232/wgpu-step-by-step/cf57a6e110409803f2b84bb220d58456659b1c02/assets/wgpuexamples01.png -------------------------------------------------------------------------------- /assets/wgpupy01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jack1232/wgpu-step-by-step/cf57a6e110409803f2b84bb220d58456659b1c02/assets/wgpupy01.png --------------------------------------------------------------------------------