schellingb / UnityCapture

Streams Unity rendered output to other Windows applications as virtual capture device
420 stars 65 forks source link

Any workaround for HDRP? #21

Open Seratonin opened 3 years ago

Seratonin commented 3 years ago

I am looking to tweak the script to be compatible with HDRP. I heard there is a workaround by setting your camera to render to a RenderTexture. Can anyone help me modify this script with the following

public RenderTexture source;

private void Update()
{
    var tempRT = RenderTexture.GetTemporary(640, 480);
    Graphics.Blit(source, tempRT);

    switch (CaptureInterface.SendTexture(source, Timeout, DoubleBuffering, ResizeMode, MirrorMode))
    {
        case ECaptureSendResult.SUCCESS: break;
        case ECaptureSendResult.WARNING_FRAMESKIP: if (!HideWarnings) Debug.LogWarning("[UnityCapture] Capture device did skip a frame read, capture frame rate will not match render frame rate."); break;
        case ECaptureSendResult.WARNING_CAPTUREINACTIVE: if (!HideWarnings) Debug.LogWarning("[UnityCapture] Capture device is inactive"); break;
        case ECaptureSendResult.ERROR_UNSUPPORTEDGRAPHICSDEVICE: Debug.LogError("[UnityCapture] Unsupported graphics device (only D3D11 supported)"); break;
        case ECaptureSendResult.ERROR_PARAMETER: Debug.LogError("[UnityCapture] Input parameter error"); break;
        case ECaptureSendResult.ERROR_TOOLARGERESOLUTION: Debug.LogError("[UnityCapture] Render resolution is too large to send to capture device"); break;
        case ECaptureSendResult.ERROR_TEXTUREFORMAT: Debug.LogError("[UnityCapture] Render texture format is unsupported (only basic non-HDR (ARGB32) and HDR (FP16/ARGB Half) formats are supported)"); break;
        case ECaptureSendResult.ERROR_READTEXTURE: Debug.LogError("[UnityCapture] Error while reading texture image data"); break;
        case ECaptureSendResult.ERROR_INVALIDCAPTUREINSTANCEPTR: Debug.LogError("[UnityCapture] Invalid Capture Instance Pointer"); break;
    }

    RenderTexture.ReleaseTemporary(tempRT);
}
miraclestar commented 2 years ago

have you done with this? I need use in HDRP too

rrahim commented 1 year ago

Has anyone figured out how to do this in URP or HDRP?

miraclestar commented 11 months ago

RenderPipelineManager.endCameraRendering += OnEndFrameRendering; I use this to solve,but not stable;

sometimes will error

[UnityCapture] Error while reading texture image data

rrahim commented 11 months ago

Thanks, I'll test. But I need something stable though :(


From: miraclestar @.> Sent: Wednesday, August 23, 2023 10:28 PM To: schellingb/UnityCapture @.> Cc: rrahim @.>; Comment @.> Subject: Re: [schellingb/UnityCapture] Any workaround for HDRP? (#21)

[Uploading image.png…] I use this to solve,but not stable;

sometimes will error

[UnityCapture] Error while reading texture image data

— Reply to this email directly, view it on GitHubhttps://github.com/schellingb/UnityCapture/issues/21#issuecomment-1690895529, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADQ6VBK4ZCECPG2EQW2YJRDXW2357ANCNFSM474RUOHQ. You are receiving this because you commented.Message ID: @.***>