Ejemplo n.º 1
0
    void Start()
    {
        if (Screen.dpi < 1)
        {
            dpiScale = 1;
        }
        if (Screen.dpi < 200)
        {
            dpiScale = 1;
        }
        else
        {
            dpiScale = Screen.dpi / 200f;
        }
        guiStyleHeader.fontSize         = (int)(15f * dpiScale);
        guiStyleHeader.normal.textColor = guiColor;
        guiStyleHeaderMobile.fontSize   = (int)(17f * dpiScale);

        ChangeCurrent(Current);

        startSunIntensity        = Sun.intensity;
        startSunRotation         = Sun.transform.rotation;
        startAmbientLight        = RenderSettings.ambientLight;
        startAmbientIntencity    = RenderSettings.ambientIntensity;
        startReflectionIntencity = RenderSettings.reflectionIntensity;
        startLightShadows        = Sun.shadows;

        if (isMobile)
        {
            ChangeLight();
        }
        // RFX1_DistortionAndBloom = Camera.main.GetComponent<RFX1_DistortionAndBloom>();
    }
        void SetShaderKeywords(CommandBuffer cmd, ref CameraData cameraData, ref LightData lightData, ref ShadowData shadowData)
        {
            int vertexLightsCount = lightData.totalAdditionalLightsCount - lightData.pixelAdditionalLightsCount;

            CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.AdditionalLights, lightData.totalAdditionalLightsCount > 0);
            CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.MixedLightingSubtractive, m_MixedLightingSetup == MixedLightingSetup.Subtractive);
            CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.VertexLights, vertexLightsCount > 0);

            // TODO: We have to discuss cookie approach on LWRP.
            // CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.MainLightCookieText, mainLightIndex != -1 && LightweightUtils.IsSupportedCookieType(visibleLights[mainLightIndex].lightType) && visibleLights[mainLightIndex].light.cookie != null);

            LightShadows directionalShadowQuality = shadowData.renderedDirectionalShadowQuality;
            LightShadows localShadowQuality       = shadowData.renderedLocalShadowQuality;

            // Currently shadow filtering keyword is shared between local and directional shadows.
            bool hasSoftShadows = (directionalShadowQuality == LightShadows.Soft || localShadowQuality == LightShadows.Soft) &&
                                  shadowData.supportsSoftShadows;

            CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.DirectionalShadows, directionalShadowQuality != LightShadows.None);
            CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.LocalShadows, localShadowQuality != LightShadows.None);
            CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.SoftShadows, hasSoftShadows);
            CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.CascadeShadows, shadowData.directionalLightCascadeCount > 1);

            // TODO: Remove this. legacy particles support will be removed from Unity in 2018.3. This should be a shader_feature instead with prop exposed in the Standard particles shader.
            CoreUtils.SetKeyword(cmd, "SOFTPARTICLES_ON", cameraData.requiresSoftParticles);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="binaryReader"></param>
        public override void Deserialize(BinaryReader binaryReader)
        {
            base.Deserialize(binaryReader);
#if UNITY_2019_1_OR_NEWER
            lightShape          = (LightShape)binaryReader.ReadInt32();
            colorTemperature    = binaryReader.ReadSingle();
            useColorTemperature = binaryReader.ReadBoolean();
            renderingLayerMask  = binaryReader.ReadInt32();
#endif
            lightType         = (LightType)binaryReader.ReadInt32();
            range             = binaryReader.ReadSingle();
            spotAngle         = binaryReader.ReadSingle();
            innerSpotAngle    = binaryReader.ReadSingle();
            cookieSize        = binaryReader.ReadSingle();
            m_colorKun        = SerializerKun.DesirializeObject <ColorKun>(binaryReader);
            intensity         = binaryReader.ReadSingle();
            bounceIntensity   = binaryReader.ReadSingle();
            cookie            = binaryReader.ReadString();
            shadowsType       = (LightShadows)binaryReader.ReadInt32();
            shadowsStrength   = binaryReader.ReadSingle();
            shadowsResolution = (UnityEngine.Rendering.LightShadowResolution)binaryReader.ReadInt32();
            shadowsBias       = binaryReader.ReadSingle();
            shadowsNormalBias = binaryReader.ReadSingle();
            shadowsNearPlane  = binaryReader.ReadSingle();
            halo        = binaryReader.ReadBoolean();
            flare       = binaryReader.ReadString();
            renderMode  = (LightRenderMode)binaryReader.ReadInt32();
            cullingMask = binaryReader.ReadInt32();
        }
Ejemplo n.º 4
0
        public void GetFrom(Light light)
        {
            name     = light.name;
            modThis  = true;
            isActive = light.gameObject.activeSelf;

            Transform t = light.transform;

            position = t.localPosition;
            rotation = t.localRotation.eulerAngles;

            type      = light.type;
            range     = light.range;
            spotAngle = light.spotAngle;
            color     = light.color;
            intensity = light.intensity;
            shadows   = light.shadows;

            GameStateLight gameStateLight = light.GetComponent <GameStateLight>();

            dependentOnGameState = gameStateLight != null && gameStateLight.enabled;
            if (dependentOnGameState)
            {
                intensityWaiting = gameStateLight.intensityWaiting;
                intensityPlaying = gameStateLight.intensityPlaying;
            }
        }
Ejemplo n.º 5
0
 public ShadowSettings(LightShadows shadows, ShadowProjection shadowProjection, int shadowCascades, float shadowDistance)
 {
     this.shadows          = shadows;
     this.shadowProjection = shadowProjection;
     this.shadowCascades   = shadowCascades;
     this.shadowDistance   = shadowDistance;
 }
