Esempio n. 1
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>();
            }
        }
Esempio n. 2
0
        void Start()
        {
            _instance = this;

            _oceanBuilder = FindObjectOfType <OceanBuilder>();
            _oceanBuilder.GenerateMesh(MakeBuildParams());
        }
Esempio n. 3
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();
        }
        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();
        }
Esempio n. 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;
            }
        }
Esempio n. 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();
        }
        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;
            }
        }
Esempio n. 9
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();
        }
Esempio n. 10
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();
        }
Esempio n. 11
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>();
            }
        }
Esempio n. 12
0
 void RegenMesh()
 {
     OceanBuilder.GenerateMesh(this, _baseVertDensity, _lodCount);
 }
Esempio n. 13
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;
        }
Esempio n. 14
0
 public void RegenMesh()
 {
     _oceanBuilder.GenerateMesh(MakeBuildParams());
 }
 void RegenMesh()
 {
     OceanBuilder.GenerateMesh(this, _lodDataResolution, _geometryDownSampleFactor, _lodCount);
 }
 public void RegenMesh()
 {
     _oceanBuilder.GenerateMesh(_baseVertDensity, _lodCount);
 }