public virtual void InitUniforms(MaterialPropertyBlock target) { if (target == null) { return; } if (Atmosphere != null) { Atmosphere.InitUniforms(target); } }
public void Reanimate() { //NOTE : So, when unity recompiles shaders or scripts from editor while playing - quads not draws properly. //NOTE : Fixed. Buffers setted 1 time. Need to update when focus losted. //NOTE : Reinit [Reanimate] ocean stuff only after focus lost... if (Quads != null) { if (Quads.Count != 0) { for (int i = 0; i < Quads.Count; i++) { Quads[i].Uniformed = false; if (Atmosphere != null) { Atmosphere.InitUniforms(Quads[i].QuadMaterial); Atmosphere.SetUniforms(Quads[i].QuadMaterial); } } } } if (Ocean != null) { Ocean.Reanimate(); } if (Atmosphere != null) { Atmosphere.Reanimate(); } }
public void SetupMainQuad(QuadPosition quadPosition) { GameObject go = new GameObject(string.Format("Quad_{0}", quadPosition)); go.transform.parent = QuadsRoot.transform; go.transform.position = Vector3.zero; go.transform.rotation = Quaternion.identity; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; Mesh mesh = GetMesh(quadPosition); mesh.bounds = new Bounds(Vector3.zero, new Vector3(PlanetRadius * 2, PlanetRadius * 2, PlanetRadius * 2)); Material material = MaterialHelper.CreateTemp(ColorShader, "Quad"); Quad quadComponent = go.AddComponent <Quad>(); quadComponent.Planetoid = this; quadComponent.QuadMesh = mesh; quadComponent.QuadMaterial = material; if (Atmosphere != null) { Atmosphere.InitUniforms(null, quadComponent.QuadMaterial, false); } QuadGenerationConstants gc = QuadGenerationConstants.Init(TerrainMaxHeight); gc.planetRadius = PlanetRadius; gc.cubeFaceEastDirection = quadComponent.GetCubeFaceEastDirection(quadPosition); gc.cubeFaceNorthDirection = quadComponent.GetCubeFaceNorthDirection(quadPosition); gc.patchCubeCenter = quadComponent.GetPatchCubeCenter(quadPosition); quadComponent.Position = quadPosition; quadComponent.ID = QuadID.One; quadComponent.generationConstants = gc; quadComponent.SetupCorners(quadPosition); quadComponent.ShouldDraw = true; quadComponent.ReadyForDispatch = true; Quads.Add(quadComponent); MainQuads.Add(quadComponent); }
public Quad SetupSubQuad(QuadPosition quadPosition) { GameObject go = new GameObject(string.Format("Quad_{0}", quadPosition)); Mesh mesh = GetMesh(quadPosition); mesh.bounds = new Bounds(Vector3.zero, new Vector3(PlanetRadius * 2, PlanetRadius * 2, PlanetRadius * 2)); Material material = MaterialHelper.CreateTemp(ColorShader, "Quad"); Quad quadComponent = go.AddComponent <Quad>(); quadComponent.Planetoid = this; quadComponent.QuadMesh = mesh; quadComponent.QuadMaterial = material; quadComponent.SetupCorners(quadPosition); if (Atmosphere != null) { Atmosphere.InitUniforms(null, quadComponent.QuadMaterial, false); } QuadGenerationConstants gc = QuadGenerationConstants.Init(TerrainMaxHeight); gc.planetRadius = PlanetRadius; quadComponent.Position = quadPosition; quadComponent.generationConstants = gc; quadComponent.ShouldDraw = false; if (qdtccc == null) { qdtccc = new QuadDistanceToClosestCornerComparer(); } Quads.Add(quadComponent); Quads.Sort(qdtccc); return(quadComponent); }
public void InitUniforms(Material target) { if (target == null) { return; } target.SetTexture("sunSpikes", Settings.SunSpikes); target.SetTexture("sunFlare", Settings.SunFlare); target.SetTexture("sunGhost1", Settings.SunGhost1); target.SetTexture("sunGhost2", Settings.SunGhost2); target.SetTexture("sunGhost3", Settings.SunGhost3); target.SetVector("flareSettings", Settings.FlareSettings); target.SetVector("spikesSettings", Settings.SpikesSettings); target.SetMatrix("ghost1Settings", Ghost1Settings); target.SetMatrix("ghost2Settings", Ghost2Settings); target.SetMatrix("ghost3Settings", Ghost2Settings); if (Atmosphere != null) { Atmosphere.InitUniforms(target); } }
public void InitUniforms(Material mat) { if (mat == null) { return; } SunGlareMaterial.SetTexture("sunSpikes", SunSpikes); SunGlareMaterial.SetTexture("sunFlare", SunFlare); SunGlareMaterial.SetTexture("sunGhost1", SunGhost1); SunGlareMaterial.SetTexture("sunGhost2", SunGhost2); SunGlareMaterial.SetTexture("sunGhost3", SunGhost3); SunGlareMaterial.SetVector("flareSettings", FlareSettings); SunGlareMaterial.SetVector("spikesSettings", SpikesSettings); SunGlareMaterial.SetMatrix("ghost1Settings", Ghost1Settings); SunGlareMaterial.SetMatrix("ghost2Settings", Ghost2Settings); SunGlareMaterial.SetMatrix("ghost3Settings", Ghost2Settings); if (Atmosphere != null) { Atmosphere.InitUniforms(null, SunGlareMaterial, false); } }