Beispiel #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;
                }
            }
        }
Beispiel #2
0
        public override void Init(ProlandManager manager)
        {
            base.Init(manager);

            m_initJacobiansMat       = new Material(ShaderReplacer.Instance.LoadedShaders[("Proland/Ocean/InitJacobians")]);
            m_whiteCapsPrecomputeMat = new Material(ShaderReplacer.Instance.LoadedShaders[("Proland/Ocean/WhiteCapsPrecompute0")]);

            m_initJacobiansMat.SetTexture(ShaderProperties._Spectrum01_PROPERTY, m_spectrum01);
            m_initJacobiansMat.SetTexture(ShaderProperties._Spectrum23_PROPERTY, m_spectrum23);
            m_initJacobiansMat.SetTexture(ShaderProperties._WTable_PROPERTY, m_WTable);
            m_initJacobiansMat.SetVector(ShaderProperties._Offset_PROPERTY, m_offset);
            m_initJacobiansMat.SetVector(ShaderProperties._InverseGridSizes_PROPERTY, m_inverseGridSizes);
        }
Beispiel #3
0
        public override void Init(ProlandManager manager)
        {
            base.Init(manager);

            m_initSpectrumMat     = new Material(ShaderReplacer.Instance.LoadedShaders[("Proland/Ocean/InitSpectrum")]);
            m_initDisplacementMat = new Material(ShaderReplacer.Instance.LoadedShaders[("Proland/Ocean/InitDisplacement")]);

            m_fourierGridSize = Scatterer.Instance.mainSettings.m_fourierGridSize;

            if (m_fourierGridSize > 256)
            {
                Utils.LogDebug("Proland::OceanFFT::Start	- fourier grid size must not be greater than 256, changing to 256");
                m_fourierGridSize = 256;
            }

            if (!Mathf.IsPowerOfTwo(m_fourierGridSize))
            {
                Utils.LogDebug("Proland::OceanFFT::Start	- fourier grid size must be pow2 number, changing to nearest pow2 number");
                m_fourierGridSize = Mathf.NextPowerOfTwo(m_fourierGridSize);
            }

            m_fsize  = (float)m_fourierGridSize;
            m_offset = new Vector4(1.0f + 0.5f / m_fsize, 1.0f + 0.5f / m_fsize, 0, 0);


            float factor = 2.0f * Mathf.PI * m_fsize;

            m_inverseGridSizes = new Vector4(factor / m_gridSizes.x, factor / m_gridSizes.y, factor / m_gridSizes.z, factor / m_gridSizes.w);


            m_fourier = new FourierGPU(m_fourierGridSize);

            m_writeFloat = new WriteFloat(m_fourierGridSize, m_fourierGridSize);

            //Create the data needed to make the waves each frame
            CreateRenderTextures();
            GenerateWavesSpectrum();
            CreateWTable();

            m_initSpectrumMat.SetTexture(ShaderProperties._Spectrum01_PROPERTY, m_spectrum01);
            m_initSpectrumMat.SetTexture(ShaderProperties._Spectrum23_PROPERTY, m_spectrum23);
            m_initSpectrumMat.SetTexture(ShaderProperties._WTable_PROPERTY, m_WTable);
            m_initSpectrumMat.SetVector(ShaderProperties._Offset_PROPERTY, m_offset);
            m_initSpectrumMat.SetVector(ShaderProperties._InverseGridSizes_PROPERTY, m_inverseGridSizes);

            m_initDisplacementMat.SetVector(ShaderProperties._InverseGridSizes_PROPERTY, m_inverseGridSizes);
        }
Beispiel #4
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;
                }
            }
        }