在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:SaschaWillems/Vulkan开源软件地址:https://github.com/SaschaWillems/Vulkan开源编程语言:GLSL 41.4%开源软件介绍:Vulkan C++ examples and demosA comprehensive collection of open source C++ examples for Vulkan®, the new generation graphics and compute API from Khronos. Table of Contents
Official Khronos Vulkan SamplesKhronos recently made an official Vulkan Samples repository available to the public (press release). You can find this repository at https://github.com/KhronosGroup/Vulkan-Samples As I've been involved with getting the official repository up and running, I'll be mostly contributing to that repository from now, but may still add samples that don't fit there in here and I'll of course continue to maintain these samples. CloningThis repository contains submodules for external dependencies, so when doing a fresh clone you need to clone recursively:
Existing repositories can be updated manually:
AssetsMany examples require assets from the asset pack that is not part of this repository due to file size. A python script is included to download the asset pack that. Run
from the root of the repository after cloning or see this for manual download. BuildingThe repository contains everything required to compile and build the examples on Windows, Linux, Android, iOS and macOS (using MoltenVK) using a C++ compiler that supports C++11. See BUILD.md for details on how to build for the different platforms. RunningOnce built, examples can be run from the bin directory. The list of available command line options can be brought up with
Note that some examples require specific device features, and if you are on a multi-gpu system you might need to use the ShadersVulkan consumes shaders in an intermediate representation called SPIR-V. This makes it possible to use different shader languages by compiling them to that bytecode format. The primary shader language used here is GLSL but thanks to an external contribution you'll also find HLSL shader sources. A note on synchronizationSynchronization in the master branch currently isn't optimal und uses ExamplesBasicsFirst triangleBasic and verbose example for getting a colored triangle rendered to the screen using Vulkan. This is meant as a starting point for learning Vulkan from the ground up. A huge part of the code is boilerplate that is abstracted away in later examples. PipelinesUsing pipeline state objects (pso) that bake state information (rasterization states, culling modes, etc.) along with the shaders into a single object, making it easy for an implementation to optimize usage (compared to OpenGL's dynamic state machine). Also demonstrates the use of pipeline derivatives. Descriptor setsDescriptors are used to pass data to shader binding points. Sets up descriptor sets, layouts, pools, creates a single pipeline based on the set layout and renders multiple objects with different descriptor sets. Dynamic uniform buffersDynamic uniform buffers are used for rendering multiple objects with multiple matrices stored in a single uniform buffer object. Individual matrices are dynamically addressed upon descriptor binding time, minimizing the number of required descriptor sets. Push constantsUses push constants, small blocks of uniform data stored within a command buffer, to pass data to a shader without the need for uniform buffers. Specialization constantsUses SPIR-V specialization constants to create multiple pipelines with different lighting paths from a single "uber" shader. Texture mappingLoads a 2D texture from disk (including all mip levels), uses staging to upload it into video memory and samples from it using combined image samplers. Texture arraysLoads a 2D texture array containing multiple 2D texture slices (each with its own mip chain) and renders multiple meshes each sampling from a different layer of the texture. 2D texture arrays don't do any interpolation between the slices. Cube map texturesLoads a cube map texture from disk containing six different faces. All faces and mip levels are uploaded into video memory, and the cubemap is displayed on a skybox as a backdrop and on a 3D model as a reflection. Cube map arraysLoads an array of cube map textures from a single file. All cube maps are uploaded into video memory with their faces and mip levels, and the selected cubemap is displayed on a skybox as a backdrop and on a 3D model as a reflection. 3D texturesGenerates a 3D texture on the cpu (using perlin noise), uploads it to the device and samples it to render an animation. 3D textures store volumetric data and interpolate in all three dimensions. Input attachmentsUses input attachments to read framebuffer contents from a previous sub pass at the same pixel position within a single render pass. This can be used for basic post processing or image composition (blog entry). Sub passesAdvanced example that uses sub passes and input attachments to write and read back data from framebuffer attachments (same location only) in single render pass. This is used to implement deferred render composition with added forward transparency in a single pass. Offscreen renderingBasic offscreen rendering in two passes. First pass renders the mirrored scene to a separate framebuffer with color and depth attachments, second pass samples from that color attachment for rendering a mirror surface. CPU particle systemImplements a simple CPU based particle system. Particle data is stored in host memory, updated on the CPU per-frame and synchronized with the device before it's rendered using pre-multiplied alpha. Stencil bufferUses the stencil buffer and its compare functionality for rendering a 3D model with dynamic outlines. Vertex attributesDemonstrates two different ways of passing vertices to the vertex shader using either interleaved or separate vertex attributes. glTFThese samples show how implement different features of the glTF 2.0 3D format 3D transmission file format in detail. glTF model loading and renderingShows how to load a complete scene from a glTF 2.0 file. The structure of the glTF 2.0 scene is converted into the data structures required to render the scene with Vulkan. glTF vertex skinningDemonstrates how to do GPU vertex skinning from animation data stored in a glTF 2.0 model. Along with reading all the data structures required for doing vertex skinning, the sample also shows how to upload animation data to the GPU and how to render it using shaders. glTF scene renderingRenders a complete scene loaded from an glTF 2.0 file. The sample is based on the glTF model loading sample, and adds data structures, functions and shaders required to render a more complex scene using Crytek's Sponza model with per-material pipelines and normal mapping. AdvancedMulti samplingImplements multisample anti-aliasing (MSAA) using a renderpass with multisampled attachments and resolve attachments that get resolved into the visible frame buffer. High dynamic rangeImplements a high dynamic range rendering pipeline using 16/32 bit floating point precision for all internal formats, textures and calculations, including a bloom pass, manual exposure and tone mapping. Shadow mappingRendering shadows for a directional light source. First pass stores depth values from the light's pov, second pass compares against these to check if a fragment is shadowed. Uses depth bias to avoid shadow artifacts and applies a PCF filter to smooth shadow edges. Cascaded shadow mappingUses multiple shadow maps (stored as a layered texture) to increase shadow resolution for larger scenes. The camera frustum is split up into multiple cascades with corresponding layers in the shadow map. Layer selection for shadowing depth compare is then done by comparing fragment depth with the cascades' depths ranges. Omnidirectional shadow mappingUses a dynamic floating point cube map to implement shadowing for a point light source that casts shadows in all directions. The cube map is updated every frame and stores distance to the light source for each fragment used to determine if a fragment is shadowed. Run-time mip-map generationGenerating a complete mip-chain at runtime instead of loading it from a file, by blitting from one mip level, starting with the actual texture image, down to the next smaller size until the lower 1x1 pixel end of the mip chain. Capturing screenshotsCapturing and saving an image after a scene has been rendered using blits to copy the last swapchain image from optimal device to host local linear memory, so that it can be stored into a ppm image. Order Independent TransparencyImplements order independent transparency based on linked lists. To achieve this, the sample uses storage buffers in combination with image load and store atomic operations in the fragment shader. PerformanceMulti threaded command buffer generationMulti threaded parallel command buffer generation. Instead of prebuilding and reusing the same command buffers this sample uses multiple hardware threads to demonstrate parallel per-frame recreation of secondary command buffers that are executed and submitted in a primary buffer once all threads have finished. InstancingUses the instancing feature for rendering many instances of the same mesh from a single vertex buffer with variable parameters and textures (indexing a layered texture). Instanced data is passed using a secondary vertex buffer. Indirect drawingRendering thousands of instanced objects with different geometry using one single indirect draw call instead of issuing separate draws. All draw commands to be executed are stored in a dedicated indirect draw buffer object (storing index count, offset, instance count, etc.) that is uploaded to the device and sourced by the indirect draw command for rendering. Occlusion queriesUsing query pool objects to get number of passed samples for rendered primitives got determining on-screen visibility. Pipeline statisticsUsing query pool objects to gather statistics from different stages of the pipeline like vertex, fragment shader and tessellation evaluation shader invocations depending on payload. Physically Based RenderingPhysical based rendering as a lighting technique that achieves a more realistic and dynamic look by applying approximations of bidirectional reflectance distribution functions based on measured real-world material parameters and environment lighting. PBR basicsDemonstrates a basic specular BRDF implementation with solid materials and fixed light sources on a grid of objects with varying material parameters, demonstrating how metallic reflectance and surface roughness affect the appearance of pbr lit objects. PBR image based lightingAdds image based lighting from an hdr environment cubemap to the PBR equation, using the surrounding environment as the light source. This adds an even more realistic look the scene as the light contribution used by the materials is now controlled by the environment. Also shows how to generate the BRDF 2D-LUT and irradiance and filtered cube maps from the environment map. Textured PBR with IBLRenders a model specially crafted for a metallic-roughness PBR workflow with textures defining material parameters for the PRB equation (albedo, metallic, roughness, baked ambient occlusion, normal maps) in an image based lighting environment. DeferredThese examples use a deferred shading setup. Deferred shading basicsUses multiple render targets to fill all attachments (albedo, normals, position, depth) required for a G-Buffer in a single pass. A deferred pass then uses these to calculate shading and lighting in screen space, so that calculations only have to be done for visible fragments independent of no. of lights. Deferred multi samplingAdds multi sampling to a deferred renderer using manual resolve in the fragment shader. Deferred shading shadow mappingAdds shadows from multiple spotlights to a deferred renderer using a layered depth attachment filled in one pass using multiple geometry shader invocations. Screen space ambient occlusionAdds ambient occlusion in screen space to a 3D scene. Depth values from a previous deferred pass are used to generate an ambient occlusion texture that is blurred before being applied to the scene in a final composition path. Compute ShaderImage processingUses a compute shader along with a separate compute queue to apply different convolution kernels (and effects) on an input image in realtime. GPU particle systemAttraction based 2D GPU particle system using compute shaders. Particle data is stored in a shader storage buffer and only modified on the GPU using memory barriers for synchronizing compute particle updates with graphics pipeline vertex access. N-body simulationN-body simulation based particle system with multiple attractors and particle-to-particle interaction using two passes separating particle movement calculation and final integration. Shared compute shader memory is used to speed up compute calculations. Ray tracingSimple GPU ray tracer with shadows and reflections using a compute shader. No scene geometry is rendered in the graphics pass. Cloth simulationMass-spring based cloth system on the GPU using a compute shader to calculate and integrate spring forces, also implementing basic collision with a fixed scene object. Cull and LODPurely GPU based frustum visibility culling and level-of-detail system. A compute shader is used to modify draw commands stored in an indirect draw commands buffer to toggle model visibility and select its level-of-detail based on camera distance, no calculations have to be done on and synced with the CPU. Geometry Shader |