Ejemplo n.º 6
0
	static void OpenGeovoxIntegrationWindow(){
		Resolution res = Screen.currentResolution;
		
		UpdateCurrentSourceDirectory();
		
		if ( window == null ){
			window = ScriptableObject.CreateInstance<AGF_IntegrationWindow>();
			window.ShowUtility();
			
			window.position = new Rect( res.width * 0.25f, res.height * 0.25f, 500.0f, 200 );
			window.title = "Geovox Scene Loader";
			window.maxSize = new Vector2( window.position.width, window.position.height );
			window.minSize = new Vector2( window.position.width, window.position.height );
			window.integrationType = IntegrationType.Geovox;
			
			m_CurrentWindowState = WindowState.ModeSelect;
			
		} else {
			window.Focus();
		}

		lightShadows = (LightShadows)PlayerPrefs.GetInt (Main.gameName + "ShadowType", 2);
		terrainShadows = PlayerPrefs.GetInt (Main.gameName + "TerrainShadowType", 1) == 1;
		grassShadows = PlayerPrefs.GetInt (Main.gameName + "GrassShadowType", 1) == 1;
		prefabShadows = PlayerPrefs.GetInt (Main.gameName + "PrefabShadowType", 1) == 1;
		terrainSpecular = PlayerPrefs.GetInt (Main.gameName + "TerrainSpecular", 1) == 1;
		
		prevRunInBackground = Application.runInBackground;
		Application.runInBackground = true;
	}
Ejemplo n.º 7
0
        void Awake()
        {
            _light = GetComponent <Light>();
            UpdateRememberedValues();

            switch (_light.shadows)
            {
            case LightShadows.None:
                _hardShadowsValue = LightShadows.None;
                _softShadowsValue = LightShadows.None;
                break;

            case LightShadows.Hard:
                _hardShadowsValue = LightShadows.Hard;
                _softShadowsValue = LightShadows.Hard;
                break;

            case LightShadows.Soft:
                _hardShadowsValue = LightShadows.Hard;
                _softShadowsValue = LightShadows.Soft;
                break;
            }

            UpdatesManager.Subscribe(OnUpdate, 0.1f); // 10 times per second
        }
Ejemplo n.º 8
0
        private void CheckIfQualitySettingsAreApplied()
        {
            Assert.IsTrue(lwrpAsset.msaaSampleCount == (int)DCL.Settings.i.qualitySettings.antiAliasing, "antiAliasing mismatch");
            Assert.IsTrue(lwrpAsset.renderScale == DCL.Settings.i.qualitySettings.renderScale, "renderScale mismatch");
            Assert.IsTrue(lwrpAsset.supportsMainLightShadows == DCL.Settings.i.qualitySettings.shadows, "shadows mismatch");
            Assert.IsTrue(lwrpAsset.supportsSoftShadows == DCL.Settings.i.qualitySettings.softShadows, "softShadows mismatch");
            Assert.IsTrue(lwrpAsset.mainLightShadowmapResolution == (int)DCL.Settings.i.qualitySettings.shadowResolution, "shadowResolution mismatch");

            LightShadows shadowType = LightShadows.None;

            if (DCL.Settings.i.qualitySettings.shadows)
            {
                shadowType = DCL.Settings.i.qualitySettings.softShadows ? LightShadows.Soft : LightShadows.Hard;
            }
            Assert.IsTrue(environmentLight.shadows == shadowType, "shadows (environmentLight) mismatch");
            Bloom bloom;

            if (postProcessVolume.profile.TryGetSettings(out bloom))
            {
                Assert.IsTrue(bloom.enabled.value == DCL.Settings.i.qualitySettings.bloom, "bloom mismatch");
            }
            ColorGrading colorGrading;

            if (postProcessVolume.profile.TryGetSettings(out colorGrading))
            {
                Assert.IsTrue(colorGrading.enabled.value == DCL.Settings.i.qualitySettings.colorGrading, "colorGrading mismatch");
            }
            Assert.IsTrue(firstPersonCamera.m_Lens.FarClipPlane == DCL.Settings.i.qualitySettings.cameraDrawDistance, "cameraDrawDistance (firstPersonCamera) mismatch");
            Assert.IsTrue(freeLookCamera.m_Lens.FarClipPlane == DCL.Settings.i.qualitySettings.cameraDrawDistance, "cameraDrawDistance (freeLookCamera) mismatch");
        }
        public static void SetCityLightShadows(LightShadows spotLightShadows, LightShadows pointLightShadows)
        {
            if (isHousingIsland)
            {
                return;
            }

            var lights = GetCityLights();

            if (lights.IsNullOrEmpty())
            {
                return;
            }

            foreach (var light in lights)
            {
                if (light.type == LightType.Spot)
                {
                    light.shadows = spotLightShadows;
                }

                if (light.type == LightType.Point)
                {
                    light.shadows = pointLightShadows;
                }
            }
        }
