예제 #1
0
        void Awake()
        {
            if (!VerifyRequirements())
            {
                enabled = false;
                return;
            }

#if UNITY_EDITOR
            if (_verifySRPVersionInEditor)
            {
                // Fire off a request to get the LWRP version, as early versions are not compatible
                _request = Client.List(true, false);
            }
#endif

            Instance = this;
            Scale    = Mathf.Clamp(Scale, _minScale, _maxScale);

            OceanBuilder.GenerateMesh(this, _lodDataResolution, _geometryDownSampleFactor, _lodCount);

            if (null == GetComponent <BuildCommandBufferBase>())
            {
                gameObject.AddComponent <BuildCommandBuffer>();
            }

            InitViewpoint();
            InitTimeProvider();
        }
예제 #2
0
        void Awake()
        {
            if (!VerifyRequirements())
            {
                enabled = false;
                return;
            }

            Instance = this;
            Scale    = Mathf.Clamp(Scale, _minScale, _maxScale);

            OceanBuilder.GenerateMesh(this, _lodDataResolution, _geometryDownSampleFactor, _lodCount);

            if (null == GetComponent <BuildCommandBufferBase>())
            {
                gameObject.AddComponent <BuildCommandBuffer>();
            }

            InitViewpoint();
            InitTimeProvider();

            if (_attachDebugGUI && GetComponent <OceanDebugGUI>() == null)
            {
                gameObject.AddComponent <OceanDebugGUI>();
            }
        }
예제 #3
0
        void Start()
        {
            _instance = this;

            _oceanBuilder = FindObjectOfType <OceanBuilder>();
            _oceanBuilder.GenerateMesh(MakeBuildParams());
        }
        void Awake()
        {
            if (_material == null)
            {
                Debug.LogError("A material for the ocean must be assigned on the Material property of the OceanRenderer.", this);
                enabled = false;
                return;
            }

            _instance = this;

            OceanBuilder.GenerateMesh(this, _baseVertDensity, _lodCount);

            // set render orders, event hooks, etc
            var scheduler = GetComponent <IOceanScheduler>();

            if (scheduler == null)
            {
                scheduler = gameObject.AddComponent <OceanScheduler>();
            }
            scheduler.ApplySchedule(this);

            InitViewpoint();
            InitTimeProvider();
        }
예제 #5
0
        void Start()
        {
            _instance = this;

            _oceanBuilder = GetComponent <OceanBuilder>();
            _oceanBuilder.GenerateMesh(MakeBuildParams());

            SetSmoothLODsShaderParam();
        }
        void Start()
        {
            _instance = this;

            _oceanBuilder = FindObjectOfType <OceanBuilder>();
            _oceanBuilder.GenerateMesh(_baseVertDensity, _lodCount);

            if (_viewpoint == null)
            {
                _viewpoint = Camera.main.transform;
            }
        }
예제 #7
0
        void Start()
        {
            _instance = this;

            OceanBuilder.GenerateMesh(this, _baseVertDensity, _lodCount);

            // set render orders, event hooks, etc
            var scheduler = GetComponent <IOceanScheduler>();

            if (scheduler == null)
            {
                scheduler = gameObject.AddComponent <OceanScheduler>();
            }
            scheduler.ApplySchedule(this);

            InitViewpoint();
        }
예제 #8
0
        public virtual void ApplySchedule(OceanBuilder ocean)
        {
            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // --- Dynamic waves camera renders first
            for (int i = 0; i < ocean.CurrentLodCount && ocean._camsDynWaves[i] != null; i++)
            {
                ocean._camsDynWaves[i].depth = -40 - i;
            }


            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // --- Animated waves next
            for (int i = 0; i < ocean.CurrentLodCount; i++)
            {
                ocean._camsAnimWaves[i].depth = -30 - i;

                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // --- Copy dynamic waves into animated waves (convert to displacements in the process)
                if (ocean._camsDynWaves[i] != null)
                {
                    ocean._camsDynWaves[i].GetComponent <LodDataDynamicWaves>().HookCombinePass(ocean._camsAnimWaves[i], CameraEvent.AfterForwardAlpha);
                }
            }


            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // --- Do combine passes to carry long wavelengths/low detail up the chain into the high detail lods
            ocean._lodDataAnimWaves[0].HookCombinePass(ocean._camsAnimWaves[0], CameraEvent.AfterEverything);


            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // --- Foam takes the final combined waves as input and generates foam
            for (int i = 0; i < ocean.CurrentLodCount && ocean._camsFoam[i] != null; i++)
            {
                ocean._camsFoam[i].depth = -20 - i;
            }


            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // --- User cameras render the ocean surface at depth ~0 - above data should be ready to go!


            // warn if main camera scheduled early
            CheckMainCameraDepth();
        }
예제 #9
0
        void Start()
        {
            _instance = this;

            _oceanBuilder = FindObjectOfType <OceanBuilder>();
            _oceanBuilder.GenerateMesh(_baseVertDensity, _lodCount);

            _collProvider = new CollProviderDispTexs();
            if (_cachedCpuOceanQueries)
            {
                _collProvider = new CollProviderCache(_collProvider);
            }

            if (_viewpoint == null)
            {
                _viewpoint = Camera.main.transform;
            }
        }
