예제 #1
0
        internal static void RenderAndWriteToFile(
            HDProbe probe, string targetFile,
            RenderTexture cubeRT, RenderTexture planarRT
            )
        {
            var settings = probe.settings;

            switch (settings.type)
            {
            case ProbeSettings.ProbeType.ReflectionProbe:
            {
                var positionSettings = ProbeCapturePositionSettings.ComputeFrom(probe, null);
                HDRenderUtilities.Render(probe.settings, positionSettings, cubeRT,
                                         forceFlipY: true,
                                         forceInvertBackfaceCulling: true, // Cubemap have an RHS standard, so we need to invert the face culling
                                         (uint)StaticEditorFlags.ReflectionProbeStatic
                                         );
                HDBakingUtilities.CreateParentDirectoryIfMissing(targetFile);
                if (Provider.isActive && HDEditorUtils.IsAssetPath(targetFile))
                {
                    Checkout(targetFile, CheckoutMode.Both);
                }
                HDTextureUtilities.WriteTextureFileToDisk(cubeRT, targetFile);
                break;
            }

            case ProbeSettings.ProbeType.PlanarProbe:
            {
                var planarProbe      = (PlanarReflectionProbe)probe;
                var positionSettings = ProbeCapturePositionSettings.ComputeFromMirroredReference(
                    probe,
                    planarProbe.referencePosition
                    );

                HDRenderUtilities.Render(
                    settings,
                    positionSettings,
                    planarRT,
                    out var cameraSettings, out var cameraPositionSettings
                    );
                HDBakingUtilities.CreateParentDirectoryIfMissing(targetFile);
                if (Provider.isActive && HDEditorUtils.IsAssetPath(targetFile))
                {
                    Checkout(targetFile, CheckoutMode.Both);
                }
                HDTextureUtilities.WriteTextureFileToDisk(planarRT, targetFile);
                var renderData           = new HDProbe.RenderData(cameraSettings, cameraPositionSettings);
                var targetRenderDataFile = targetFile + ".renderData";
                if (Provider.isActive && HDEditorUtils.IsAssetPath(targetRenderDataFile))
                {
                    Checkout(targetRenderDataFile, CheckoutMode.Both);
                }
                HDBakingUtilities.TrySerializeToDisk(renderData, targetRenderDataFile);
                break;
            }
            }
        }
        public static void Render(
            HDProbe probe, Transform viewerTransform,
            Texture outTarget, out HDProbe.RenderData outRenderData,
            bool forceFlipY = false
            )
        {
            var positionSettings = ProbeCapturePositionSettings.ComputeFrom(probe, viewerTransform);

            HDRenderUtilities.Render(
                probe.settings,
                positionSettings,
                outTarget,
                out CameraSettings cameraSettings, out CameraPositionSettings cameraPosition,
                forceFlipY: forceFlipY
                );

            outRenderData = new HDProbe.RenderData(cameraSettings, cameraPosition);
        }
예제 #3
0
        internal static void RenderAndWriteToFile(
            HDProbe probe, string targetFile,
            RenderTexture cubeRT, RenderTexture planarRT
            )
        {
            var settings = probe.settings;

            switch (settings.type)
            {
            case ProbeSettings.ProbeType.ReflectionProbe:
            {
                var positionSettings = ProbeCapturePositionSettings.ComputeFrom(probe, null);
                HDRenderUtilities.Render(probe.settings, positionSettings, cubeRT,
                                         forceFlipY: true,
                                         forceInvertBackfaceCulling: true, // TODO: for an unknown reason, we need to invert the backface culling for baked reflection probes, Remove this
                                         (uint)StaticEditorFlags.ReflectionProbeStatic
                                         );
                HDBakingUtilities.CreateParentDirectoryIfMissing(targetFile);
                HDTextureUtilities.WriteTextureFileToDisk(cubeRT, targetFile);
                break;
            }

            case ProbeSettings.ProbeType.PlanarProbe:
            {
                var planarProbe      = (PlanarReflectionProbe)probe;
                var positionSettings = ProbeCapturePositionSettings.ComputeFromMirroredReference(
                    probe,
                    planarProbe.referencePosition
                    );

                HDRenderUtilities.Render(
                    settings,
                    positionSettings,
                    planarRT,
                    out CameraSettings cameraSettings, out CameraPositionSettings cameraPositionSettings
                    );
                HDBakingUtilities.CreateParentDirectoryIfMissing(targetFile);
                HDTextureUtilities.WriteTextureFileToDisk(planarRT, targetFile);
                var renderData = new HDProbe.RenderData(cameraSettings, cameraPositionSettings);
                HDBakingUtilities.TrySerializeToDisk(renderData, targetFile + ".renderData");
                break;
            }
            }
        }
        internal static void RenderAndWriteToFile(
            HDProbe probe, string targetFile,
            RenderTexture cubeRT, RenderTexture planarRT
            )
        {
            var settings = probe.settings;

            switch (settings.type)
            {
            case ProbeSettings.ProbeType.ReflectionProbe:
            {
                var positionSettings = ProbeCapturePositionSettings.ComputeFrom(probe, null);
                HDRenderUtilities.Render(probe.settings, positionSettings, cubeRT, forceFlipY: true);
                HDBakingUtilities.CreateParentDirectoryIfMissing(targetFile);
                HDTextureUtilities.WriteTextureFileToDisk(cubeRT, targetFile);
                break;
            }

            case ProbeSettings.ProbeType.PlanarProbe:
            {
                var planarProbe      = (PlanarReflectionProbe)probe;
                var positionSettings = ProbeCapturePositionSettings.ComputeFromMirroredReference(
                    probe,
                    planarProbe.referencePosition
                    );

                HDRenderUtilities.Render(
                    settings,
                    positionSettings,
                    planarRT,
                    out CameraSettings cameraSettings, out CameraPositionSettings cameraPositionSettings
                    );
                HDBakingUtilities.CreateParentDirectoryIfMissing(targetFile);
                HDTextureUtilities.WriteTextureFileToDisk(planarRT, targetFile);
                var renderData = new HDProbe.RenderData(cameraSettings, cameraPositionSettings);
                HDBakingUtilities.TrySerializeToDisk(renderData, targetFile + ".renderData");
                break;
            }
            }
        }