Ejemplo n.º 10
0
        private void CheckIfQualitySettingsAreApplied()
        {
            Assert.IsTrue(lwrpAsset.msaaSampleCount == (int)DCL.Settings.i.qualitySettings.antiAliasing, "antiAliasing mismatch");
            Assert.IsTrue(lwrpAsset.renderScale == DCL.Settings.i.qualitySettings.renderScale, "renderScale mismatch");
            Assert.IsTrue(lwrpAsset.supportsMainLightShadows == DCL.Settings.i.qualitySettings.shadows, "shadows mismatch");
            Assert.IsTrue(lwrpAsset.supportsSoftShadows == DCL.Settings.i.qualitySettings.softShadows, "softShadows mismatch");
            Assert.IsTrue(lwrpAsset.mainLightShadowmapResolution == (int)DCL.Settings.i.qualitySettings.shadowResolution, "shadowResolution mismatch");

            LightShadows shadowType = LightShadows.None;

            if (DCL.Settings.i.qualitySettings.shadows)
            {
                shadowType = DCL.Settings.i.qualitySettings.softShadows ? LightShadows.Soft : LightShadows.Hard;
            }

            Assert.IsTrue(environmentLight.shadows == shadowType, "shadows (environmentLight) mismatch");

            if (postProcessVolume.profile.TryGet <Bloom>(out Bloom bloom))
            {
                Assert.IsTrue(bloom.active == DCL.Settings.i.qualitySettings.bloom, "bloom mismatch");
            }

            if (postProcessVolume.profile.TryGet <Tonemapping>(out Tonemapping toneMapping))
            {
                Assert.IsTrue(toneMapping.active == DCL.Settings.i.qualitySettings.colorGrading, "colorGrading mismatch");
            }

            UnityEngine.Assertions.Assert.AreApproximatelyEqual(firstPersonCamera.m_Lens.FarClipPlane, DCL.Settings.i.qualitySettings.cameraDrawDistance, "cameraDrawDistance (firstPersonCamera) mismatch");
            UnityEngine.Assertions.Assert.AreApproximatelyEqual(freeLookCamera.m_Lens.FarClipPlane, DCL.Settings.i.qualitySettings.cameraDrawDistance, "cameraDrawDistance (freeLookCamera) mismatch");
        }
Ejemplo n.º 11
0
    void Awake()
    {
        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            switch (Device.generation)
            {
            case DeviceGeneration.iPhone5S:
                shadowType = LightShadows.Hard;
                break;

            case DeviceGeneration.iPhone6:
                shadowType = LightShadows.Soft;
                break;

            case DeviceGeneration.iPhone6Plus:
                shadowType = LightShadows.Soft;
                break;

            default:
                shadowType = LightShadows.None;
                break;
            }
            GameObject.Find("Directional Light").GetComponent <Light>().shadows = shadowType;
        }
    }
Ejemplo n.º 12
0
        protected override void ReadFromImpl(object obj)
        {
            base.ReadFromImpl(obj);
            Light uo = (Light)obj;

            shadows                  = uo.shadows;
            shadowStrength           = uo.shadowStrength;
            shadowResolution         = uo.shadowResolution;
            layerShadowCullDistances = uo.layerShadowCullDistances;
            cookieSize               = uo.cookieSize;
            cookie                 = ToID(uo.cookie);
            renderMode             = uo.renderMode;
            areaSize               = uo.areaSize;
            lightmapBakeType       = uo.lightmapBakeType;
            type                   = uo.type;
            spotAngle              = uo.spotAngle;
            color                  = uo.color;
            colorTemperature       = uo.colorTemperature;
            intensity              = uo.intensity;
            bounceIntensity        = uo.bounceIntensity;
            shadowCustomResolution = uo.shadowCustomResolution;
            shadowBias             = uo.shadowBias;
            shadowNormalBias       = uo.shadowNormalBias;
            shadowNearPlane        = uo.shadowNearPlane;
            range                  = uo.range;
            flare                  = ToID(uo.flare);
            bakingOutput           = uo.bakingOutput;
            cullingMask            = uo.cullingMask;
            lightShadowCasterMode  = uo.lightShadowCasterMode;
            shadowRadius           = uo.shadowRadius;
            shadowAngle            = uo.shadowAngle;
        }
Ejemplo n.º 13
0
    void Start()
    {
        if (Screen.dpi < 1)
        {
            dpiScale = 1;
        }
        if (Screen.dpi < 200)
        {
            dpiScale = 1;
        }
        else
        {
            dpiScale = Screen.dpi / 200f;
        }
        guiStyleHeader.fontSize = (int)(15f * dpiScale);
        //guiStyleHeader.normal.textColor = new Color(0.15f,0.15f,0.15f);
        guiStyleHeaderMobile.fontSize = (int)(17f * dpiScale);

        ChangeCurrent(0);

        startSunIntensity        = Sun.intensity;
        startSunRotation         = Sun.transform.rotation;
        startAmbientLight        = RenderSettings.ambientLight;
        startAmbientIntencity    = RenderSettings.ambientIntensity;
        startReflectionIntencity = RenderSettings.reflectionIntensity;
        startLightShadows        = Sun.shadows;

        ChangeDayNight();
    }
Ejemplo n.º 14
0
    static int IntToEnum(IntPtr L)
    {
        int          arg0 = (int)LuaDLL.lua_tonumber(L, 1);
        LightShadows o    = (LightShadows)arg0;

        LuaScriptMgr.PushEnum(L, o);
        return(1);
    }
Ejemplo n.º 15
0
 //Sets the shadows for all of the lights to none, soft or hard
 void SetShadowsOfAllLights(LightShadows lightShadows)
 {
     Light[] lights = Object.FindObjectsOfType<Light> ();
     foreach (Light light in lights)
     {
         light.shadows = lightShadows;
     }
 }
Ejemplo n.º 16
0
 //Sets the shadows for all of the lights to none, soft or hard
 void SetShadowsOfAllLights(LightShadows lightShadows)
 {
     Light[] lights = Object.FindObjectsOfType <Light> ();
     foreach (Light light in lights)
     {
         light.shadows = lightShadows;
     }
 }
