Example #1
0
        private void DrawShader()
        {
            var pipe = SgtShaderBundle.DetectProjectPipeline();

            EditorGUILayout.PropertyField(serializedObject.FindProperty("target"));

            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.TextField("Project Pipeline", pipe.ToString());

            foreach (var variant in tgt.Variants)
            {
                var active = variant.Pipe == tgt.CurrentPipe;

                EditorGUILayout.Toggle(variant.Pipe.ToString(), active);
            }
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.Separator();

            if (GUILayout.Button("Switch Shader To " + pipe.ToString()) == true)
            {
                tgt.TrySwitchTo(pipe);

                serializedObject.Update();
            }

            if (GUILayout.Button("Switch All Shaders To " + pipe.ToString()) == true)
            {
                SgtShaderBundle.TrySwitchAllTo(pipe);

                serializedObject.Update();
            }
        }
        protected virtual void Update()
        {
            var pipe = SgtShaderBundle.DetectProjectPipeline();

            if (SgtShaderBundle.IsStandard(pipe) == true)
            {
                ApplyIntensity(intensityInStandard);
            }
            else if (SgtShaderBundle.IsURP(pipe) == true)
            {
                ApplyIntensity(intensityInURP);
            }
            else if (SgtShaderBundle.IsHDRP(pipe) == true)
            {
                ApplyIntensity(intensityInHDRP);
            }
        }
Example #3
0
        public override void OnInspectorGUI()
        {
            tgt = (SgtShaderBundle)target;

            DrawShader();

        #if __BETTERSHADERS__
            EditorGUILayout.Separator();

            DrawCompile();
        #endif

            EditorGUILayout.Separator();

            DrawShaderBundles();

            serializedObject.ApplyModifiedProperties();
        }
Example #4
0
        protected virtual void OnEnable()
        {
            var pipe = SgtShaderBundle.DetectProjectPipeline();

            if (SgtShaderBundle.IsHDRP(pipe) == true)
            {
                if (changeExposureInHDRP == true || changeVisualEnvironmentInHDRP == true || changeFogInHDRP == true)
                {
                    TryCreateVolume();
                }

                if (upgradeLightsInHDRP == true)
                {
                    TryUpgradeLights();
                }

                if (upgradeCamerasInHDRP == true)
                {
                    TryUpgradeCameras();
                }
            }
        }
        protected virtual void UpdateMaterials()
        {
            if (innerMaterial == null)
            {
                innerMaterial = SgtHelper.CreateTempMaterial("Atmosphere Inner (Generated)", SgtHelper.ShaderNamePrefix + "AtmosphereInner");
            }

            if (outerMaterial == null)
            {
                outerMaterial = SgtHelper.CreateTempMaterial("Atmosphere Outer (Generated)", SgtHelper.ShaderNamePrefix + "AtmosphereOuter");
            }

            var color      = SgtHelper.Brighten(this.color, brightness);
            var innerRatio = SgtHelper.Divide(innerMeshRadius, OuterRadius);

            innerMaterial.renderQueue = outerMaterial.renderQueue = renderQueue;

            innerMaterial.SetColor(SgtShader._Color, color);
            outerMaterial.SetColor(SgtShader._Color, color);

            innerMaterial.SetTexture(SgtShader._DepthTex, innerDepthTex);
            outerMaterial.SetTexture(SgtShader._DepthTex, outerDepthTex);

            innerMaterial.SetFloat(SgtShader._InnerRatio, innerRatio);
            innerMaterial.SetFloat(SgtShader._InnerScale, 1.0f / (1.0f - innerRatio));

            if (SgtShaderBundle.IsHDRP(SgtShaderBundle.DetectProjectPipeline()) == true)
            {
                innerMaterial.SetFloat(SgtShader._Offset, -1.0f);
            }
            else
            {
                innerMaterial.SetFloat(SgtShader._Offset, -0.001f);
            }

            if (outerSoftness > 0.0f)
            {
                SgtHelper.EnableKeyword("SGT_A", outerMaterial);                 // Softness

                outerMaterial.SetFloat(SgtShader._SoftParticlesFactor, SgtHelper.Reciprocal(outerSoftness));
            }
            else
            {
                SgtHelper.DisableKeyword("SGT_A", outerMaterial);                 // Softness
            }

            if (lit == true)
            {
                innerMaterial.SetColor(SgtShader._AmbientColor, ambientColor);
                outerMaterial.SetColor(SgtShader._AmbientColor, ambientColor);

                innerMaterial.SetTexture(SgtShader._LightingTex, lightingTex);
                outerMaterial.SetTexture(SgtShader._LightingTex, lightingTex);

                if (scattering == true)
                {
                    outerMaterial.SetTexture(SgtShader._ScatteringTex, scatteringTex);
                    outerMaterial.SetFloat(SgtShader._ScatteringMie, scatteringMie);
                    outerMaterial.SetFloat(SgtShader._ScatteringRayleigh, scatteringRayleigh);

                    SgtHelper.EnableKeyword("SGT_B", outerMaterial);                     // Scattering

                    if (groundScattering == true)
                    {
                        innerMaterial.SetTexture(SgtShader._ScatteringTex, scatteringTex);
                        innerMaterial.SetFloat(SgtShader._ScatteringMie, scatteringMie);
                        innerMaterial.SetFloat(SgtShader._ScatteringRayleigh, scatteringRayleigh);

                        SgtHelper.EnableKeyword("SGT_B", innerMaterial);                         // Scattering
                    }
                    else
                    {
                        SgtHelper.DisableKeyword("SGT_B", innerMaterial);                         // Scattering
                    }
                }
                else
                {
                    SgtHelper.DisableKeyword("SGT_B", innerMaterial);                     // Scattering
                    SgtHelper.DisableKeyword("SGT_B", outerMaterial);                     // Scattering
                }
            }

            CachedSharedMaterial.Material = innerMaterial;
        }