All Projects → kayru → Barycentrics

kayru / Barycentrics

Licence: MIT license
No description or website provided.

Programming Languages

c
50402 projects - #5 most used programming language
C++
36643 projects - #6 most used programming language
GLSL
2045 projects

Projects that are alternatives of or similar to Barycentrics

Vulkan-MemoryModel
Vulkan Memory Model
Stars: ✭ 95 (+39.71%)
Mutual labels:  vulkan
imgui-rs-vulkan-renderer
A Vulkan renderer for imgui-rs using Ash
Stars: ✭ 44 (-35.29%)
Mutual labels:  vulkan
vulkan.gpuinfo.org
Front-End and Back-End for the Vulkan Hardware Database
Stars: ✭ 21 (-69.12%)
Mutual labels:  vulkan
LowLevelAPIDemo
Evergine Low-Level API samples.
Stars: ✭ 12 (-82.35%)
Mutual labels:  vulkan
go-vk
Go bindings for Vulkan
Stars: ✭ 20 (-70.59%)
Mutual labels:  vulkan
vil
Vulkan Layer for Live Introspection & Debugging. Allows to view all vulkan state live inside your application.
Stars: ✭ 39 (-42.65%)
Mutual labels:  vulkan
vulkan-seed
🌋🌱 A Vulkan starter repo that you could use to get the ball rolling.
Stars: ✭ 57 (-16.18%)
Mutual labels:  vulkan
SACK
System Abstraction Component Kit
Stars: ✭ 18 (-73.53%)
Mutual labels:  vulkan
Vortice.Vulkan
Cross platform .NET bindings for Vulkan, VMA, SPIRV-Cross and shaderc
Stars: ✭ 172 (+152.94%)
Mutual labels:  vulkan
SourceRenderer
A tiny 3D engine that loads and renders Source engine maps - Also known as dreieck.exe
Stars: ✭ 32 (-52.94%)
Mutual labels:  vulkan
mojoshader
Use Direct3D shaders with other 3D rendering APIs.
Stars: ✭ 91 (+33.82%)
Mutual labels:  vulkan
AngryEngine
Game Engine for Windows by Vulkan SDK
Stars: ✭ 20 (-70.59%)
Mutual labels:  vulkan
FANCY
A rendering-framework for DX12 and Vulkan. Mostly intended for personal learning purposes and graphics demos
Stars: ✭ 21 (-69.12%)
Mutual labels:  vulkan
CrossWindow-Demos
🥪 Examples of how to use CrossWindow for things like rendering graphics, listening to events, etc.
Stars: ✭ 48 (-29.41%)
Mutual labels:  vulkan
vortice
Cross-platform .NET 6.0 game engine.
Stars: ✭ 210 (+208.82%)
Mutual labels:  vulkan
VkInline
A tool to make it easy to use Vulkan from Python. An interface for computation and off-screen rendering.
Stars: ✭ 16 (-76.47%)
Mutual labels:  vulkan
LittleEngineVk
3D game engine using C++20 and Vulkan (WIP)
Stars: ✭ 87 (+27.94%)
Mutual labels:  vulkan
racket-vulkan
Racket integration with all things Vulkan 💥
Stars: ✭ 40 (-41.18%)
Mutual labels:  vulkan
scenery
Flexible VR Visualisation for Volumetric and Geometric Data on the Java VM, powered by Kotlin and Vulkan
Stars: ✭ 107 (+57.35%)
Mutual labels:  vulkan
variance shadow mapping vk
Variance shadow mapping for omni lights with Vulkan
Stars: ✭ 27 (-60.29%)
Mutual labels:  vulkan

Barycentrics

This demo several approaches for computing barycentric coordinates in the pixel shader.

Mode 1: Non-indexed geometry

Geometry is rendered using non-indexed draws. Vertex shader explicitly loads indices and vertices from index and vertex buffers and writes out barycentric coordinates. This approach is similar to using a geometry shader that outputs per-vertex barycentrics.

This approach results in geometry throughput ~2x slower than regular indexed rendering.

Mode 2: Geometry shader

Geometry shader is used to output new triangles with explicit per-vertex barycentric coordinates. This approach does not require custom vertex fetching (unlike mode 1).

Performance is slightly worse than mode 1 on AMD Fury X, but better on NVIDIA 1080. In general, we are still looking at ~2x slower rendering in geometry-bound scenes.

Mode 3: Manual ray-triangle intersection in pixel shader

Primitive indices and vertices are loaded in the pixel shader based on primitive ID. Positions are transformed into world space and resulting triangle is intersected with the eye ray to calculate barycentrics.

Despite doing quite a lot of work per pixel, this mode is much faster than modes 1 and 2 in geometry-heavy scenes.

On NVIDIA 1080 this runs ~25% slower than baseline "speed-of-light" shader that simply outpts texture coordinates in a geometry-bound scene. Interestingly, even with no geometry visible on screen (camera facing away, but still shading all vertices) performance is ~13% slower than "speed-of-light". It appears that simply using gl_PrimitiveID incurs an overhead.

AMD Fury X is ~10% slower than "speed-of-light" on average and ~7% slower in pure geometry-bound case, again suggesting an overhead from using gl_PrimitiveID.

Mode 4: Passthrough geometry shader (NVIDIA)

This mode uses VK_NV_geometry_shader_passthrough extension. Fast / passthrough geometry shader is used to output world positions of triangles to the pixel shader, which then performs a ray-triangle intersection similar to mode 3.

Performance is slightly better than mode 3, averaging ~15% slowdown compared to "speed-of-light". With no geometry in view, performance matches the baseline (no primitive ID overhead, unlike mode 3).

Mode 5: Native barycentrics (AMD)

This mode uses VK_AMD_shader_explicit_vertex_parameter extension. This approach is described in GPUOpen blog post.

Vertex shader writes gl_VertexIndex into 2 separate outputs. Pixel shader accesses those parameters through flat and __explicitInterpAMD interpolators to establish the order of native barycentrics available through gl_BaryCoordSmoothAMD.

Performance matches the "speed-of-light". There is no measurable overhead from accessing barycentrics with this method.

Notes

Geometry-heavy scene used for testing is San Miguel 2.0 from http://casual-effects.com/data.

In more balanced scenes, performance delta between different methods can be much less dramatic. In any case, Mode 4 seems to be the most preferable one on NVIDIA and Mode 5 is obviously hard to compete with on AMD.

Mode 3 may be the best cross-platform mechanism at this point, though it would be interesting to implement a way to avoid gl_PrimitiveID overhead.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].