Ejemplo n.º 17
0
    private void Update()
    {
        LightShadows lightShadow = (LightShadows)Mathf.Clamp(ConVar.Graphics.shadowmode, 1, 2);

        if (this.light.shadows != lightShadow)
        {
            this.light.shadows = lightShadow;
        }
    }
Ejemplo n.º 18
0
    public void ApplyQualitySetting(Light light, LightShadows defaultValue)
    {
        LightShadows lightShadows = (this.ShadowLevel >= TheForestQualitySettings.ShadowLevels.Low) ? LightShadows.None : defaultValue;

        if (light.shadows != lightShadows)
        {
            light.shadows = lightShadows;
        }
    }
Ejemplo n.º 19
0
        void Awake()
        {
            mainLight1Shadows = MainLight1.shadows;
            mainLight2Shadows = MainLight2.shadows;
            mainLight3Shadows = MainLight3.shadows;

            FillLight1.shadows = LightShadows.None;

            EnableShadows(true);
        }
Ejemplo n.º 20
0
 public override TaskStatus OnUpdate()
 {
     if (this.light == null)
     {
         Debug.LogWarning("Light is null");
         return(TaskStatus.Failure);
     }
     this.light.shadows = this.shadows;
     return(TaskStatus.Success);
 }
Ejemplo n.º 21
0
        private void Start()
        {
            light = GetComponent <Light>();
            DesiredLightShadowQuality = light.shadows;

            //Replace this with your "Player" object
            LocalPlayer = GameObject.FindObjectOfType <FreeCamera>();

            StartCoroutine("AdjustLODQuality");
        }
Ejemplo n.º 22
0
    private void Update()
    {
        LightShadows lightShadows = (LightShadows)Mathf.Clamp(Graphics.shadowmode, 1, 2);

        if (this.light.get_shadows() == lightShadows)
        {
            return;
        }
        this.light.set_shadows(lightShadows);
    }
 public void SetShadowsType(LightShadows type)
 {
     Light[] lights = GameObject.FindObjectsOfType <Light>();
     if (lights != null)
     {
         foreach (Light light in lights)
         {
             light.shadows = type;
         }
     }
 }
Ejemplo n.º 24
0
        //--------------------------------------------------------------------------------------------------------------------------

        private static Light CreateBaseLight(Color color, LightShadows shadows, float intensity)
        {
            var go = new GameObject("Light");

            var cmp = go.AddComponent <Light>();

            cmp.color     = color;
            cmp.shadows   = shadows;
            cmp.intensity = intensity;

            return(cmp);
        }
Ejemplo n.º 25
0
        private void Start()
        {
            light = GetComponent <Light>();
            DesiredLightShadowQuality = light.shadows;
            InspectorShadowResolution = light.shadowResolution;
            InitiallyOn = light.enabled;

            //Replace this with your "Player" object
            LODCameras = new List <LightLODCamera>(GameObject.FindObjectsOfType <LightLODCamera>());

            StartCoroutine("AdjustLODQuality");
        }
Ejemplo n.º 26
0
        public LightKun(Component component) : base(component)
        {
            componentKunType = BehaviourKun.ComponentKunType.Light;
            cookie           = "";
            flare            = "";
            m_colorKun       = new ColorKun();
            var light = component as Light;

            if (light)
            {
#if UNITY_2019_1_OR_NEWER
                lightShape          = light.shape;
                useColorTemperature = light.useColorTemperature;
                colorTemperature    = light.colorTemperature;
                renderingLayerMask  = light.renderingLayerMask;
#endif
                enabled        = light.enabled;
                lightType      = light.type;
                range          = light.range;
                spotAngle      = light.spotAngle;
                innerSpotAngle = light.spotAngle;
                cookieSize     = light.cookieSize;
                if (light.cookie != null)
                {
                    cookie = light.cookie.name;
                }
                else
                {
                    cookie = "";
                }
                if (light.flare != null)
                {
                    flare = light.flare.name;
                }
                else
                {
                    flare = "";
                }
                color           = light.color;
                intensity       = light.intensity;
                bounceIntensity = light.bounceIntensity;

                shadowsType       = light.shadows;
                shadowsStrength   = light.shadowStrength;
                shadowsBias       = light.shadowBias;
                shadowsNormalBias = light.shadowNormalBias;
                shadowsNormalBias = light.shadowNormalBias;
                // halo
                renderMode  = light.renderMode;
                cullingMask = light.cullingMask;
            }
        }
Ejemplo n.º 27
0
        private void Update()
        {
            if (!lightComponent)
            {
                return;
            }

            if (lightComponent.isBaked)
            {
                return;
            }

            if (lastShadowMode == LightShadows.None && lightComponent.shadows == LightShadows.None)
            {
                //Light doesnt have shadows.
                return;
            }

            Camera mainCamera = Camera.main;

            if (!mainCamera)
            {
                return;
            }

            Vector3 center      = GetCenter();
            float   distToLight = Vector3.Distance(mainCamera.transform.position, center);

            float distanceRatio = Mathf.Clamp01(distToLight / maxShadowDistance);

            if (distanceRatio >= 1)
            {
                if (lightComponent.shadows != LightShadows.None)
                {
                    lastShadowMode         = lightComponent.shadows;
                    lightComponent.shadows = LightShadows.None;
                }
            }
            else
            {
                if (lightComponent.shadows == LightShadows.None)
                {
                    lightComponent.shadows = lastShadowMode;
                }

                float fade = 1.0f - Mathf.Clamp01((distanceRatio - shadowFadeRatio) / (1.0f - shadowFadeRatio));
                if (lightComponent.shadowStrength != fade)
                {
                    lightComponent.shadowStrength = fade;
                }
            }
        }
