Beispiel #1
0
 private void CheckInternalLogLut()
 {
     if (m_InternalLogLut == null || !m_InternalLogLut.IsCreated())
     {
         RuntimeUtilities.Destroy(m_InternalLogLut);
         RenderTextureFormat lutFormat = GetLutFormat();
         m_InternalLogLut = new RenderTexture(33, 33, 0, lutFormat, RenderTextureReadWrite.Linear)
         {
             name              = "Color Grading Log Lut",
             dimension         = TextureDimension.Tex3D,
             hideFlags         = HideFlags.DontSave,
             filterMode        = FilterMode.Bilinear,
             wrapMode          = TextureWrapMode.Clamp,
             anisoLevel        = 0,
             enableRandomWrite = true,
             volumeDepth       = 33,
             autoGenerateMips  = false,
             useMipMap         = false
         };
         m_InternalLogLut.Create();
     }
 }
Beispiel #2
0
        private static CommandLineRunner CreateRunner(
            string[] args           = null,
            string input            = "",
            string responseFile     = null,
            string workingDirectory = null)
        {
            var io         = new TestConsoleIO(input);
            var clientDir  = Path.GetDirectoryName(RuntimeUtilities.GetAssemblyLocation(typeof(CommandLineRunnerTests)));
            var buildPaths = new BuildPaths(
                clientDir: clientDir,
                workingDir: workingDirectory ?? clientDir,
                sdkDir: null,
                tempDir: Path.GetTempPath());

            var compiler = new CSharpInteractiveCompiler(
                responseFile,
                buildPaths,
                args?.Where(a => a != null).ToArray() ?? s_defaultArgs,
                new NotImplementedAnalyzerLoader());

            return(new CommandLineRunner(io, compiler, CSharpScriptCompiler.Instance, CSharpObjectFormatter.Instance));
        }
Beispiel #3
0
        internal MockCSharpCompiler CreateCSharpCompiler(
            string responseFile,
            string workingDirectory,
            string[] args,
            ImmutableArray <DiagnosticAnalyzer> analyzers = default,
            ImmutableArray <ISourceGenerator> generators  = default,
            AnalyzerAssemblyLoader loader = null
            )
        {
            var buildPaths = RuntimeUtilities.CreateBuildPaths(
                workingDirectory,
                sdkDirectory: SdkDirectory
                );

            return(new MockCSharpCompiler(
                       responseFile,
                       buildPaths,
                       args,
                       analyzers,
                       generators,
                       loader
                       ));
        }
        private void DisplayHealthToUI()
        {
            var currentHealthAmount = playerHealthSetter.GetCurrentHealth();
            var maxHealthAmount     = playerHealthSetter.maxHealthAmount;
            var healthRatio         = currentHealthAmount / maxHealthAmount;

            if (healthRatio <= 0.5f)
            {
                if (!_postProcessOverrideApplied)
                {
                    CreateOverrideVignetteEffect();
                    _postProcessVolume = PostProcessManager.instance.QuickVolume(
                        PostProcessLayer,
                        PostProcessOverridePriority,
                        _healthVignette
                        );
                    _postProcessOverrideApplied = true;
                }

                _healthVignette.color.value = Color.Lerp(
                    Color.black,
                    minHealthColor,
                    ExtensionFunctions.Map(healthRatio, 0, 0.5f, 1, 0.25f)
                    );
            }
            else if (healthRatio > 0.5f && _postProcessOverrideApplied)
            {
                RuntimeUtilities.DestroyVolume(_postProcessVolume, true);
                _postProcessOverrideApplied = false;
            }

            healthFiller.color = healthRatio <= 0.5f
                ? Color.Lerp(minHealthColor, halfHealthColor, healthRatio * 2)
                : Color.Lerp(halfHealthColor, maxHealthColor, (healthRatio - 0.5f) * 2);

            healthSlider.value = healthRatio;
        }
Beispiel #5
0
        public void Init(PostProcessProfile asset, SerializedObject serializedObject)
        {
            Assert.IsNotNull(asset);
            Assert.IsNotNull(serializedObject);

            this.asset         = asset;
            m_SerializedObject = serializedObject;
            m_SettingsProperty = serializedObject.FindProperty("settings");
            Assert.IsNotNull(m_SettingsProperty);

            m_EditorTypes = new Dictionary <Type, Type>();
            m_Editors     = new List <PostProcessEffectBaseEditor>();

            // Gets the list of all available postfx editors
            var editorTypes = RuntimeUtilities.GetAllAssemblyTypes()
                              .Where(
                t => t.IsSubclassOf(typeof(PostProcessEffectBaseEditor)) &&
                t.IsDefined(typeof(PostProcessEditorAttribute), false) &&
                !t.IsAbstract
                );

            // Map them to their corresponding settings type
            foreach (var editorType in editorTypes)
            {
                var attribute = editorType.GetAttribute <PostProcessEditorAttribute>();
                m_EditorTypes.Add(attribute.settingsType, editorType);
            }

            // Create editors for existing settings
            for (int i = 0; i < this.asset.settings.Count; i++)
            {
                CreateEditor(this.asset.settings[i], m_SettingsProperty.GetArrayElementAtIndex(i));
            }

            // Keep track of undo/redo to redraw the inspector when that happens
            Undo.undoRedoPerformed += OnUndoRedoPerformed;
        }
        public override void Render(PostProcessRenderContext context)
        {
            OutlineResources resources;

            if (settings.Resources.value)
            {
                resources = settings.Resources;
            }
            else
            {
                if (!_defaultResources)
                {
                    _defaultResources = ScriptableObject.CreateInstance <OutlineResources>();
                    _defaultResources.ResetToDefaults();
                    _defaultResources.FullscreenTriangleMesh = RuntimeUtilities.fullscreenTriangle;
                }

                resources = _defaultResources;
            }

            if (resources && resources.IsValid)
            {
                RuntimeUtilities.CopyTexture(context.command, context.source, context.destination);

                using (var renderer = new OutlineRenderer(context.command, resources, context.destination, context.camera.actualRenderingPath, new Vector2Int(context.width, context.height)))
                {
                    _objects.Clear();
                    settings.Layers.value.GetRenderObjects(_objects);

                    foreach (var obj in _objects)
                    {
                        renderer.Render(obj);
                    }
                }
            }
        }
