{"id":18019731,"url":"https://github.com/kayru/raytracedshadows","last_synced_at":"2025-03-26T20:31:27.351Z","repository":{"id":138268953,"uuid":"123834710","full_name":"kayru/RayTracedShadows","owner":"kayru","description":"This demo implements BVH construction and GPU traversal for rendering hard shadows.","archived":false,"fork":false,"pushed_at":"2021-01-01T22:22:59.000Z","size":165,"stargazers_count":132,"open_issues_count":0,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-22T10:42:59.238Z","etag":null,"topics":["bvh","raytracing","vulkan"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kayru.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-03-04T22:22:00.000Z","updated_at":"2025-01-23T23:18:51.000Z","dependencies_parsed_at":"2024-01-14T01:47:13.009Z","dependency_job_id":null,"html_url":"https://github.com/kayru/RayTracedShadows","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayru%2FRayTracedShadows","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayru%2FRayTracedShadows/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayru%2FRayTracedShadows/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayru%2FRayTracedShadows/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kayru","download_url":"https://codeload.github.com/kayru/RayTracedShadows/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245731444,"owners_count":20663187,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bvh","raytracing","vulkan"],"created_at":"2024-10-30T05:12:19.644Z","updated_at":"2025-03-26T20:31:26.945Z","avatar_url":"https://github.com/kayru.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ray Traced Shadows\n\nThis demo implements BVH construction and GPU traversal for rendering hard shadows.\n\n## BVH Construction and Layout\n\nBVH is constructed on CPU. The build process is fairly naive, but results in a high quality hierarchy that's fast to traverse. The tree is constructed using a top-down strategy, using a surface area heuristic (SAH) to find optimal split point at every level.\n\nNodes are laid out in memory using a depth-first traversal order. Child node with the larger surface area is always on the left. This heuristic aims to find an intersected primitive for a ray in a cache-coherent manner.\n\nEach intermediate BVH node is packed into 32 bytes:\n\n\tstruct BVHNode\n\t{\n\t\tvec3 bboxMin;\n\t\tuint primitiveId;\n\t\tvec3 bboxMax;\n\t\tuint next;\n\t};\n\nLeaf BVH nodes are packed into 48 bytes:\n\n\tstruct BVHNodeLeaf\n\t{\n\t\tvec3 edge0;\n\t\tuint padding0;\n\t\tvec3 edge1;\n\t\tuint next; // node miss pointer\n\t\tvec3 vertex;\n\t\tuint padding2;\n\t};\n\n## BVH Traversal\n\nHard shadows are implemented by using any-hit BVH traversal for a ray on GPU. A stackless algorithm is used, which relies on the depth-first memory layout of the tree.\n\nThe bounding box of each visited intermediate node is tested against a ray. On hit, the next node that must be visited is next in memory. On miss, current node's `next` pointer is used to skip part of the tree. This either jumps to the current node's right sibling or to the parent's right sibling.\n\nEach intermediate node contains a `primitiveId` field. If this field is not `0xFFFFFFFF`, then current node is reinterpreted as `BVHNodeLeaf`. Extra data for leaf nodes is stored deinterleaved (at the end of the BVH buffer).\n\n## How to build on Windows with Visual Studio 2017\n\nClone repository\n\n\tgit@github.com:kayru/RayTracedShadows.git\n\tcd RayTracedShadows\n\tgit submodule update --init\n\nGenerate Visual Studio solution\n\n\tcd Scripts\n\tcmake-vs2017-vk.cmd\n\nSolution files written to `Build` directory in the root of the repository.\n\n## Acknowledgements\n\nThis demo uses similar ideas to what is described in the following work:\n\n* [The Perfect BVH, Jacco Bikker, 2016](http://www.cs.uu.nl/docs/vakken/magr/2015-2016/slides/lecture%2003%20-%20the%20perfect%20BVH.pdf)\n* [Implementing a practical rendering system using GLSL, Toshiya Hachisuka, 2015](http://www.ci.i.u-tokyo.ac.jp/~hachisuka/tdf2015.pdf)\n* [AMD RadeonRays](https://github.com/GPUOpen-LibrariesAndSDKs/RadeonRays_SDK)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkayru%2Fraytracedshadows","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkayru%2Fraytracedshadows","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkayru%2Fraytracedshadows/lists"}