vault backup: 2024-10-17 13:45:48
This commit is contained in:
parent
63d30d0452
commit
afd58aadcc
@ -148,6 +148,81 @@ DisplayFrame NDIlib_frame_format_type_progressive NDIlib_FourCC_video_type
|
|||||||
=>
|
=>
|
||||||
DrawProgressiveVideoFrame
|
DrawProgressiveVideoFrame
|
||||||
|
|
||||||
|
## Shader Binding RT
|
||||||
|
设置RT:
|
||||||
|
```c++
|
||||||
|
FTextureRHIRef TargetableTexture;
|
||||||
|
|
||||||
|
// check for our frame sync object and that we are actually connected to the end point
|
||||||
|
if (p_framesync_instance != nullptr)
|
||||||
|
{
|
||||||
|
// Initialize the frame size parameter
|
||||||
|
FIntPoint FrameSize = FIntPoint(Result.xres, Result.yres);
|
||||||
|
|
||||||
|
if (!RenderTarget.IsValid() || !RenderTargetDescriptor.IsValid() ||
|
||||||
|
RenderTargetDescriptor.GetSize() != FIntVector(FrameSize.X, FrameSize.Y, 0) ||
|
||||||
|
DrawMode != EDrawMode::Progressive)
|
||||||
|
{
|
||||||
|
// Create the RenderTarget descriptor
|
||||||
|
RenderTargetDescriptor = FPooledRenderTargetDesc::Create2DDesc(
|
||||||
|
FrameSize, PF_B8G8R8A8, FClearValueBinding::None, TexCreate_None, TexCreate_RenderTargetable | TexCreate_SRGB, false);
|
||||||
|
|
||||||
|
// Update the shader resource for the 'SourceTexture'
|
||||||
|
// The source texture will be given UYVY data, so make it half-width
|
||||||
|
#if (ENGINE_MAJOR_VERSION > 5) || ((ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 1))
|
||||||
|
const FRHITextureCreateDesc CreateDesc = FRHITextureCreateDesc::Create2D(TEXT("NDIMediaReceiverProgressiveSourceTexture"))
|
||||||
|
.SetExtent(FrameSize.X / 2, FrameSize.Y)
|
||||||
|
.SetFormat(PF_B8G8R8A8)
|
||||||
|
.SetNumMips(1)
|
||||||
|
.SetFlags(ETextureCreateFlags::RenderTargetable | ETextureCreateFlags::Dynamic);
|
||||||
|
|
||||||
|
SourceTexture = RHICreateTexture(CreateDesc);
|
||||||
|
#elif (ENGINE_MAJOR_VERSION == 4) || (ENGINE_MAJOR_VERSION == 5)
|
||||||
|
FRHIResourceCreateInfo CreateInfo(TEXT("NDIMediaReceiverProgressiveSourceTexture"));
|
||||||
|
TRefCountPtr<FRHITexture2D> DummyTexture2DRHI;
|
||||||
|
RHICreateTargetableShaderResource2D(FrameSize.X / 2, FrameSize.Y, PF_B8G8R8A8, 1, TexCreate_Dynamic,
|
||||||
|
TexCreate_RenderTargetable, false, CreateInfo, SourceTexture,
|
||||||
|
DummyTexture2DRHI);
|
||||||
|
#else
|
||||||
|
#error "Unsupported engine major version"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Find a free target-able texture from the render pool
|
||||||
|
GRenderTargetPool.FindFreeElement(RHICmdList, RenderTargetDescriptor, RenderTarget, TEXT("NDIIO"));
|
||||||
|
|
||||||
|
DrawMode = EDrawMode::Progressive;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if ENGINE_MAJOR_VERSION >= 5
|
||||||
|
TargetableTexture = RenderTarget->GetRHI();
|
||||||
|
#elif ENGINE_MAJOR_VERSION == 4
|
||||||
|
TargetableTexture = RenderTarget->GetRenderTargetItem().TargetableTexture;
|
||||||
|
...
|
||||||
|
...
|
||||||
|
// Initialize the Render pass with the conversion texture
|
||||||
|
FRHITexture* ConversionTexture = TargetableTexture.GetReference();
|
||||||
|
FRHIRenderPassInfo RPInfo(ConversionTexture, ERenderTargetActions::DontLoad_Store);
|
||||||
|
|
||||||
|
// Needs to be called *before* ApplyCachedRenderTargets, since BeginRenderPass is caching the render targets.
|
||||||
|
RHICmdList.BeginRenderPass(RPInfo, TEXT("NDI Recv Color Conversion"));
|
||||||
|
```
|
||||||
|
|
||||||
|
设置NDI传入的UYVY:
|
||||||
|
```c++
|
||||||
|
// set the texture parameter of the conversion shader
|
||||||
|
FNDIIOShaderUYVYtoBGRAPS::Params Params(SourceTexture, SourceTexture, FrameSize,
|
||||||
|
FVector2D(0, 0), FVector2D(1, 1),
|
||||||
|
bPerformsRGBtoLinear ? FNDIIOShaderPS::EColorCorrection::sRGBToLinear : FNDIIOShaderPS::EColorCorrection::None,
|
||||||
|
FVector2D(0.f, 1.f));
|
||||||
|
ConvertShader->SetParameters(RHICmdList, Params);
|
||||||
|
|
||||||
|
// Create the update region structure
|
||||||
|
FUpdateTextureRegion2D Region(0, 0, 0, 0, FrameSize.X/2, FrameSize.Y);
|
||||||
|
|
||||||
|
// Set the Pixel data of the NDI Frame to the SourceTexture
|
||||||
|
RHIUpdateTexture2D(SourceTexture, 0, Region, Result.line_stride_in_bytes, (uint8*&)Result.p_data);
|
||||||
|
```
|
||||||
|
|
||||||
## 解决方案
|
## 解决方案
|
||||||
[NDI plugin质量问题](https://forums.unrealengine.com/t/ndi-plugin-quality-trouble/1970097)
|
[NDI plugin质量问题](https://forums.unrealengine.com/t/ndi-plugin-quality-trouble/1970097)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user