Beispiel #7
0
        public override void Render(PostProcessRenderContext context)
        {
            float realtimeSinceStartup = Time.realtimeSinceStartup;
            float z = HaltonSeq.Get(m_SampleIndex & 0x3FF, 2);
            float w = HaltonSeq.Get(m_SampleIndex & 0x3FF, 3);

            if (++m_SampleIndex >= 1024)
            {
                m_SampleIndex = 0;
            }
            if (m_GrainLookupRT == null || !m_GrainLookupRT.IsCreated())
            {
                RuntimeUtilities.Destroy(m_GrainLookupRT);
                m_GrainLookupRT = new RenderTexture(128, 128, 0, GetLookupFormat())
                {
                    filterMode = FilterMode.Bilinear,
                    wrapMode   = TextureWrapMode.Repeat,
                    anisoLevel = 0,
                    name       = "Grain Lookup Texture"
                };
                m_GrainLookupRT.Create();
            }
            PropertySheet propertySheet = context.propertySheets.Get(context.resources.shaders.grainBaker);

            propertySheet.properties.Clear();
            propertySheet.properties.SetFloat(ShaderIDs.Phase, realtimeSinceStartup % 10f);
            context.command.BeginSample("GrainLookup");
            context.command.BlitFullscreenTriangle(BuiltinRenderTextureType.None, m_GrainLookupRT, propertySheet, base.settings.colored.value ? 1 : 0);
            context.command.EndSample("GrainLookup");
            PropertySheet uberSheet = context.uberSheet;

            uberSheet.EnableKeyword("GRAIN");
            uberSheet.properties.SetTexture(ShaderIDs.GrainTex, m_GrainLookupRT);
            uberSheet.properties.SetVector(ShaderIDs.Grain_Params1, new Vector2(base.settings.lumContrib.value, base.settings.intensity.value * 20f));
            uberSheet.properties.SetVector(ShaderIDs.Grain_Params2, new Vector4((float)context.width / (float)m_GrainLookupRT.width / base.settings.size.value, (float)context.height / (float)m_GrainLookupRT.height / base.settings.size.value, z, w));
        }