Ejemplo n.º 28
0
        private void Update()
        {
            if (light == null)
            {
                this.light = base.GetComponent <Light>();
            }
            LightShadows lightShadows = 0;

            if (this.light.shadows != lightShadows)
            {
                this.light.shadows = lightShadows;
            }
        }
Ejemplo n.º 29
0
    public LightComponent(Component comp)
        : base(comp)
    {
        Light light = comp as Light;

        if (light != null)
        {
            lightType  = light.type;
            color      = light.color;
            lightMode  = light.lightmapBakeType;
            intensity  = light.intensity;
            shadowType = light.shadows;
        }
    }
Ejemplo n.º 30
0
 public override void Read(BinaryReader br)
 {
     this.firstRun           = false;
     this.type               = (LightType)br.ReadInt32();
     this.color              = new Color(br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
     this.intensity          = br.ReadSingle();
     this.shadows            = (LightShadows)br.ReadInt32();
     this.shadowStrength     = br.ReadSingle();
     this.shadowBias         = br.ReadSingle();
     this.shadowSoftness     = br.ReadSingle();
     this.shadowSoftnessFade = br.ReadSingle();
     this.range              = br.ReadSingle();
     this.spotAngle          = br.ReadSingle();
     this.cullingMask        = br.ReadInt32();
 }
 void OnEnable()
 {
     lightTarget       = GetComponent <LightTarget>();
     intensity         = lightTarget.lightTargetParameters.intensity;
     indirectIntensity = lightTarget.lightTargetParameters.indirectIntensity;
     range             = lightTarget.lightTargetParameters.range;
     colorTemperature  = lightTarget.lightTargetParameters.colorTemperature;
     colorFilter       = lightTarget.lightTargetParameters.colorFilter;
     lightAngle        = lightTarget.lightTargetParameters.lightAngle;
     shadows           = lightTarget.lightTargetParameters.shadows;
     //shadowsResolution=lightTarget.lightTargetParameters.shadowsResolution;
     shadowQuality  = lightTarget.lightTargetParameters.shadowQuality;
     ShadowNearClip = lightTarget.lightTargetParameters.ShadowNearClip;
     shadowBias     = lightTarget.lightTargetParameters.shadowBias;
 }
Ejemplo n.º 32
0
        void ApplyQualitySettings(SettingsData.QualitySettings qualitySettings)
        {
            UnitySettings.masterTextureLimit = (int)qualitySettings.textureQuality;

            if (lightweightRenderPipelineAsset)
            {
                lightweightRenderPipelineAsset.msaaSampleCount = (int)qualitySettings.antiAliasing;
                lightweightRenderPipelineAsset.renderScale     = qualitySettings.renderScale;

                lwrpaShadowField?.SetValue(lightweightRenderPipelineAsset, qualitySettings.shadows);
                lwrpaSoftShadowField?.SetValue(lightweightRenderPipelineAsset, qualitySettings.softShadows);
                lwrpaShadowResolutionField?.SetValue(lightweightRenderPipelineAsset, qualitySettings.shadowResolution);
            }

            if (environmentLight)
            {
                LightShadows shadowType = LightShadows.None;
                if (qualitySettings.shadows)
                {
                    shadowType = qualitySettings.softShadows ? LightShadows.Soft : LightShadows.Hard;
                }
                environmentLight.shadows = shadowType;
            }

            if (postProcessVolume)
            {
                Bloom bloom;
                if (postProcessVolume.profile.TryGetSettings(out bloom))
                {
                    bloom.enabled.value = qualitySettings.bloom;
                }
                ColorGrading colorGrading;
                if (postProcessVolume.profile.TryGetSettings(out colorGrading))
                {
                    colorGrading.enabled.value = qualitySettings.colorGrading;
                }
            }

            if (thirdPersonCamera)
            {
                thirdPersonCamera.m_Lens.FarClipPlane = qualitySettings.cameraDrawDistance;
            }

            if (firstPersonCamera)
            {
                firstPersonCamera.m_Lens.FarClipPlane = qualitySettings.cameraDrawDistance;
            }
        }
Ejemplo n.º 33
0
 private void OnPreCull()
 {
     if (!this.GoodToGo)
     {
         SunshineKeywords.DisableShadows();
         return;
     }
     this.RenderCascades();
     this.ConfigureShaders();
     if (this.ShadowsActive)
     {
         this._lightShadows = Sunshine.Instance.SunLight.shadows;
         this._lightRenderMode = Sunshine.Instance.SunLight.renderMode;
         Sunshine.Instance.SunLight.shadows = LightShadows.None;
         Sunshine.Instance.SunLight.renderMode = LightRenderMode.ForcePixel;
     }
     if (Sunshine.Instance.RequiresPostprocessing && (this.AttachedCamera.depthTextureMode & DepthTextureMode.Depth) == DepthTextureMode.None && SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth))
     {
         this.AttachedCamera.depthTextureMode |= DepthTextureMode.Depth;
     }
 }
