Exemplo n.º 1
0
    AOVRequestDataCollection BuildAovRequest()
    {
        var aovRequestBuilder = new AOVRequestBuilder();
        var aovRequest        = new AOVRequest(AOVRequest.NewDefault()).SetFullscreenOutput(LightingProperty.DiffuseOnly);

        aovRequestBuilder.Add(aovRequest, RTAllocator, null, new[] { AOVBuffers.Color }, (cmd, textures, properties) => { if (diffuse != null)
                                                                                                                          {
                                                                                                                              cmd.Blit(textures[0], diffuse);
                                                                                                                          }
                              });
        aovRequest.SetFullscreenOutput(LightingProperty.SpecularOnly);
        aovRequestBuilder.Add(aovRequest, RTAllocator, null, new[] { AOVBuffers.Color }, (cmd, textures, properties) => { if (specular != null)
                                                                                                                          {
                                                                                                                              cmd.Blit(textures[0], specular);
                                                                                                                          }
                              });
        aovRequest.SetFullscreenOutput(LightingProperty.DirectDiffuseOnly);
        aovRequestBuilder.Add(aovRequest, RTAllocator, null, new[] { AOVBuffers.Color }, (cmd, textures, properties) => { if (directDiffuse != null)
                                                                                                                          {
                                                                                                                              cmd.Blit(textures[0], directDiffuse);
                                                                                                                          }
                              });
        aovRequest.SetFullscreenOutput(LightingProperty.DirectSpecularOnly);
        aovRequestBuilder.Add(aovRequest, RTAllocator, null, new[] { AOVBuffers.Color }, (cmd, textures, properties) => { if (directSpecular != null)
                                                                                                                          {
                                                                                                                              cmd.Blit(textures[0], directSpecular);
                                                                                                                          }
                              });
        aovRequest.SetFullscreenOutput(LightingProperty.IndirectDiffuseOnly);
        aovRequestBuilder.Add(aovRequest, RTAllocator, null, new[] { AOVBuffers.Color }, (cmd, textures, properties) => { if (indirectDiffuse != null)
                                                                                                                          {
                                                                                                                              cmd.Blit(textures[0], indirectDiffuse);
                                                                                                                          }
                              });
        aovRequest.SetFullscreenOutput(LightingProperty.ReflectionOnly);
        aovRequestBuilder.Add(aovRequest, RTAllocator, null, new[] { AOVBuffers.Color }, (cmd, textures, properties) => { if (reflection != null)
                                                                                                                          {
                                                                                                                              cmd.Blit(textures[0], reflection);
                                                                                                                          }
                              });
        aovRequest.SetFullscreenOutput(LightingProperty.EmissiveOnly);
        aovRequestBuilder.Add(aovRequest, RTAllocator, null, new[] { AOVBuffers.Color }, (cmd, textures, properties) => { if (emissive != null)
                                                                                                                          {
                                                                                                                              cmd.Blit(textures[0], emissive);
                                                                                                                          }
                              });
        aovRequest.SetFullscreenOutput(LightingProperty.RefractionOnly);
        aovRequestBuilder.Add(aovRequest, RTAllocator, null, new[] { AOVBuffers.Color }, (cmd, textures, properties) => { if (refraction != null)
                                                                                                                          {
                                                                                                                              cmd.Blit(textures[0], refraction);
                                                                                                                          }
                              });

        return(aovRequestBuilder.Build());
    }
