Exemplo n.º 1
0
        public static bool TryGet(OceanCameraTask oceanCamera, out OceanVolume result)
        {
            if (activated.Count != 0)
            {
                result = activated[0];
                return(true);
            }

            result = default;
            return(false);
        }
Exemplo n.º 2
0
        protected virtual void CollectUnderOceanInfos(OceanCameraTask oceanCamera, OceanVolume ocean)
        {
            if (oceanCamera.EnableUnderOceanEffect)
            {
                if (ocean.EnableUnderOcean && ocean.UnderOceanData != null)
                {
                    PreparedContents     |= ocean.UnderOceanData.OnPreOceanRender(oceanCamera, ocean);
                    IsHasUnderOceanEffect = true;
                    return;
                }
            }

            UnderOceanModeOptions.DisableUnderOceanEffectAll();
        }
Exemplo n.º 3
0
        public virtual void OnPreOceanRender(OceanCameraTask oceanCamera)
        {
            SunLight = GetSunlight();
            CollectOceanInfos(oceanCamera);

            OceanVolume ocean;

            if (OceanVolume.TryGet(oceanCamera, out ocean))
            {
                Height = ocean.Height;
                Normal = ocean.Normal;
                CollectUnderOceanInfos(oceanCamera, ocean);
            }
            else
            {
                Height = 0;
                Normal = Vector3.up;
                UnderOceanModeOptions.DisableUnderOceanEffectAll();
            }

            Shader.SetGlobalFloat(OceanShaderOptions.TimeShaderID, OceanTime);

            if ((PreparedContents & PreparedContent.SunLight) != 0 && SunLight != null)
            {
                Vector4 pos = SunLight.transform.eulerAngles;
                pos.w = Vector3.Dot(new Vector3(0, -1, 0), SunLight.transform.forward);
                Shader.SetGlobalVector(OceanShaderOptions.SunLightShaderID, pos);
                Shader.SetGlobalColor(OceanShaderOptions.SunLightColorShaderID, SunLight.color);
            }

            if ((PreparedContents & PreparedContent.Ripple) != 0)
            {
                RippleSystem.Current.SetValueToShader(oceanCamera, new CameraTaskRippleData()
                {
                    OceanHeight = Height
                });
            }

            FoamShpereSystem.Current.SetValueToShader(oceanCamera, FoamData, PreparedContents);
            FoamAreaSystem.Current.SetValueToShader(oceanCamera, PreparedContents);
        }
Exemplo n.º 4
0
 public abstract PreparedContent OnPreOceanRender(OceanCameraTask oceanCamera, OceanVolume ocean);
Exemplo n.º 5
0
        public override PreparedContent OnPreOceanRender(OceanCameraTask oceanCamera, OceanVolume ocean)
        {
            Matrix4x4 worldToLightMatrix;

            if (materialData.ModeObject.Mode.Cookie > 0 && oceanCamera.Data.SunLight != null)
            {
                var sunLightTransform = oceanCamera.Data.SunLight.transform;
                worldToLightMatrix = Matrix4x4.TRS(sunLightTransform.position, sunLightTransform.rotation, materialData.Data.Cookie.Scale).inverse;
            }
            else
            {
                worldToLightMatrix = Matrix4x4.identity;
            }
            Shader.SetGlobalMatrix(UnderCookieOptions.WorldToCookieMatrixShaderID, worldToLightMatrix);


            UnderOceanModeOptions.UpdateKeywords(materialData.ModeObject.Mode);
            if (!UnderMaterialOptions.UpdateShaderFields(materialData.Data))
            {
                if (materialData.Data.Cookie.Texture != null)
                {
                    Shader.SetGlobalTexture(UnderCookieOptions.TextureShaderFieldID, materialData.Data.Cookie.Texture.GetCurrentTexture());
                }
            }

            if (ProjectSettings.Current.RenderQueue == OceanRenderQueue.Transparent)
            {
                UnderOceanModeOptions.DisableUnderOceanFogEffect();
            }

            Shader.SetGlobalVector(UnderMaterialOptions.UnderOceanPositionShaderID, new Vector4(0, ocean.Height, 0, 0));

            return(PreparedContent.UnderOceanMarkTexture);
        }