Get serialized material parameters for a list of materials. * \param materialIDsBuffer Buffer containing material IDs * \param paramsBuffer Buffer to write material parameters to */
| 4191 | * \param paramsBuffer Buffer to write material parameters to |
| 4192 | */ |
| 4193 | inline void getMaterialParamsPython(Scene& scene, ref<Buffer> materialIDsBuffer, ref<Buffer> paramsBuffer) |
| 4194 | { |
| 4195 | // Get material IDs from buffer. |
| 4196 | FALCOR_CHECK(materialIDsBuffer->getStructSize() == sizeof(uint32_t), "Material IDs buffer must contain uint32_t elements."); |
| 4197 | std::vector<uint32_t> materialIDs = materialIDsBuffer->getElements<uint32_t>(); |
| 4198 | |
| 4199 | // Fetch material parameters. |
| 4200 | std::vector<float> params; |
| 4201 | params.reserve(materialIDs.size() * SerializedMaterialParams::kParamCount); |
| 4202 | for (uint32_t materialID : materialIDs) |
| 4203 | { |
| 4204 | SerializedMaterialParams tmpParams = scene.getMaterial(MaterialID(materialID))->serializeParams(); |
| 4205 | params.insert(params.end(), tmpParams.begin(), tmpParams.end()); |
| 4206 | } |
| 4207 | |
| 4208 | // Write material parameters to buffer. |
| 4209 | FALCOR_CHECK(paramsBuffer->getSize() >= params.size() * sizeof(float), "Material parameter buffer is too small."); |
| 4210 | paramsBuffer->setBlob(params.data(), 0, params.size() * sizeof(float)); |
| 4211 | #if FALCOR_HAS_CUDA |
| 4212 | scene.getDevice()->getRenderContext()->waitForFalcor(); |
| 4213 | #endif |
| 4214 | } |
| 4215 | |
| 4216 | /** Set serialized material parameters for a list of materials. |
| 4217 | * \param materialIDsBuffer Buffer containing material IDs |
nothing calls this directly
no test coverage detected