Beispiel #8
0
    private void Render()
    {
        _CommandBuffer      = new CommandBuffer();
        _CommandBuffer.name = "AdvancedRTR";

        _CommandBuffer.GetTemporaryRT(ShaderConstants._SourceRT, _Camera.pixelWidth, _Camera.pixelHeight, 0, FilterMode.Bilinear, RenderTextureFormat.ARGBHalf);

        //copy
        RuntimeUtilities.BuiltinBlit(_CommandBuffer, BuiltinRenderTextureType.CameraTarget, ShaderConstants._SourceRT);

        //FXAA
        _CommandBuffer.BeginSample("SSR");

        _CommandBuffer.GetTemporaryRT(ShaderConstants._TestRT, _Camera.pixelWidth, _Camera.pixelHeight, 0, FilterMode.Bilinear, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
        RuntimeUtilities.BlitFullscreenTriangle(_CommandBuffer, ShaderConstants._SourceRT, ShaderConstants._TestRT, _SSRMat, 0);

        RuntimeUtilities.BuiltinBlit(_CommandBuffer, ShaderConstants._TestRT, BuiltinRenderTextureType.CameraTarget, _BlendMat, 0);

        _CommandBuffer.EndSample("SSR");

        _CommandBuffer.ReleaseTemporaryRT(ShaderConstants._SourceRT);
        _CommandBuffer.ReleaseTemporaryRT(ShaderConstants._TestRT);
        _Camera.AddCommandBuffer(CameraPoint, _CommandBuffer);
    }
Beispiel #9
0
 public string DumpAssemblyData(out string dumpDirectory)
 {
     return(RuntimeUtilities.DumpAssemblyData(ModuleDatas, out dumpDirectory));
 }
Beispiel #10
0
 void OnDestroy()
 {
     RuntimeUtilities.DestroyVolume(v_Volume, true, true);
     RuntimeUtilities.DestroyVolume(ch_Volume, true, true);
 }
 private static BuildPaths CreateBuildPaths(string workingDirectory, string sdkDirectory = null) => RuntimeUtilities.CreateBuildPaths(workingDirectory, sdkDirectory);
 public MockCSharpCompiler(string responseFile, BuildPaths buildPaths, string[] args, ImmutableArray <DiagnosticAnalyzer> analyzers = default, AnalyzerAssemblyLoader loader = null)
     : base(CSharpCommandLineParser.Default, responseFile, args, buildPaths, Environment.GetEnvironmentVariable("LIB"), loader ?? RuntimeUtilities.CreateAnalyzerAssemblyLoader())
 {
     _analyzers = analyzers.NullToEmpty();
 }
Beispiel #13
0
 private void DestroyVolume()
 {
     RuntimeUtilities.DestroyVolume(m_Volume, true, true);
     Iscreate = false;
 }
Beispiel #14
0
        public override void Render(PostProcessRenderContext context)
        {
            PropertySheet sheet = context.propertySheets.Get(shader);
            CommandBuffer cmd   = context.command;

            Camera cam = context.camera;

            #region Skybox sampling
            //Add the skybox rendering component to any camera rendering Fog
            if (settings.colorSource.value == Fog.FogColorSource.SkyboxColor)
            {
                //Ignore hidden camera's, except scene-view cam
                if (cam.hideFlags != HideFlags.None && cam.name != "SceneCamera")
                {
                    return;
                }

                if (!skyboxCams.ContainsKey(cam))
                {
                    skyboxCams[cam] = cam.gameObject.GetComponent <RenderScreenSpaceSkybox>();

                    if (!skyboxCams[cam])
                    {
                        skyboxCams[cam] = cam.gameObject.AddComponent <RenderScreenSpaceSkybox>();
                    }
                    skyboxCams[cam].manuallyAdded = false; //Don't show warning on component
                }
            }
            #endregion

            //OpenVR.System.GetProjectionMatrix(vrEye, mainCamera.nearClipPlane, mainCamera.farClipPlane, EGraphicsAPIConvention.API_DirectX)

            //Clip-space to world-space camera matrix conversion
            #region Property value composition
            var p = GL.GetGPUProjectionMatrix(cam.projectionMatrix, false);
            p[2, 3] = p[3, 2] = 0.0f;
            p[3, 3] = 1.0f;
            var clipToWorld = Matrix4x4.Inverse(p * cam.worldToCameraMatrix) * Matrix4x4.TRS(new Vector3(0, 0, -p[2, 2]), Quaternion.identity, Vector3.one);
            sheet.properties.SetMatrix("clipToWorld", clipToWorld);

            float FdotC  = cam.transform.position.y - settings.height;
            float paramK = (FdotC <= 0.0f ? 1.0f : 0.0f);
            //Always exclude skybox for skybox color mode
            //Always include when using light scattering to avoid depth discontinuity
            float skyboxInfluence = (settings.lightScattering) ? 1.0f : settings.skyboxInfluence;
            float distanceFog     = (settings.distanceFog) ? 1.0f : 0.0f;
            float heightFog       = (settings.heightFog) ? 1.0f : 0.0f;

            int colorSource  = (settings.useSceneSettings) ? 0 : (int)settings.colorSource.value;
            var sceneMode    = (settings.useSceneSettings) ? RenderSettings.fogMode : settings.fogMode;
            var sceneDensity = (settings.useSceneSettings) ? RenderSettings.fogDensity : settings.globalDensity / 100;
            var sceneStart   = (settings.useSceneSettings) ? RenderSettings.fogStartDistance : settings.fogStartDistance;
            var sceneEnd     = (settings.useSceneSettings) ? RenderSettings.fogEndDistance : settings.fogEndDistance;

            bool  linear  = (sceneMode == FogMode.Linear);
            float diff    = linear ? sceneEnd - sceneStart : 0.0f;
            float invDiff = Mathf.Abs(diff) > 0.0001f ? 1.0f / diff : 0.0f;

            Vector4 sceneParams;
            sceneParams.x = sceneDensity * 1.2011224087f; // density / sqrt(ln(2)), used by Exp2 fog mode
            sceneParams.y = sceneDensity * 1.4426950408f; // density / ln(2), used by Exp fog mode
            sceneParams.z = linear ? -invDiff : 0.0f;
            sceneParams.w = linear ? sceneEnd * invDiff : 0.0f;

            float gradientDistance = (settings.gradientUseFarClipPlane.value) ? settings.gradientDistance : context.camera.farClipPlane;
            #endregion

            #region Property assignment
            if (settings.heightNoiseTex.value)
            {
                sheet.properties.SetTexture("_NoiseTex", settings.heightNoiseTex);
            }
            if (settings.fogColorGradient.value)
            {
                sheet.properties.SetTexture("_ColorGradient", settings.fogColorGradient);
            }
            sheet.properties.SetFloat("_FarClippingPlane", gradientDistance);
            sheet.properties.SetVector("_SceneFogParams", sceneParams);
            sheet.properties.SetVector("_SceneFogMode", new Vector4((int)sceneMode, settings.useRadialDistance ? 1 : 0, colorSource, settings.heightFogNoise ? 1 : 0));
            sheet.properties.SetVector("_NoiseParams", new Vector4(settings.heightNoiseSize * 0.01f, settings.heightNoiseSpeed * 0.01f, settings.heightNoiseStrength, 0));
            sheet.properties.SetVector("_DensityParams", new Vector4(settings.distanceDensity, settings.heightNoiseStrength, settings.skyboxMipLevel, 0));
            sheet.properties.SetVector("_HeightParams", new Vector4(settings.height, FdotC, paramK, settings.heightDensity * 0.5f));
            sheet.properties.SetVector("_DistanceParams", new Vector4(-sceneStart, 0f, distanceFog, heightFog));
            sheet.properties.SetColor("_FogColor", (settings.useSceneSettings) ? RenderSettings.fogColor : settings.fogColor);
            sheet.properties.SetVector("_SkyboxParams", new Vector4(skyboxInfluence, settings.skyboxMipLevel, 0, 0));

            Vector3 sunDir       = (settings.useLightDirection) ? Fog.LightDirection : settings.lightDirection.value.normalized;
            float   sunIntensity = (settings.useLightIntensity) ? FogLightSource.intensity : settings.lightIntensity.value;
            sunIntensity = (settings.enableDirectionalLight) ? sunIntensity : 0f;
            sheet.properties.SetVector("_DirLightParams", new Vector4(sunDir.x, sunDir.y, sunDir.z, sunIntensity));

            Color sunColor = (settings.useLightColor) ? FogLightSource.color : settings.lightColor.value;
            sheet.properties.SetVector("_DirLightColor", new Vector4(sunColor.r, sunColor.g, sunColor.b, 0));

            #endregion

            #region Light scattering
            //Repurpose parts of the bloom effect
            bool enableScattering = (settings.lightScattering) ? true : false;

            if (enableScattering)
            {
                int  tw = Mathf.FloorToInt(context.screenWidth / (2f));
                int  th = Mathf.FloorToInt(context.screenHeight / (2f));
                bool singlePassDoubleWide = (context.stereoActive && (context.stereoRenderingMode == PostProcessRenderContext.StereoRenderingMode.SinglePass) && (context.camera.stereoTargetEye == StereoTargetEyeMask.Both));
                int  tw_stereo            = singlePassDoubleWide ? tw * 2 : tw;

                // Determine the iteration count
                int   s           = Mathf.Max(tw, th);
                float logs        = Mathf.Log(s, 2f) + Mathf.Min(settings.scatterDiffusion.value, 10f) - 10f;
                int   logs_i      = Mathf.FloorToInt(logs);
                int   iterations  = Mathf.Clamp(logs_i, 1, k_MaxPyramidSize);
                float sampleScale = 0.5f + logs - logs_i;
                sheet.properties.SetFloat("_SampleScale", sampleScale);

                // Prefiltering parameters
                float lthresh   = Mathf.GammaToLinearSpace(settings.scatterThreshold.value);
                float knee      = lthresh * settings.scatterSoftKnee.value + 1e-5f;
                var   threshold = new Vector4(lthresh, lthresh - knee, knee * 2f, 0.25f / knee);
                sheet.properties.SetVector("_Threshold", threshold);

                // Downsample
                var lastDown = context.source;
                for (int i = 0; i < iterations; i++)
                {
                    int mipDown = m_Pyramid[i].down;
                    int mipUp   = m_Pyramid[i].up;
                    int pass    = i == 0 ? (int)Pass.Prefilter : (int)Pass.Downsample;

                    context.GetScreenSpaceTemporaryRT(cmd, mipDown, 0, context.sourceFormat, RenderTextureReadWrite.Default, FilterMode.Bilinear, tw_stereo, th);
                    context.GetScreenSpaceTemporaryRT(cmd, mipUp, 0, context.sourceFormat, RenderTextureReadWrite.Default, FilterMode.Bilinear, tw_stereo, th);
                    cmd.BlitFullscreenTriangle(lastDown, mipDown, sheet, pass);

                    lastDown  = mipDown;
                    tw_stereo = (singlePassDoubleWide && ((tw_stereo / 2) % 2 > 0)) ? 1 + tw_stereo / 2 : tw_stereo / 2;
                    tw_stereo = Mathf.Max(tw_stereo, 1);
                    th        = Mathf.Max(th / 2, 1);
                }

                // Upsample
                int lastUp = m_Pyramid[iterations - 1].down;
                for (int i = iterations - 2; i >= 0; i--)
                {
                    int mipDown = m_Pyramid[i].down;
                    int mipUp   = m_Pyramid[i].up;
                    cmd.SetGlobalTexture("_BloomTex", mipDown);
                    cmd.BlitFullscreenTriangle(lastUp, mipUp, sheet, (int)Pass.Upsample);
                    lastUp = mipUp;
                }

                float intensity      = RuntimeUtilities.Exp2(settings.scatterIntensity.value / 10f) - 1f;
                var   shaderSettings = new Vector4(sampleScale, intensity, 0, iterations);
                sheet.properties.SetVector("_ScatteringParams", shaderSettings);

                cmd.SetGlobalTexture("_BloomTex", lastUp);

                // Cleanup
                for (int i = 0; i < iterations; i++)
                {
                    if (m_Pyramid[i].down != lastUp)
                    {
                        cmd.ReleaseTemporaryRT(m_Pyramid[i].down);
                    }
                    if (m_Pyramid[i].up != lastUp)
                    {
                        cmd.ReleaseTemporaryRT(m_Pyramid[i].up);
                    }
                }
            }

            #endregion

            #region shader passes
            context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, enableScattering ? (int)Pass.BlendScattering : (int)Pass.Blend);
            #endregion
        }
 private void OnDestroy()
 {
     RuntimeUtilities.DestroyVolume(volume, true, true);
 }
        public override void Render(PostProcessRenderContext context)
        {
            CommandBuffer command = context.command;

            command.BeginSample("BloomPyramid");
            PropertySheet propertySheet = context.propertySheets.Get(context.resources.shaders.bloom);

            propertySheet.properties.SetTexture(ShaderIDs.AutoExposureTex, context.autoExposureTexture);
            float num   = Mathf.Clamp(base.settings.anamorphicRatio, -1f, 1f);
            float num2  = (!(num < 0f)) ? 0f : (0f - num);
            float num3  = (!(num > 0f)) ? 0f : num;
            int   num4  = Mathf.FloorToInt((float)context.screenWidth / (2f - num2));
            int   num5  = Mathf.FloorToInt((float)context.screenHeight / (2f - num3));
            int   num6  = Mathf.Max(num4, num5);
            float num7  = Mathf.Log(num6, 2f) + Mathf.Min(base.settings.diffusion.value, 10f) - 10f;
            int   num8  = Mathf.FloorToInt(num7);
            int   num9  = Mathf.Clamp(num8, 1, 16);
            float num10 = 0.5f + num7 - (float)num8;

            propertySheet.properties.SetFloat(ShaderIDs.SampleScale, num10);
            float   num11 = Mathf.GammaToLinearSpace(base.settings.threshold.value);
            float   num12 = num11 * base.settings.softKnee.value + 1E-05f;
            Vector4 value = new Vector4(num11, num11 - num12, num12 * 2f, 0.25f / num12);

            propertySheet.properties.SetVector(ShaderIDs.Threshold, value);
            float x = Mathf.GammaToLinearSpace(base.settings.clamp.value);

            propertySheet.properties.SetVector(ShaderIDs.Params, new Vector4(x, 0f, 0f, 0f));
            int num13 = base.settings.fastMode ? 1 : 0;
            RenderTargetIdentifier source = context.source;

            for (int i = 0; i < num9; i++)
            {
                int down = m_Pyramid[i].down;
                int up   = m_Pyramid[i].up;
                int pass = (i != 0) ? (2 + num13) : num13;
                context.GetScreenSpaceTemporaryRT(command, down, 0, context.sourceFormat, RenderTextureReadWrite.Default, FilterMode.Bilinear, num4, num5);
                context.GetScreenSpaceTemporaryRT(command, up, 0, context.sourceFormat, RenderTextureReadWrite.Default, FilterMode.Bilinear, num4, num5);
                command.BlitFullscreenTriangle(source, down, propertySheet, pass);
                source = down;
                num4   = Mathf.Max(num4 / 2, 1);
                num5   = Mathf.Max(num5 / 2, 1);
            }
            int num14 = m_Pyramid[num9 - 1].down;

            for (int num15 = num9 - 2; num15 >= 0; num15--)
            {
                int down2 = m_Pyramid[num15].down;
                int up2   = m_Pyramid[num15].up;
                command.SetGlobalTexture(ShaderIDs.BloomTex, down2);
                command.BlitFullscreenTriangle(num14, up2, propertySheet, 4 + num13);
                num14 = up2;
            }
            Color   linear = base.settings.color.value.linear;
            float   num16  = RuntimeUtilities.Exp2(base.settings.intensity.value / 10f) - 1f;
            Vector4 value2 = new Vector4(num10, num16, base.settings.dirtIntensity.value, num9);

            if (context.IsDebugOverlayEnabled(DebugOverlay.BloomThreshold))
            {
                context.PushDebugOverlay(command, context.source, propertySheet, 6);
            }
            else if (context.IsDebugOverlayEnabled(DebugOverlay.BloomBuffer))
            {
                propertySheet.properties.SetVector(ShaderIDs.ColorIntensity, new Vector4(linear.r, linear.g, linear.b, num16));
                context.PushDebugOverlay(command, m_Pyramid[0].up, propertySheet, 7 + num13);
            }
            Texture texture = (!(base.settings.dirtTexture.value == null)) ? base.settings.dirtTexture.value : RuntimeUtilities.blackTexture;
            float   num17   = (float)texture.width / (float)texture.height;
            float   num18   = (float)context.screenWidth / (float)context.screenHeight;
            Vector4 value3  = new Vector4(1f, 1f, 0f, 0f);

            if (num17 > num18)
            {
                value3.x = num18 / num17;
                value3.z = (1f - value3.x) * 0.5f;
            }
            else if (num18 > num17)
            {
                value3.y = num17 / num18;
                value3.w = (1f - value3.y) * 0.5f;
            }
            PropertySheet uberSheet = context.uberSheet;

            if ((bool)base.settings.fastMode)
            {
                uberSheet.EnableKeyword("BLOOM_LOW");
            }
            else
            {
                uberSheet.EnableKeyword("BLOOM");
            }
            uberSheet.properties.SetVector(ShaderIDs.Bloom_DirtTileOffset, value3);
            uberSheet.properties.SetVector(ShaderIDs.Bloom_Settings, value2);
            uberSheet.properties.SetColor(ShaderIDs.Bloom_Color, linear);
            uberSheet.properties.SetTexture(ShaderIDs.Bloom_DirtTex, texture);
            command.SetGlobalTexture(ShaderIDs.BloomTex, num14);
            for (int j = 0; j < num9; j++)
            {
                if (m_Pyramid[j].down != num14)
                {
                    command.ReleaseTemporaryRT(m_Pyramid[j].down);
                }
                if (m_Pyramid[j].up != num14)
                {
                    command.ReleaseTemporaryRT(m_Pyramid[j].up);
                }
            }
            command.EndSample("BloomPyramid");
            context.bloomBufferNameID = num14;
        }