Ejemplo n.º 34
0
    void OnPreCull()
    {
        if(!GoodToGo)
        {
            SunshineKeywords.DisableShadows();
            return;
        }

        RenderCascades();

        ConfigureShaders();

        if(ShadowsActive)
        {
            _lightShadows = Sunshine.Instance.SunLight.shadows;
            _lightRenderMode = Sunshine.Instance.SunLight.renderMode;
            Sunshine.Instance.SunLight.shadows = LightShadows.None; //Disable built-in shadows
            Sunshine.Instance.SunLight.renderMode = LightRenderMode.ForcePixel; //Force per-pixel lighting
        }

        if(Sunshine.Instance.RequiresPostprocessing)
        {
            //Check for existing depth textures...
            bool usingDepth = (AttachedCamera.depthTextureMode & DepthTextureMode.Depth) != 0;
            if(!usingDepth)
            {
                if(SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth))
                    AttachedCamera.depthTextureMode |= DepthTextureMode.Depth;
            }
        }
    }
 public ShadowSettings(LightShadows shadows, ShadowProjection shadowProjection, int shadowCascades, float shadowDistance)
 {
     this.shadows = shadows;
     this.shadowProjection = shadowProjection;
     this.shadowCascades = shadowCascades;
     this.shadowDistance = shadowDistance;
 }
