# ibl_sample **Repository Path**: wangzhuohw/ibl_sample ## Basic Information - **Project Name**: ibl_sample - **Description**: Sample showing how to use IBL(image based lighting) in arkgraphics 3d. - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-02-15 - **Last Updated**: 2025-02-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 添加IBL光照步骤 ### 1. HDR转成Cubemap(KTX) 将.hdr文件放置到``tools/hdr2ibl``目录,执行``tools/hdr2ibl/convert.bat``脚本 ### 2. 加载资产 将生成出来的两张ktx图片放置到``entry\src\main\resources\rawfile``资产目录,并替换如下代码片段: ``` this.scene.environment.environmentImage = await rf.createImage({ name: "skybox", uri: $rawfile('IBL/flower_road_2k_skybox.ktx') }); this.scene.environment.radianceImage = await rf.createImage({ name: "radiance", uri: $rawfile('IBL/flower_road_2k_ibl.ktx') }); ``` 其中,``skybox``贴图表示天空显示的颜色,``radiance``贴图表示天空对物体的光照。 ### 3. 设置球谐参数 HDR的光照信息一部分存储在``radiance``贴图,另一部分用球谐函数表示。将步骤1生成出来的``sh.txt``中的球谐参数替换到如下代码段中(可使用DeepSeek工具辅助调整格式): ``` this.scene.environment.irradianceCoefficients = [ { x: 1.588075518608093, y: 1.513368964195251, z: 1.448706507682800 }, // L00, irradiance, pre-scaled base { x: 1.519405007362366, y: 1.558451414108276, z: 1.578060746192932 }, // L1-1, irradiance, pre-scaled base { x: 1.504220962524414, y: 1.463262438774109, z: 1.383159756660461 }, // L10, irradiance, pre-scaled base { x: -1.298253297805786, y: -1.258347153663635, z: -1.182270407676697 }, // L11, irradiance, pre-scaled base { x: -1.305838108062744, y: -1.261003851890564, z: -1.181669354438782 }, // L2-2, irradiance, pre-scaled base { x: 1.493174433708191, y: 1.444317102432251, z: 1.358674407005310 }, // L2-1, irradiance, pre-scaled base { x: -0.003305336227641, y: 0.002338147023693, z: 0.005189759656787 }, // L20, irradiance, pre-scaled base { x: -1.190836310386658, y: -1.143299579620361, z: -1.069862723350525 }, // L21, irradiance, pre-scaled base { x: -0.169978946447372, y: -0.153091773390770, z: -0.136493653059006 } // L22, irradiance, pre-scaled base ]; ```