Beispiel #17
0
 public MockCSharpCompiler(string responseFile, string baseDirectory, string[] args)
     : this(responseFile, baseDirectory, args, ImmutableArray <DiagnosticAnalyzer> .Empty, RuntimeUtilities.CreateAnalyzerAssemblyLoader())
 {
 }
    static EntityConfigurationTypeFinder()
    {
        EntityRegistersDict    = new Dictionary <Type, Dictionary <Type, EntityTypeConfigurationMetadata> >();
        EntityMapDbContextDict = new Dictionary <Type, Type>();
        Empty          = new Dictionary <Type, EntityTypeConfigurationMetadata>();
        DbContextTypes = new HashSet <Type>();

        var assemblies = RuntimeUtilities.GetAllAssemblies();

        var types = assemblies.SelectMany(assembly => assembly.DefinedTypes).Where(type =>
                                                                                   type.IsClass && !type.IsAbstract && !type.IsGenericTypeDefinition).ToArray();

        var applyConfigurationMethod = typeof(ModelBuilder)
                                       .GetMethods()
                                       .Single(
            e => e.Name == "ApplyConfiguration" &&
            e.ContainsGenericParameters &&
            e.GetParameters().SingleOrDefault()?.ParameterType.GetGenericTypeDefinition()
            == typeof(IEntityTypeConfiguration <>));

        foreach (var constructableType in types)
        {
            if (constructableType.GetConstructor(Type.EmptyTypes) == null)
            {
                continue;
            }

            object configuration = null;
            foreach (var type in constructableType.GetInterfaces())
            {
                if (!type.IsGenericType)
                {
                    continue;
                }

                // 只有指定了 DbContext 的接口才知道如何加载
                // 没有指定 DbContext 的只能靠用户自己处理
                if (type.GetGenericTypeDefinition() == typeof(IEntityTypeConfiguration <,>))
                {
                    var entityType    = type.GetGenericArguments()[0];
                    var dbContextType = type.GetGenericArguments()[1];
                    if (!EntityRegistersDict.ContainsKey(dbContextType))
                    {
                        EntityRegistersDict.Add(dbContextType,
                                                new Dictionary <Type, EntityTypeConfigurationMetadata>());
                    }

                    configuration ??= Activator.CreateInstance(constructableType);

                    if (EntityRegistersDict[dbContextType].ContainsKey(entityType))
                    {
                        throw new MicroserviceFrameworkException($"类型 {entityType}, {dbContextType} 已经被注册过");
                    }

                    var methodInfo = applyConfigurationMethod.MakeGenericMethod(entityType);
                    EntityRegistersDict[dbContextType].Add(entityType,
                                                           new EntityTypeConfigurationMetadata(entityType, methodInfo, configuration));
                    EntityMapDbContextDict.AddOrUpdate(entityType, dbContextType);
                    DbContextTypes.Add(dbContextType);
                }

                // else if (type.GetGenericTypeDefinition() == typeof(IEntityTypeConfiguration<>))
                // {
                //  var entityType = type.GetGenericArguments()[0];
                //  var dbContextType = typeof(DefaultDbContext);
                //  if (!EntityRegistersDict.ContainsKey(dbContextType))
                //  {
                //      EntityRegistersDict.Add(dbContextType, new List<object>());
                //  }
                //
                //  EntityRegistersDict[dbContextType].Add(Activator.CreateInstance(constructableType));
                //
                //  EntityMapDbContextDict.AddOrUpdate(entityType, dbContextType);
                // }
            }
        }
    }