Ejemplo n.º 36
0
	private void OnGUI(){
		float currentHeight = 10.0f;
		Rect thisRect = window.position;

		string integrationPrefix = "";
		if(integrationType == IntegrationType.AGF){
			integrationPrefix = "AGF";
		}
		else if(integrationType == IntegrationType.Geovox){
			integrationPrefix = "Geovox";
		}

		if ( sourceDirectory == "" ){
			UpdateCurrentSourceDirectory();	
		}
			
		if (m_CurrentWindowState == WindowState.ModeSelect) {

			// Title Text
			DisplayCenteredText (ref currentHeight, 15, integrationPrefix + " Scene Loader");
			
			// Help Box
			float helpBoxSideMargin = 20.0f, helpBoxHeight = 20.0f;
			EditorGUI.HelpBox (new Rect (helpBoxSideMargin, currentHeight, thisRect.width - (helpBoxSideMargin * 2.0f), helpBoxHeight), "Choose which task you would like to perform.", MessageType.Info);
			currentHeight += 30.0f;
			
			float buttonWidth = 400.0f, buttonHeight = 20.0f;

			if (integrationType == IntegrationType.AGF) {
				//Warning label
				GUI.Label (new Rect (20, currentHeight, thisRect.width - 40, 60), "TURN OFF DIRECTX3D11\nTHE AGF TERRAIN SHADER DOES NOT WORK WITH " +
					"DX11 INSIDE UNITY\nFILE>BUILD SETTINGS>PLAYER SETTINGS>USE DIRECTX3D11\nOFF OR UNCHECKED.");
				currentHeight += 60;
			}
			
			// Buttons
			if (GUI.Button (new Rect (thisRect.width / 2.0f - buttonWidth / 2.0f, currentHeight, buttonWidth, buttonHeight), "Select default directory")) {
				m_CurrentWindowState = WindowState.SetDirectory;
			}
			currentHeight += 30.0f;
			
			if (GUI.Button (new Rect (thisRect.width / 2.0f - buttonWidth / 2.0f, currentHeight, buttonWidth, buttonHeight), "Import Geovox Scene")){
				if (!GameObject.Find ("Geovox_Integration")) {
					string path = "Assets/AGF_SceneLoader/AGF_Assets/Prefabs/Geovox_Integration.prefab";
					GameObject integrationPrefab = (GameObject)MonoBehaviour.Instantiate ((GameObject)AssetDatabase.LoadAssetAtPath (path, typeof(GameObject)));
					integrationPrefab.name = "Geovox_Integration";
					Debug.Log ("Integration prefab created");
				}
				if (GameObject.Find ("Geovox_Integration")) {
					int returnCode = LoadGeovoxScene ();
					if (returnCode != AGF_ReturnCode.Success) {
						Debug.LogError(returnCode);
						HandleLoadSceneError (returnCode);
					}
				} else {
					Debug.LogError ("Failed to create integration prefab from Assets/AGF_SceneLoader/AGF_Assets/Prefabs/Geovox_Integration.prefab");
				}
			}
			currentHeight += 30.0f;
			
			if (GUI.Button (new Rect (thisRect.width / 2.0f - buttonWidth / 2.0f, currentHeight, buttonWidth, buttonHeight), "Import Settings")) {
				m_CurrentWindowState = WindowState.Settings;
				m_PrevWindowState = WindowState.ModeSelect;
			}
			currentHeight += 30.0f;
			
			buttonWidth = 70.0f;
			buttonHeight = 20.0f;
			if (GUI.Button (new Rect (thisRect.width - 20.0f - buttonWidth, thisRect.height - 10.0f - buttonHeight, buttonWidth, buttonHeight), "Help")) {
				m_CurrentWindowState = WindowState.Help;
				m_PrevWindowState = WindowState.ModeSelect;
			}

//			if(GUI.Button(new Rect(20, thisRect.height - 40, 20, 20), "+")){
//				foreach(Transform chunk in FindObjectsOfType<Transform>()){
//					if(chunk.name == "HiResChunk"){
//						if(!AGF_IntegrationWindow.terrainSpecular){
//							chunk.GetComponent<Renderer>().sharedMaterial.shader = Shader.Find("Standard");
//						}
//						else{
//							chunk.GetComponent<Renderer>().sharedMaterial.shader = Shader.Find("Standard (Specular setup)");
//						}
//					}
//				}
//			}
//			
//			if(GUI.Button(new Rect(50, thisRect.height - 40, 20, 20), "+")){
//				foreach(Transform chunk in FindObjectsOfType<Transform>()){
//					if(chunk.name == "HiResChunk"){
//						if(!AGF_IntegrationWindow.terrainSpecular){
//							chunk.GetComponent<Renderer>().sharedMaterial.shader = Shader.Find("Voxel/Standard");
//						}
//						else{
//							chunk.GetComponent<Renderer>().sharedMaterial.shader = Shader.Find("Voxel/Standard (Specular setup)");
//						}
//					}
//				}
//			}
			
		} else if (m_CurrentWindowState == WindowState.Help) {
			// Title Text
			DisplayCenteredText (ref currentHeight, 15, "Help");
			
			float buttonWidth = 400.0f, buttonHeight = 20.0f;
			if (GUI.Button (new Rect (thisRect.width / 2.0f - buttonWidth / 2.0f, currentHeight, buttonWidth, buttonHeight), "My Unity Scene does not have a camera. What should I do?")) {
				m_CurrentWindowState = WindowState.HelpCamera;
			}
			currentHeight += 30.0f;
			
			buttonWidth = 70.0f;
			buttonHeight = 20.0f;
			if (GUI.Button (new Rect (thisRect.width - 20.0f - buttonWidth, thisRect.height - 10.0f - buttonHeight, buttonWidth, buttonHeight), "Back")) {
				m_CurrentWindowState = m_PrevWindowState;
			}
			
		} else if (m_CurrentWindowState == WindowState.Settings) {
			// Title Text
			DisplayCenteredText (ref currentHeight, 15, "Settings");
			
			float buttonWidth = 400.0f, buttonHeight = 20.0f;

			GUI.Label(new Rect(30, currentHeight, 200, 20), "Shadow type:");
			lightShadows = (LightShadows)EditorGUI.EnumPopup(new Rect(thisRect.width - 230, currentHeight, 200, 20), lightShadows);
			currentHeight += 20;
			
			GUI.Label(new Rect(30, currentHeight, 200, 20), "Terrain Shadows:");
			terrainShadows = EditorGUI.Toggle(new Rect(thisRect.width - 50, currentHeight, 20, 20), terrainShadows);
			currentHeight += 20;
			
			GUI.Label(new Rect(30, currentHeight, 200, 20), "Grass Shadows:");
			grassShadows = EditorGUI.Toggle(new Rect(thisRect.width - 50, currentHeight, 20, 20), grassShadows);
			currentHeight += 20;
			
			GUI.Label(new Rect(30, currentHeight, 200, 20), "Prefab Shadows:");
			prefabShadows = EditorGUI.Toggle(new Rect(thisRect.width - 50, currentHeight, 20, 20), prefabShadows);
			currentHeight += 20;
			
			GUI.Label(new Rect(30, currentHeight, 200, 20), "Use Terrain Specular:");
			terrainSpecular = EditorGUI.Toggle(new Rect(thisRect.width - 50, currentHeight, 20, 20), terrainSpecular);
			currentHeight += 20;
			
			buttonWidth = 70.0f;
			buttonHeight = 20.0f;
			if (GUI.Button (new Rect (thisRect.width - 20.0f - buttonWidth, thisRect.height - 10.0f - buttonHeight, buttonWidth, buttonHeight), "Back")) {
				PlayerPrefs.SetInt(Main.gameName + "ShadowType", (int)lightShadows);
				PlayerPrefs.SetInt(Main.gameName + "TerrainShadowType", terrainShadows ? 1 : 0);
				PlayerPrefs.SetInt(Main.gameName + "GrassShadowType", grassShadows ? 1 : 0);
				PlayerPrefs.SetInt(Main.gameName + "PrefabShadowType", prefabShadows ? 1 : 0);
				PlayerPrefs.SetInt(Main.gameName + "TerrainSpecular", terrainSpecular ? 1 : 0);


				m_CurrentWindowState = m_PrevWindowState;
			}
		}
		else if ( m_CurrentWindowState == WindowState.HelpCamera ){
			DisplayCenteredText( ref currentHeight, 15, "Camera Information" );
			
			DisplayWordWrappedCenteredText( ref currentHeight, 11, 
				"Unity provides a quick method of inserting a basic camera and character controller into your scene. " +
				"In the Menu Bar, navigate to Assets > Import Package. From there, click on \"Character Controller\", and import. " +
				"Drag in the \"First Person Controller\" prefab. You will notice that the prefab includes a main camera as one of its children.\n\n" +
				"When importing an " + integrationPrefix + " scene, select this new camera. Your " + integrationPrefix + " scene will load, apply all the necessary filters and skybox textures to the camera, and be ready to go!", 450.0f, true );
			
			float buttonWidth = 70.0f, buttonHeight = 20.0f;
			if ( GUI.Button ( new Rect( thisRect.width - 20.0f - buttonWidth, thisRect.height - 10.0f - buttonHeight, buttonWidth, buttonHeight ), "Back" ) ){
				m_CurrentWindowState = WindowState.Help;
			}
			
		} else if ( m_CurrentWindowState == WindowState.ConfigureCamera ){
			DisplaySceneImport( ref currentHeight, "Import Camera Settings from "+integrationPrefix + " Scene", "Use this utility if you have added a camera to your Unity scene after already performing the " +integrationPrefix + " scene import process.", AGF_LevelLoader.LoadSceneMode.CameraOnly, integrationType );
			
			float buttonWidth = 70.0f, buttonHeight = 20.0f;
			if ( GUI.Button ( new Rect( thisRect.width - 20.0f - buttonWidth, thisRect.height - 10.0f - buttonHeight, buttonWidth, buttonHeight ), "Back" ) ){
				m_CurrentWindowState = WindowState.ModeSelect;
			}
			
			if ( GUI.Button ( new Rect( thisRect.width - 20.0f - buttonWidth * 2.0f - 10.0f, thisRect.height - 10.0f - buttonHeight, buttonWidth, buttonHeight ), "Help" ) ){
				m_PrevWindowState = WindowState.ConfigureCamera;
				m_CurrentWindowState = WindowState.Help;
			}
			
		} else if ( m_CurrentWindowState == WindowState.SceneImport ){
			DisplaySceneImport( ref currentHeight, "Import "+integrationPrefix + " Scene", "This utility will load a target "+integrationPrefix + " scene into the current active Unity scene. Note that a camera must exist within this Unity scene in order for the process to complete. (See help for more info.)", 
			                   AGF_LevelLoader.LoadSceneMode.All, integrationType );
			
			float buttonWidth = 70.0f, buttonHeight = 20.0f;
			if ( GUI.Button ( new Rect( thisRect.width - 20.0f - buttonWidth, thisRect.height - 10.0f - buttonHeight, buttonWidth, buttonHeight ), "Back" ) ){
				m_CurrentWindowState = WindowState.ModeSelect;
			}
			
			if ( GUI.Button ( new Rect( thisRect.width - 20.0f - buttonWidth * 2.0f - 10.0f, thisRect.height - 10.0f - buttonHeight, buttonWidth, buttonHeight ), "Help" ) ){
				m_PrevWindowState = WindowState.SceneImport;
				m_CurrentWindowState = WindowState.Help;
			}
			
		} else if ( m_CurrentWindowState == WindowState.SetDirectory ){
			if(!Directory.Exists(sourceDirectory)){
				sourceDirectory = Main.GetUserDataHomeFolder();
				System.IO.File.WriteAllText( Application.dataPath + "/SourceDirectory.txt", sourceDirectory );
			}

			// Title Text
			DisplayCenteredText( ref currentHeight, 15, "Set Source Directory" );
			
			currentHeight = 50.0f;
			
			DisplayWordWrappedCenteredText( ref currentHeight, 11, "Select the default directory to search for Geovox scenes.\n" +
				"If this is not set, it will default to the directory of this scene loader.", 450.0f );
			
			currentHeight += 30.0f;
			
			GUI.TextField ( new Rect( thisRect.width/2.0f - 400.0f/2.0f, currentHeight, 400.0f, 18.0f ), sourceDirectory );
			currentHeight += 20.0f;
			
			if ( GUI.Button ( new Rect( thisRect.width/2.0f - 400.0f/2.0f, currentHeight, 180.0f, 20.0f ), "Select Directory..." ) ){
				string newSourceDir = EditorUtility.OpenFolderPanel( "Set Source Directory", sourceDirectory, "" );
				if ( newSourceDir != "" ){
					sourceDirectory = newSourceDir;
					System.IO.File.WriteAllText( Application.dataPath + "/SourceDirectory.txt", sourceDirectory );
				}
			}
			
			if ( GUI.Button ( new Rect( thisRect.width/2.0f - 400.0f/2.0f + 220.0f, currentHeight, 180.0f, 20.0f ), "Use Default" ) ){
				sourceDirectory = Main.GetUserDataHomeFolder();
				System.IO.File.WriteAllText( Application.dataPath + "/SourceDirectory.txt", sourceDirectory );
			}
			
			float buttonWidth = 70.0f, buttonHeight = 20.0f;
			if ( GUI.Button ( new Rect( thisRect.width - 20.0f - buttonWidth, thisRect.height - 10.0f - buttonHeight, buttonWidth, buttonHeight ), "Back" ) ){
				m_CurrentWindowState = WindowState.ModeSelect;
			}
			
		} else if ( m_CurrentWindowState == WindowState.RuntimeLoader ){
			// Title Text
			DisplayCenteredText( ref currentHeight, 15, "Runtime Loader Setup" );
			
			DisplayCenteredText( ref currentHeight, 18, "Coming soon!", true );
			
			float buttonWidth = 70.0f, buttonHeight = 20.0f;
			if ( GUI.Button ( new Rect( thisRect.width - 20.0f - buttonWidth, thisRect.height - 10.0f - buttonHeight, buttonWidth, buttonHeight ), "Back" ) ){
				m_CurrentWindowState = WindowState.ModeSelect;
			}
			
		} else if ( m_CurrentWindowState == WindowState.LoadingScene ){
			// Title Text
			DisplayCenteredText( ref currentHeight, 15, "Loading Scene...", true );
			
		} else if ( m_CurrentWindowState == WindowState.ErrorMissingAssetBundle ){
			int prevLabelSize = GUI.skin.label.fontSize;
			bool prevWordWrap = GUI.skin.label.wordWrap;
			
			GUIContent errorText = new GUIContent("Error! An Asset Bundle was missing. "
				+ "Make sure all asset bundles required for loading the scene exist within: " 
				+ sourceDirectory + "/Asset Packs/ " 
				+ "(Refer to the console for more information.) ");
			
			GUI.skin.label.fontSize = 15;
			GUI.skin.label.wordWrap = true;
			float height = GUI.skin.label.CalcHeight( errorText, 400.0f );
			GUI.Label ( new Rect( thisRect.width/2.0f - 400.0f/2.0f, thisRect.height/2.0f - height/2.0f, 400.0f, height ), errorText );
			
			GUI.skin.label.fontSize = prevLabelSize;
			GUI.skin.label.wordWrap = prevWordWrap;
			
			float buttonWidth = 70.0f, buttonHeight = 20.0f;
			if ( GUI.Button ( new Rect( thisRect.width - 20.0f - buttonWidth, thisRect.height - 10.0f - buttonHeight, buttonWidth, buttonHeight ), "Back" ) ){
				m_CurrentWindowState = WindowState.ModeSelect;
			}
			
		} else if ( m_CurrentWindowState == WindowState.ErrorVersionNumber ){
			
		}
	}