예제 #10
0
        void Awake()
        {
            if (!VerifyRequirements())
            {
                enabled = false;
                return;
            }

            Instance = this;

            OceanBuilder.GenerateMesh(this, _lodDataResolution, _geometryDownSampleFactor, _lodCount);

            if (null == GetComponent <BuildCommandBufferBase>())
            {
                gameObject.AddComponent <BuildCommandBuffer>();
            }

            InitViewpoint();
            InitTimeProvider();
        }
예제 #11
0
        void Awake()
        {
            if (_material == null)
            {
                Debug.LogError("A material for the ocean must be assigned on the Material property of the OceanRenderer.", this);
                enabled = false;
                return;
            }

            Instance = this;

            OceanBuilder.GenerateMesh(this, _lodDataResolution, _geometryDownSampleFactor, _lodCount);

            if (null == GetComponent <BuildCommandBufferBase>())
            {
                gameObject.AddComponent <BuildCommandBuffer>();
            }

            InitViewpoint();
            InitTimeProvider();
        }
예제 #12
0
        void Awake()
        {
            if (!_primaryLight && _searchForPrimaryLightOnStartup)
            {
                _primaryLight = RenderSettings.sun;
            }

            if (!VerifyRequirements())
            {
                enabled = false;
                return;
            }

            Instance = this;
            Scale    = Mathf.Clamp(Scale, _minScale, _maxScale);

            // Resolution is 4 tiles across.
            var baseMeshDensity = _lodDataResolution * 0.25f / _geometryDownSampleFactor;

            // 0.4f is the "best" value when base mesh density is 8. Scaling down from there produces results similar to
            // hand crafted values which looked good when the ocean is flat.
            _lodAlphaBlackPointFade = 0.4f / (baseMeshDensity / 8f);
            // We could calculate this in the shader, but we can save two subtractions this way.
            _lodAlphaBlackPointWhitePointFade = 1f - _lodAlphaBlackPointFade - _lodAlphaBlackPointFade;

            OceanBuilder.GenerateMesh(this, _lodDataResolution, _geometryDownSampleFactor, _lodCount);

            if (null == GetComponent <BuildCommandBufferBase>())
            {
                gameObject.AddComponent <BuildCommandBuffer>();
            }

            InitViewpoint();
            InitTimeProvider();

            if (_attachDebugGUI && GetComponent <OceanDebugGUI>() == null)
            {
                gameObject.AddComponent <OceanDebugGUI>();
            }
        }
예제 #13
0
 void RegenMesh()
 {
     OceanBuilder.GenerateMesh(this, _baseVertDensity, _lodCount);
 }
예제 #14
0
        // Drive state from OnEnable and OnDisable? OnEnable on RegisterLodDataInput seems to get called on script reload
        void OnEnable()
        {
            // We don't run in "prefab scenes", i.e. when editing a prefab. Bail out if prefab scene is detected.
#if UNITY_EDITOR
            if (PrefabStageUtility.GetCurrentPrefabStage() != null)
            {
                return;
            }
#endif

            if (!_primaryLight && _searchForPrimaryLightOnStartup)
            {
                _primaryLight = RenderSettings.sun;
            }

            if (!VerifyRequirements())
            {
                enabled = false;
                return;
            }

#if UNITY_EDITOR
            if (EditorApplication.isPlaying && !Validate(this, ValidatedHelper.DebugLog))
            {
                enabled = false;
                return;
            }
#endif

            _isFirstUpdate = true;

            Instance = this;
            Scale    = Mathf.Clamp(Scale, _minScale, _maxScale);

            _lodTransform = new LodTransform();
            _lodTransform.InitLODData(_lodCount);

            // Resolution is 4 tiles across.
            var baseMeshDensity = _lodDataResolution * 0.25f / _geometryDownSampleFactor;
            // 0.4f is the "best" value when base mesh density is 8. Scaling down from there produces results similar to
            // hand crafted values which looked good when the ocean is flat.
            _lodAlphaBlackPointFade = 0.4f / (baseMeshDensity / 8f);
            // We could calculate this in the shader, but we can save two subtractions this way.
            _lodAlphaBlackPointWhitePointFade = 1f - _lodAlphaBlackPointFade - _lodAlphaBlackPointFade;

            Root = OceanBuilder.GenerateMesh(this, _oceanChunkRenderers, _lodDataResolution, _geometryDownSampleFactor, _lodCount);

            CreateDestroySubSystems();

            _commandbufferBuilder = new BuildCommandBuffer();

            InitViewpoint();

            if (_attachDebugGUI && GetComponent <OceanDebugGUI>() == null)
            {
                gameObject.AddComponent <OceanDebugGUI>().hideFlags = HideFlags.DontSave;
            }

#if UNITY_EDITOR
            EditorApplication.update -= EditorUpdate;
            EditorApplication.update += EditorUpdate;
#endif
            foreach (var lodData in _lodDatas)
            {
                lodData.OnEnable();
            }

            _canSkipCulling = false;
        }
예제 #15
0
 void RegenMesh()
 {
     OceanBuilder.GenerateMesh(this, _lodDataResolution, _geometryDownSampleFactor, _lodCount);
 }