Beispiel #19
0
 void Destroy()
 {
     RuntimeUtilities.DestroyVolume(m_Volume, true);
 }
 public override void Release()
 {
     RuntimeUtilities.Destroy(m_InternalSpectralLut);
     m_InternalSpectralLut = null;
 }
Beispiel #21
0
 void OnDisable()
 {
     profile = null;
     RuntimeUtilities.DestroyVolume(m_Volume, false, true);
     activeModifiers.Remove(this);
 }
Beispiel #22
0
 internal void Release()
 {
     RuntimeUtilities.Destroy(material);
     material = null;
 }
 void OnDisable()
 {
     RuntimeUtilities.DestroyVolume(m_Volume, true, true);
 }
Beispiel #24
0
 SerializedProperty FindProperty <TValue>(Expression <Func <CinemachinePostProcessing, TValue> > expr)
 {
     return(serializedObject.FindProperty(RuntimeUtilities.GetFieldPath(expr)));
 }
Beispiel #25
0
 /// <summary>
 /// Find a serialized property using an expression instead of a string. This is safer as it
 /// helps avoiding typos and make code refactoring easier.
 /// </summary>
 /// <typeparam name="TValue">The serialized value type</typeparam>
 /// <param name="expr">The expression to parse to reach the property</param>
 /// <returns>A <see cref="SerializedProperty"/> or <c>null</c> if none was found</returns>
 /// <example>
 /// <code>
 /// [Serializable]
 /// public class MyEffect : PostProcessEffectSettings
 /// {
 ///     public float myParameter = 1f;
 /// }
 ///
 /// [PostProcessEditor(typeof(MyEffect))]
 /// public class MyEffectEditor : PostProcessEffectEditor&lt;MyEffect&gt;
 /// {
 ///     SerializedProperty m_MyParameter;
 ///
 ///     public override void OnEnable()
 ///     {
 ///         m_MyParameter = FindProperty(x => x.myParameter);
 ///     }
 /// }
 /// </code>
 /// </example>
 /// <remarks>
 /// If you're trying to retrieve a <see cref="SerializedParameterOverride"/>, you should
 /// use <seealso cref="FindParameterOverride{TValue}"/> instead.
 /// </remarks>
 /// <seealso cref="SerializedProperty"/>
 /// <seealso cref="FindParameterOverride{TValue}"/>
 protected SerializedProperty FindProperty <TValue>(Expression <Func <T, TValue> > expr)
 {
     return(serializedObject.FindProperty(RuntimeUtilities.GetFieldPath(expr)));
 }
