Exemple #1
0
 public void SetValueToShader(OceanCameraTask oceanCamera, FoamCameraData data, PreparedContent preparedContent)
 {
     if (ProjectSettings.Current.Foam.EnabledFoamShpereCulling)
     {
         if ((preparedContent & PreparedContent.Foam16) != 0)
         {
             SetValueToShader(oceanCamera, data, 16, 4);
         }
         else if ((preparedContent & PreparedContent.Foam8) != 0)
         {
             SetValueToShader(oceanCamera, data, 8, 2);
         }
     }
 }
Exemple #2
0
        public void OnPreOceanCull(FoamCameraData data)
        {
            data.CullingGroup.enabled = ProjectSettings.Current.Foam.EnabledFoamShpereCulling;

            int boundingSphereCount = 0;

            for (int index = 0; index < foamObservers.Count; index++)
            {
                var observer = foamObservers[index];
                if (Physics.CheckSphere(observer.Position, observer.Radius, ProjectSettings.Current.OceanCullingMask, QueryTriggerInteraction.UseGlobal))
                {
                    BoundingSpheres[boundingSphereCount]  = new BoundingSphere(observer.Position, observer.Radius);
                    effectiveShperes[boundingSphereCount] = observer;
                    boundingSphereCount++;
                }
            }

            data.CullingGroup.SetBoundingSphereCount(boundingSphereCount);
        }
Exemple #3
0
        public void SetValueToShader(OceanCameraTask oceanCamera, FoamCameraData data, int count, int countQuarter)
        {
            int visibleCount = data.CullingGroup.QueryIndices(true, cullingGroupResult, 0);

            if (visibleCount == 0)
            {
                ClearArray(data0);
                ClearArray(data1);
            }
            else if (visibleCount <= count)
            {
                int index;
                for (index = 0; index < visibleCount; index++)
                {
                    int         observerIndex = cullingGroupResult[index];
                    IFoamShpere observer      = effectiveShperes[observerIndex];
                    data0[index] = VectorHelper.Create(observer.Position, observer.Radius);
                }
                for (; index < count; index++)
                {
                    data0[index] = default(Vector4);
                }

                for (index = 0; index < countQuarter; index++)
                {
                    Vector4 value = Vector4.zero;
                    for (int j = 0, newIndex = index * 4; newIndex < visibleCount && j < 4; j++, newIndex++)
                    {
                        int         observerIndex = cullingGroupResult[newIndex];
                        IFoamShpere observer      = effectiveShperes[observerIndex];
                        value[j] = observer.Intensity;
                    }
                    data1[index] = value;
                }
            }
            else
            {
                int index;
                for (index = 0; index < visibleCount; index++)
                {
                    int         observerIndex = cullingGroupResult[index];
                    IFoamShpere observer      = effectiveShperes[observerIndex];
                    sortedArray.Add(new ComparableItem(observer, oceanCamera.transform.position));
                }

                for (index = 0; index < Mathf.Min(visibleCount, count); index++)
                {
                    IFoamShpere observer = sortedArray[index].Foam;
                    data0[index] = VectorHelper.Create(observer.Position, observer.Radius);
                }
                for (; index < count; index++)
                {
                    data0[index] = default(Vector4);
                }

                for (index = 0; index < countQuarter; index++)
                {
                    Vector4 value = Vector4.zero;
                    for (int j = 0, newIndex = index * 4; newIndex < visibleCount && j < 4; j++, newIndex++)
                    {
                        IFoamShpere observer = sortedArray[newIndex].Foam;
                        value[j] = observer.Intensity;
                    }
                    data1[index] = value;
                }

                sortedArray.Clear();
            }

            Shader.SetGlobalVectorArray(FoamOptions.ShpereData0Name, data0);
            Shader.SetGlobalVectorArray(FoamOptions.ShpereData1Name, data1);
        }
Exemple #4
0
 public CameraTaskController(OceanCameraTask oceanCamera)
 {
     FoamData = new FoamCameraData(oceanCamera.ThisCamera);
 }