schellingb / UnityCapture

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

Not compatible with HDR Pipeline? #8

Closed TheCarelessWhisper closed 3 years ago

TheCarelessWhisper commented 5 years ago

i've got the sample scene to work but only when not using hdr, is it possible to have this work with hdr? it seems not send nay data to obs when using it.

Andy-Roger-Kats commented 4 years ago

I have the same issue. I would like to use this in my HDRP project. Is there any work around?

thomaswester commented 3 years ago

The reason it's not working with HDRP is because HDRP does not call OnRenderImage.

You can work around this by setting your camera to render to a RenderTexture.

Modify UnityCapture to send that rendertexture:

    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);
    }
Seratonin commented 3 years ago

The reason it's not working with HDRP is because HDRP does not call OnRenderImage.

You can work around this by setting your camera to render to a RenderTexture.

Modify UnityCapture to send that rendertexture:

    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);
    }

Hey thomaswester,

Are you able to provide me a HDRP version of the file? I tried what you described and it doesn't work.