Beispiel #26
0
 public override void Release()
 {
     RuntimeUtilities.Destroy(accumText);
     //Debug.Log("Destroying render texture");
 }
Beispiel #27
0
 private void OnDestroy()
 {
     StopAllCoroutines();
     RuntimeUtilities.DestroyVolume(rippleVolume, true, true);
 }
 public void EndGameOverEffect()
 {
     RuntimeUtilities.DestroyVolume(_volume, false);
 }
Beispiel #29
0
 internal virtual void OnDisable()
 {
     RuntimeUtilities.Destroy(output);
 }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.LabelField(EditorUtilities.GetContent("Volume blending"), EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            {
                // The layout system sort of break alignement when mixing inspector fields with
                // custom layouted fields, do the layout manually instead
                var indentOffset = EditorGUI.indentLevel * 15f;
                var lineRect     = GUILayoutUtility.GetRect(1, EditorGUIUtility.singleLineHeight);
                var labelRect    = new Rect(lineRect.x, lineRect.y, EditorGUIUtility.labelWidth - indentOffset, lineRect.height);
                var fieldRect    = new Rect(labelRect.xMax, lineRect.y, lineRect.width - labelRect.width - 60f, lineRect.height);
                var buttonRect   = new Rect(fieldRect.xMax, lineRect.y, 60f, lineRect.height);

                EditorGUI.PrefixLabel(labelRect, EditorUtilities.GetContent("Trigger|A transform that will act as a trigger for volume blending."));
                m_VolumeTrigger.objectReferenceValue = (Transform)EditorGUI.ObjectField(fieldRect, m_VolumeTrigger.objectReferenceValue, typeof(Transform), false);
                if (GUI.Button(buttonRect, EditorUtilities.GetContent("This|Assigns the current GameObject as a trigger."), EditorStyles.miniButton))
                {
                    m_VolumeTrigger.objectReferenceValue = m_Target.transform;
                }

                if (m_VolumeTrigger.objectReferenceValue == null)
                {
                    EditorGUILayout.HelpBox("No trigger has been set, the camera will only be affected by global volumes.", MessageType.Info);
                }

                EditorGUILayout.PropertyField(m_VolumeLayer, EditorUtilities.GetContent("Layer|This camera will only be affected by volumes in the selected scene-layers."));

                int mask = m_VolumeLayer.intValue;
                if (mask == 0)
                {
                    EditorGUILayout.HelpBox("No layer has been set, the trigger will never be affected by volumes.", MessageType.Warning);
                }
                else if (mask == -1 || ((mask & 1) != 0))
                {
                    EditorGUILayout.HelpBox("Do not use \"Everything\" or \"Default\" as a layer mask as it will slow down the volume blending process! Put post-processing volumes in their own dedicated layer for best performances.", MessageType.Warning);
                }
            }
            EditorGUI.indentLevel--;

            EditorGUILayout.Space();

            EditorGUILayout.LabelField(EditorUtilities.GetContent("Anti-aliasing"), EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            {
                m_AntialiasingMode.intValue = EditorGUILayout.Popup(EditorUtilities.GetContent("Mode|The anti-aliasing method to use. FXAA is fast but low quality. SMAA works well for non-HDR scenes. TAA is a bit slower but higher quality and works well with HDR."), m_AntialiasingMode.intValue, s_AntialiasingMethodNames);

                if (m_AntialiasingMode.intValue == (int)PostProcessLayer.Antialiasing.TemporalAntialiasing)
                {
                    if (RuntimeUtilities.isSinglePassStereoEnabled)
                    {
                        EditorGUILayout.HelpBox("TAA doesn't work with Single-pass stereo rendering.", MessageType.Warning);
                    }

                    EditorGUILayout.PropertyField(m_TaaJitterSpread);
                    EditorGUILayout.PropertyField(m_TaaStationaryBlending);
                    EditorGUILayout.PropertyField(m_TaaMotionBlending);
                    EditorGUILayout.PropertyField(m_TaaSharpen);
                }
                else if (m_AntialiasingMode.intValue == (int)PostProcessLayer.Antialiasing.SubpixelMorphologicalAntialiasing)
                {
                    if (RuntimeUtilities.isSinglePassStereoEnabled)
                    {
                        EditorGUILayout.HelpBox("SMAA doesn't work with Single-pass stereo rendering.", MessageType.Warning);
                    }
                }
                else if (m_AntialiasingMode.intValue == (int)PostProcessLayer.Antialiasing.FastApproximateAntialiasing)
                {
                    EditorGUILayout.PropertyField(m_FxaaMobileOptimized);
                }
            }
            EditorGUI.indentLevel--;

            EditorGUILayout.Space();

            EditorGUILayout.LabelField(EditorUtilities.GetContent("Debug Layer"), EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            {
                EditorGUILayout.PropertyField(m_DebugDisplay, EditorUtilities.GetContent("Display|Toggle visibility of the debug layer on & off in the Game View."));

                if (m_DebugDisplay.boolValue)
                {
                    if (!SystemInfo.supportsComputeShaders)
                    {
                        EditorGUILayout.HelpBox("The debug layer only works on compute-shader enabled platforms.", MessageType.Info);
                    }

                    EditorGUILayout.PropertyField(m_DebugMonitor, EditorUtilities.GetContent("Monitor|The real-time monitor to display on the debug layer."));
                    EditorGUILayout.PropertyField(m_DebugLightMeter, EditorUtilities.GetContent("HDR Light Meter|Light metering utility used to setup auto exposure. Note that it will only display correct values when using a full-HDR workflow (HDR camera, HDR/Custom color grading)."));
                }
            }
            EditorGUI.indentLevel--;

            EditorGUILayout.Space();

            // Toolkit
            EditorUtilities.DrawSplitter();
            GlobalSettings.showLayerToolkit = EditorUtilities.DrawHeader("Toolkit", GlobalSettings.showLayerToolkit);

            if (GlobalSettings.showLayerToolkit)
            {
                EditorGUILayout.Space();

                if (GUILayout.Button(EditorUtilities.GetContent("Export frame to EXR..."), EditorStyles.miniButton))
                {
                    var menu = new GenericMenu();
                    menu.AddItem(EditorUtilities.GetContent("Full Frame (as displayed)"), false, () => ExportFrameToExr(ExportMode.FullFrame));
                    menu.AddItem(EditorUtilities.GetContent("Disable post-processing"), false, () => ExportFrameToExr(ExportMode.DisablePost));
                    menu.AddItem(EditorUtilities.GetContent("Break before Color Grading (Linear)"), false, () => ExportFrameToExr(ExportMode.BreakBeforeColorGradingLinear));
                    menu.AddItem(EditorUtilities.GetContent("Break before Color Grading (Log)"), false, () => ExportFrameToExr(ExportMode.BreakBeforeColorGradingLog));
                    menu.ShowAsContext();
                }

                if (GUILayout.Button(EditorUtilities.GetContent("Select all layer volumes|Selects all the volumes that will influence this layer."), EditorStyles.miniButton))
                {
                    var volumes = RuntimeUtilities.GetAllSceneObjects <PostProcessVolume>()
                                  .Where(x => (m_VolumeLayer.intValue & (1 << x.gameObject.layer)) != 0)
                                  .Select(x => x.gameObject)
                                  .Cast <UnityEngine.Object>()
                                  .ToArray();

                    if (volumes.Length > 0)
                    {
                        Selection.objects = volumes;
                    }
                }

                if (GUILayout.Button(EditorUtilities.GetContent("Select all active volumes|Selects all volumes currently affecting the layer."), EditorStyles.miniButton))
                {
                    var volumes = new List <PostProcessVolume>();
                    PostProcessManager.instance.GetActiveVolumes(m_Target, volumes);

                    if (volumes.Count > 0)
                    {
                        Selection.objects = volumes
                                            .Select(x => x.gameObject)
                                            .Cast <UnityEngine.Object>()
                                            .ToArray();
                    }
                }

                EditorGUILayout.Space();
            }

            // Custom user effects sorter
            EditorUtilities.DrawSplitter();
            GlobalSettings.showCustomSorter = EditorUtilities.DrawHeader("Custom Effect Sorting", GlobalSettings.showCustomSorter);

            if (GlobalSettings.showCustomSorter)
            {
                EditorGUILayout.Space();

                bool anyList = false;
                if (m_CustomLists != null)
                {
                    foreach (var kvp in m_CustomLists)
                    {
                        var list = kvp.Value;

                        // Skip empty lists to avoid polluting the inspector
                        if (list.count == 0)
                        {
                            continue;
                        }

                        list.DoLayoutList();
                        anyList = true;
                    }
                }

                if (!anyList)
                {
                    EditorGUILayout.HelpBox("No custom effect loaded.", MessageType.Info);
                    EditorGUILayout.Space();
                }
            }

            EditorUtilities.DrawSplitter();
            EditorGUILayout.Space();

            serializedObject.ApplyModifiedProperties();
        }