| 53 | } |
| 54 | |
| 55 | void SkyLight::SetProbeData(TextureData& data) |
| 56 | { |
| 57 | // Validate input data |
| 58 | ASSERT(data.GetArraySize() == 6); |
| 59 | |
| 60 | // Check if was using custom probe |
| 61 | if (Mode == Modes::CustomTexture) |
| 62 | { |
| 63 | // Set |
| 64 | Mode = Modes::CaptureScene; |
| 65 | _bakedProbe = nullptr; |
| 66 | } |
| 67 | |
| 68 | Guid id = Guid::New(); |
| 69 | |
| 70 | #if COMPILE_WITH_ASSETS_IMPORTER |
| 71 | // Create asset file |
| 72 | const String path = GetScene()->GetDataFolderPath() / TEXT("SkyLights/") / GetID().ToString(Guid::FormatType::N) + ASSET_FILES_EXTENSION_WITH_DOT; |
| 73 | AssetInfo info; |
| 74 | if (FileSystem::FileExists(path) && Content::GetAssetInfo(path, info)) |
| 75 | id = info.ID; |
| 76 | if (AssetsImportingManager::Create(AssetsImportingManager::CreateCubeTextureTag, path, id, &data)) |
| 77 | { |
| 78 | LOG(Error, "Cannot import generated sky light!"); |
| 79 | return; |
| 80 | } |
| 81 | #else |
| 82 | // TODO: create or reuse virtual texture and use it |
| 83 | LOG(Error, "Changing probes at runtime in game is not supported."); |
| 84 | return; |
| 85 | #endif |
| 86 | |
| 87 | // Check if has loaded probe and it has different ID |
| 88 | if (_bakedProbe && _bakedProbe->GetID() != id) |
| 89 | { |
| 90 | const auto prevId = _bakedProbe->GetID(); |
| 91 | _bakedProbe = nullptr; |
| 92 | LOG(Warning, "New sku light cube texture has different ID={0} than old one={1}.", id, prevId); |
| 93 | } |
| 94 | |
| 95 | // Link probe texture |
| 96 | _bakedProbe = Content::LoadAsync<CubeTexture>(id); |
| 97 | } |
| 98 | |
| 99 | void SkyLight::UpdateBounds() |
| 100 | { |
no test coverage detected