Esempio n. 1
0
        public virtual void Init(ProlandManager manager)
        {
            m_manager = manager;
            loadFromConfigNode();

            InitOceanMaterial();

            //Worth moving to projected Grid Class?
            CreateProjectedGrid();

            oceanCameraProjectionMatModifier           = waterGameObjects[0].AddComponent <OceanCameraUpdateHook>();
            oceanCameraProjectionMatModifier.oceanNode = this;

            InitUnderwaterMaterial();

            underwaterProjector = new AtmosphereProjector(underwaterMaterial, m_manager.parentLocalTransform, (float)m_manager.m_radius);
            underwaterProjector.setActivated(false);

            //move this to separate class and make it work on every camera
            //refraction command buffer
            oceanRefractionCommandBuffer      = new CommandBuffer();
            oceanRefractionCommandBuffer.name = "ScattererOceanGrabScreen";
            oceanRefractionCommandBuffer.Blit(BuiltinRenderTextureType.CurrentActive, Scatterer.Instance.bufferManager.refractionTexture);
            Camera farCam;

            farCam = Scatterer.Instance.ReturnProperCamera(true, true);
            if (!(farCam is null))
            {
                //Ok, dual camera mode, register this far camera.
                farCam.AddCommandBuffer(CameraEvent.AfterForwardOpaque, oceanRefractionCommandBuffer);
            }
            //this will register right regardless
            Scatterer.Instance.ReturnProperCamera(false, false).AddCommandBuffer(CameraEvent.AfterForwardOpaque, oceanRefractionCommandBuffer);

            //dimming
            //TODO: maybe this can be changed, instead of complicated hooks on the Camera, add it to the light, like causticsShadowMaskModulate?
            if ((Scatterer.Instance.mainSettings.underwaterLightDimming || Scatterer.Instance.mainSettings.oceanCaustics) && (HighLogic.LoadedScene != GameScenes.MAINMENU))
            {
                underwaterDimmingHook           = (UnderwaterDimmingHook)Scatterer.Instance.scaledSpaceCamera.gameObject.AddComponent(typeof(UnderwaterDimmingHook));
                underwaterDimmingHook.oceanNode = this;
            }

            if (Scatterer.Instance.mainSettings.oceanCaustics && (HighLogic.LoadedScene == GameScenes.FLIGHT))
            {
                causticsShadowMaskModulator = (CausticsShadowMaskModulate)Scatterer.Instance.sunLight.AddComponent(typeof(CausticsShadowMaskModulate));
                if (!causticsShadowMaskModulator.Init(causticsTexturePath, causticsLayer1Scale, causticsLayer1Speed, causticsLayer2Scale, causticsLayer2Speed,
                                                      causticsMultiply, causticsMinBrightness, (float)manager.GetRadius(), causticsBlurDepth))
                {
                    UnityEngine.Object.DestroyImmediate(causticsShadowMaskModulator);
                    causticsShadowMaskModulator = null;
                }
            }
        }
Esempio n. 2
0
        public virtual void Init(ProlandManager manager)
        {
            m_manager = manager;
            loadFromConfigNode();

            InitOceanMaterial();

            //Worth moving to projected Grid Class?
            CreateProjectedGrid();

            oceanCameraProjectionMatModifier           = waterGameObjects[0].AddComponent <OceanCameraUpdateHook>();
            oceanCameraProjectionMatModifier.oceanNode = this;

            waterGameObjects[0].AddComponent <ScreenCopierNotifier>();

            InitUnderwaterMaterial();

            underwaterProjector = new AtmosphereProjector(underwaterMaterial, m_manager.parentLocalTransform, (float)m_manager.m_radius);
            underwaterProjector.setActivated(false);

            //dimming
            //TODO: maybe this can be changed, instead of complicated hooks on the Camera, add it to the light, like causticsShadowMaskModulate?
            if ((Scatterer.Instance.mainSettings.underwaterLightDimming || Scatterer.Instance.mainSettings.oceanCaustics) && (HighLogic.LoadedScene != GameScenes.MAINMENU))
            {
                underwaterDimmingHook           = (UnderwaterDimmingHook)Scatterer.Instance.scaledSpaceCamera.gameObject.AddComponent(typeof(UnderwaterDimmingHook));
                underwaterDimmingHook.oceanNode = this;
            }

            if (Scatterer.Instance.mainSettings.oceanCaustics && (HighLogic.LoadedScene == GameScenes.FLIGHT))
            {
                //why doesn't this work with IVA camera? do they have a separate light?
                causticsShadowMaskModulator = (CausticsShadowMaskModulate)Scatterer.Instance.sunLight.gameObject.AddComponent(typeof(CausticsShadowMaskModulate));
                if (!causticsShadowMaskModulator.Init(causticsTexturePath, causticsLayer1Scale, causticsLayer1Speed, causticsLayer2Scale, causticsLayer2Speed,
                                                      causticsMultiply, causticsMinBrightness, (float)manager.GetRadius(), causticsBlurDepth))
                {
                    UnityEngine.Object.DestroyImmediate(causticsShadowMaskModulator);
                    causticsShadowMaskModulator = null;
                }
            }
        }