{"id":22441364,"url":"https://github.com/hms-core/hms-scene-rtcore-demo","last_synced_at":"2025-08-01T18:32:08.575Z","repository":{"id":37638332,"uuid":"358502111","full_name":"HMS-Core/hms-scene-RTcore-demo","owner":"HMS-Core","description":"This demo provides examples of how to use RTCore APIs, including using them to create reflection effects and draw triangles.","archived":false,"fork":false,"pushed_at":"2022-07-12T09:20:51.000Z","size":27084,"stargazers_count":19,"open_issues_count":0,"forks_count":11,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-04-16T12:54:18.155Z","etag":null,"topics":["hms","huawei","rtcore","scene"],"latest_commit_sha":null,"homepage":"https://developer.huawei.com/consumer/en/hms/huawei-scenekit/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HMS-Core.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-16T06:43:25.000Z","updated_at":"2023-10-11T06:47:06.000Z","dependencies_parsed_at":"2022-07-14T21:46:51.528Z","dependency_job_id":null,"html_url":"https://github.com/HMS-Core/hms-scene-RTcore-demo","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HMS-Core%2Fhms-scene-RTcore-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HMS-Core%2Fhms-scene-RTcore-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HMS-Core%2Fhms-scene-RTcore-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HMS-Core%2Fhms-scene-RTcore-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HMS-Core","download_url":"https://codeload.github.com/HMS-Core/hms-scene-RTcore-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228397819,"owners_count":17913540,"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":["hms","huawei","rtcore","scene"],"created_at":"2024-12-06T02:14:15.393Z","updated_at":"2024-12-06T02:14:16.060Z","avatar_url":"https://github.com/HMS-Core.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sample Codes for RTCore\n[中文](README_zh.md) | English\n\n## Contents\n\n* [Introduction](#introduction)\n* [Compilation](#compilation)\n* [Demos](#demos)\n* [Reference Projects](#reference-projects)\n* [Technical Support](#technical-support)\n* [License](#license)\n\n## Introduction\nThis project mainly demonstrates how to use RTCore APIs to build hybrid rendering pipelines and simulate partial reflection in ray tracing. It provides two demos: one for drawing a triangle using RTCore APIs, and the other for implementing physically based rendering (PBR) pipelines and simulating partial reflection based on hybrid rendering.\nIn this project, we make use of Vulkan by referring to SaschaWillems' VulkanExample[[1]](https://github.com/SaschaWillems/Vulkan) project. In the demo of drawing a triangle, the primary ray for each pixel on the screen is calculated by referring to Ray Tracing in One Weekend[[3]](https://raytracing.github.io/books/RayTracingInOneWeekend.html). PBR-related functions are implemented by referring to LearnOpenGL[[2]](https://learnopengl-cn.github.io/07%20PBR/02%20Lighting/#pbr).\n\n## Compilation\nThe two demos have been tested on Android / Harmony OSplatforms and contain all necessary configuration files.\n**Android / Harmony OS platform**\n1\\. Development Environment\n* Android studio 4.0 or later\n* ndk 20.1.5948944 or later\n* Android SDK 29.0.0 or later\n\n2\\. Compile and Run\n\n2.1 using IDE\n\nOpen `android` in Android Studio and synchronize the project. Run the project to generate the APK and install it on a phone. Then launch the app to check whether it works as expected.\n\n2.2 using command line\n\nadb connect with mobile phone and run following.\n\n```bat\ncd android\ncall .\\gradlew clean\ncall .\\gradlew installDebug \t# or `call .\\gradlew assembleDebug` for just build apk\nadb shell am start -n \"com.huawei.rtcore.vkhybridrt/.VulkanActivity\"\n```\n\n\n\n## Demos\n### [Drawing a Triangle using Ray Tracing](examples/triangle)\nThis demo shows you how to use RTCore APIs to calculate the intersections between primary rays and triangles, to replace the original rasterization method. Below is the detailed procedure.\n\n\u003cimg src=\"images/trianglepipeline_en.png\" width=\"850px\"\u003e\n\n1\\. Use the `generatePrimary` function in `RaytracingTriangle.cpp` to calculate primary rays in the World Coordinate System (WCS) based on the camera coordinates and pixel coordinates.\n\n2\\. Use the `updateRayBuffers` function in `RaytracingTriangle.cpp` to copy rays from CPU to GPU.\n\n3\\. Build bvh and calculate the ray intersections. This task includes three steps: **performing initialization**, **building an acceleration structure**, and **calculating the ray intersections**, framed in red in the preceding figure. In this demo, RTCore APIs is used in the `VulkanTraceRay` class.\n\n\n* The `prepare` function obtains **compute queue** and call the `Setup` function of RTCore to perform initialization.\n* `buildBVH(vertices, indices, modelMatrix)` first converts vertex coordinates into WCS coordinates, and then calls the `CreateBLAS` and `CreateTLAS` functions to build the bottom-level and top-level acceleration structures, respectively.\n* The `trayRay` function calls the **TraceRays** API of RTCore to calculate the ray intersections and get the calculation result. Below is the result.\n\n\u003cimg src=\"images/triangle.png\" width=\"850px\"\u003e\n\n4\\. Use graphics pipelines to virtualize the intersections. That is, call the `triangle/VulkanTrianglePipeline` class to process pixels one by one, obtain the intersection calculation result, and show the intersections in a specific color.\n\n### [Simulating Partial Reflection Based on Hybrid Rendering](examples/hybridRayTracing)\nThis demo builds a set of ray tracing-based hybrid rendering pipelines to implement partial reflection. Below is the detailed procedure.\n\n\u003cimg src=\"images/hybridpipeline_en.png\" width=\"850px\"\u003e\n\n1\\. Use the traditional rasterization method to implement PBR pipelines (as shown in the area framed by yellow dotted lines). Here is the code:\n\n* `examples/hybridreflection/VulkanScenePipeline`\n* `examples/hybridreflection/VulkanImageBasedLighting`\n* `examples/hybridreflection/VulkanSkyboxPipeline`;\n\n2\\. Add a raytraing pipeline to generate reflection texture  which builds of resources that RTCore needs. Then generate gays, intersect with scene objects, get color and return a reflection texture in shader codes.\n\n* `examples/hybridreRayTracing/RayTracingPass`\n* `data/shaders/glsl/hybridRayTracing/raytracing_color.frag`\n\n3\\. Use a hybrid pipeline to fuse specular maps and images displayed by original graphics pipelines.\n\n* `examples/hybridreRayTracing/VulkanOnscreenPipeline`\n\nBelow is an example of partial reflection:\n\n\u003cimg src=\"images/hybridreflection.png\" width=\"850px\"\u003e\n\n## Reference Projects\n[1] https://github.com/SaschaWillems/Vulkan\n\n[2] [learnOpenGL/PBR](https://learnopengl-cn.github.io/07%20PBR/02%20Lighting/#pbr)\n\n[3] https://raytracing.github.io/books/RayTracingInOneWeekend.html\n\n## Technical Support\n\nIf you are still evaluating HMS Core, obtain the latest information about HMS Core and share your insights with other developers at [Reddit](https://www.reddit.com/r/HuaweiDevelopers/.).\n\n- To resolve development issues, please go to [Stack Overflow](https://stackoverflow.com/questions/tagged/huawei-mobile-services?tab=Votes). You can ask questions below the huawei-mobile-services tag, and Huawei R\u0026D experts can solve your problem online on a one-to-one basis.\n- To join the developer discussion, please visit [Huawei Developer Forum](https://forums.developer.huawei.com/forumPortal/en/forum/hms-core).\n\nIf you have problems using the sample code, submit [issues](https://github.com/HMS-Core/hms-scene-fine--grained-demo/issues) and [pull requests](https://github.com/HMS-Core/hms-scene-fine--grained-demo/pulls) to the repository.\n\n## License\nThe sample code is licensed under Apache License 2.0. Please refer to  [LICENSE.md](LICENSE.md)  for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhms-core%2Fhms-scene-rtcore-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhms-core%2Fhms-scene-rtcore-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhms-core%2Fhms-scene-rtcore-demo/lists"}