| 408 | } |
| 409 | |
| 410 | void LightCollection::computeStats(RenderContext* pRenderContext) const |
| 411 | { |
| 412 | if (mStatsValid) return; |
| 413 | |
| 414 | // Read back the current data. This is potentially expensive. |
| 415 | syncCPUData(pRenderContext); |
| 416 | |
| 417 | // Stats on input data. |
| 418 | MeshLightStats stats; |
| 419 | stats.meshLightCount = (uint32_t)mMeshLights.size(); |
| 420 | stats.triangleCount = (uint32_t)mMeshLightTriangles.size(); |
| 421 | |
| 422 | uint32_t trianglesTotal = 0; |
| 423 | for (const auto& meshLight : mMeshLights) |
| 424 | { |
| 425 | auto pMaterial = mpScene->getMaterial(MaterialID::fromSlang(meshLight.materialID))->toBasicMaterial(); |
| 426 | FALCOR_ASSERT(pMaterial); |
| 427 | bool isTextured = pMaterial->getEmissiveTexture() != nullptr; |
| 428 | |
| 429 | if (isTextured) |
| 430 | { |
| 431 | stats.meshesTextured++; |
| 432 | stats.trianglesTextured += meshLight.triangleCount; |
| 433 | } |
| 434 | trianglesTotal += meshLight.triangleCount; |
| 435 | } |
| 436 | FALCOR_ASSERT(trianglesTotal == stats.triangleCount); |
| 437 | |
| 438 | // Stats on pre-processed data. |
| 439 | for (const auto& tri : mMeshLightTriangles) |
| 440 | { |
| 441 | FALCOR_ASSERT(tri.flux >= 0.f); |
| 442 | if (tri.flux == 0.f) |
| 443 | { |
| 444 | stats.trianglesCulled++; |
| 445 | } |
| 446 | else |
| 447 | { |
| 448 | // TODO: Currently we don't detect uniform radiance for textured lights, so just look at whether the mesh light is textured or not. |
| 449 | // This code will change when we tag individual triangles as textured vs non-textured. |
| 450 | auto pMaterial = mpScene->getMaterial(MaterialID::fromSlang(mMeshLights[tri.lightIdx].materialID))->toBasicMaterial(); |
| 451 | FALCOR_ASSERT(pMaterial); |
| 452 | bool isTextured = pMaterial->getEmissiveTexture() != nullptr; |
| 453 | |
| 454 | if (isTextured) stats.trianglesActiveTextured++; |
| 455 | else stats.trianglesActiveUniform++; |
| 456 | } |
| 457 | } |
| 458 | stats.trianglesActive = stats.trianglesActiveUniform + stats.trianglesActiveTextured; |
| 459 | |
| 460 | mMeshLightStats = stats; |
| 461 | mStatsValid = true; |
| 462 | } |
| 463 | |
| 464 | void LightCollection::buildTriangleList(RenderContext* pRenderContext, const Scene& scene) |
| 465 | { |
nothing calls this directly
no test coverage detected