diff --git a/WickedEngine/wiScene.cpp b/WickedEngine/wiScene.cpp index 8a93c7f08..d94a7e1d6 100644 --- a/WickedEngine/wiScene.cpp +++ b/WickedEngine/wiScene.cpp @@ -4090,7 +4090,8 @@ namespace wi::scene if (video != nullptr) { // Video attachment will overwrite texture slots on shader side: - int descriptor = GetDevice()->GetDescriptorIndex(&video->videoinstance.output.texture, SubresourceType::SRV, video->videoinstance.output.subresource_srgb); + Texture videoTexture = video->videoinstance.GetCurrentFrameTexture(); + int descriptor = GetDevice()->GetDescriptorIndex(&videoTexture, SubresourceType::SRV, video->videoinstance.GetCurrentFrameTextureSRGBSubresource()); material.WriteShaderTextureSlot(materialArrayMapped + args.jobIndex, BASECOLORMAP, descriptor); material.WriteShaderTextureSlot(materialArrayMapped + args.jobIndex, EMISSIVEMAP, descriptor); } @@ -4876,7 +4877,8 @@ namespace wi::scene const VideoComponent* video = videos.GetComponent(entity); if (video != nullptr) { - light.maskTexDescriptor = GetDevice()->GetDescriptorIndex(&video->videoinstance.output.texture, SubresourceType::SRV, video->videoinstance.output.subresource_srgb); + Texture videoTexture = video->videoinstance.GetCurrentFrameTexture(); + light.maskTexDescriptor = GetDevice()->GetDescriptorIndex(&videoTexture, SubresourceType::SRV, video->videoinstance.GetCurrentFrameTextureSRGBSubresource()); } } @@ -5408,6 +5410,7 @@ namespace wi::scene void Scene::RunSpriteUpdateSystem(wi::jobsystem::context& ctx) { wi::jobsystem::Dispatch(ctx, (uint32_t)sprites.GetCount(), small_subtask_groupsize, [&](wi::jobsystem::JobArgs args) { + Entity entity = sprites.GetEntity(args.jobIndex); Sprite& sprite = sprites[args.jobIndex]; if (sprite.params.isExtractNormalMapEnabled()) { @@ -5421,6 +5424,18 @@ namespace wi::scene { sprite.params.mask_subresource = sprite.maskResource.GetTextureSRGBSubresource(); } + + const VideoComponent* videocomponent = videos.GetComponent(entity); + if (videocomponent != nullptr && videocomponent->videoinstance.IsValid()) + { + Texture videoTexture = videocomponent->videoinstance.GetCurrentFrameTexture(); + if (videoTexture.IsValid()) + { + sprite.textureResource.SetTexture(videoTexture); + sprite.params.image_subresource = videocomponent->videoinstance.GetCurrentFrameTextureSRGBSubresource(); + } + } + sprite.Update(dt); }); } diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 0a5d88c7c..74643a4ef 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 71; // minor bug fixes, alterations, refactors, updates - const int revision = 765; + const int revision = 766; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision); diff --git a/WickedEngine/wiVideo.h b/WickedEngine/wiVideo.h index 40e8496fb..37f03d8f2 100644 --- a/WickedEngine/wiVideo.h +++ b/WickedEngine/wiVideo.h @@ -92,6 +92,11 @@ namespace wi::video }; Flags flags = Flags::Empty; inline bool IsValid() const { return decoder.IsValid(); } + + // Get texture resource of the latest decoded frame that can be displayed: + wi::graphics::Texture GetCurrentFrameTexture() const { return output.texture; } + // Get SRGB subresource view of the latest decoded frame that can be displayed: + int GetCurrentFrameTextureSRGBSubresource() const { return output.subresource_srgb; } }; bool CreateVideo(const std::string& filename, Video* video);