Exemplo n.º 2
0
        void EnableAOVCapture(RecordingSession session, Camera cam)
        {
            var aovRecorderSettings = session.settings as AOVRecorderSettings;

            if (aovRecorderSettings != null)
            {
                if (aovRecorderSettings.AOVGSelection == AOVGType.Beauty)
                {
                    return;
                }

                var hdAdditionalCameraData = cam.GetComponent <HDAdditionalCameraData>();
                if (hdAdditionalCameraData != null)
                {
                    if (m_TempRT == null)
                    {
                        m_TempRT = CreateFrameBuffer(RenderTextureFormat.ARGBFloat, outputWidth, outputHeight, 0,
                                                     false);
                    }
                    var aovRequest = new AOVRequest(AOVRequest.@default);
                    var aovBuffer  = AOVBuffers.Color;
                    if (aovRecorderSettings.AOVGSelection == AOVGType.Depth)
                    {
                        aovRequest.SetFullscreenOutput(DebugFullScreen.Depth);
                        aovBuffer = AOVBuffers.DepthStencil;
                    }
                    else
                    {
                        aovRequest.SetFullscreenOutput((MaterialSharedProperty)aovRecorderSettings.AOVGSelection);
                    }

                    var bufAlloc = m_ColorRT ?? (m_ColorRT = RTHandles.Alloc(outputWidth, outputHeight));

                    var aovRequestBuilder = new AOVRequestBuilder();
                    aovRequestBuilder.Add(aovRequest,
                                          bufferId => bufAlloc,
                                          null,
                                          new[] { aovBuffer },
                                          (cmd, textures, properties) =>
                    {
                        if (m_TempRT != null)
                        {
                            cmd.Blit(textures[0], m_TempRT);
                        }
                    });
                    var aovRequestDataCollection = aovRequestBuilder.Build();
                    var previousRequests         = hdAdditionalCameraData.aovRequests;
                    if (previousRequests != null && previousRequests.Any())
                    {
                        var listOfRequests = previousRequests.ToList();
                        foreach (var p in aovRequestDataCollection)
                        {
                            listOfRequests.Add(p);
                        }
                        var allRequests = new AOVRequestDataCollection(listOfRequests);
                        hdAdditionalCameraData.SetAOVRequests(allRequests);
                    }
                    else
                    {
                        hdAdditionalCameraData.SetAOVRequests(aovRequestDataCollection);
                    }
                }
            }
        }
Exemplo n.º 3
0
        void EnableAOVCapture(RecordingSession session, Camera cam)
        {
            var aovRecorderSettings = session.settings as AOVRecorderSettings;

            if (aovRecorderSettings != null)
            {
                var hdAdditionalCameraData = cam.GetComponent <HDAdditionalCameraData>();
                if (hdAdditionalCameraData != null)
                {
                    if (m_TempRT == null)
                    {
                        if (aovRecorderSettings.CaptureHDR)
                        {
                            m_TempRT = CreateFrameBuffer(RenderTextureFormat.ARGBFloat, OutputWidth, OutputHeight, 0,
                                                         false);
                        }
                        else
                        {
                            m_TempRT = CreateFrameBuffer(RenderTextureFormat.BGRA32, OutputWidth, OutputHeight, 0,
                                                         true);
                        }
                    }

                    var aovRequest = new AOVRequest(AOVRequest.NewDefault());
                    var aovBuffer  = AOVBuffers.Color;
                    var aovInfo    = new AOVInfo();

                    if (m_Aovs.TryGetValue(aovRecorderSettings.m_AOVSelection, out aovInfo))
                    {
                        aovBuffer  = aovInfo.m_AovBuffers;
                        aovRequest = aovInfo.m_AovRequest;
                    }
                    else
                    {
                        Debug.LogError($"Unrecognized AOV '{aovRecorderSettings.m_AOVSelection}'");
                    }

                    var bufAlloc = m_ColorRT ?? (m_ColorRT = RTHandles.Alloc(OutputWidth, OutputHeight,
                                                                             colorFormat: GraphicsFormat.R32G32B32A32_SFloat, name: "m_ColorRT"));
                    var aovRequestBuilder = new AOVRequestBuilder();
                    aovRequestBuilder.Add(aovRequest,
                                          bufferId => bufAlloc,
                                          null,
                                          new[] { aovBuffer },
                                          (cmd, textures, properties) =>
                    {
                        if (m_TempRT != null)
                        {
                            cmd.Blit(textures[0], m_TempRT);
                        }
                    });
                    var aovRequestDataCollection = aovRequestBuilder.Build();
                    var previousRequests         = hdAdditionalCameraData.aovRequests;
                    if (previousRequests != null && previousRequests.Any())
                    {
                        var listOfRequests = previousRequests.ToList();
                        foreach (var p in aovRequestDataCollection)
                        {
                            listOfRequests.Add(p);
                        }
                        var allRequests = new AOVRequestDataCollection(listOfRequests);
                        hdAdditionalCameraData.SetAOVRequests(allRequests);
                    }
                    else
                    {
                        hdAdditionalCameraData.SetAOVRequests(aovRequestDataCollection);
                    }
                }
            }
        }