protected virtual void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial(SgtHelper.ShaderNamePrefix + "Ring"); } var color = SgtHelper.Brighten(Color, Brightness); var renderQueue = (int)RenderQueue + RenderQueueOffset; var lightCount = SgtHelper.WriteLights(Lights, 2, transform.position, null, null, material); var shadowCount = SgtHelper.WriteShadows(Shadows, 2, material); material.renderQueue = renderQueue; material.SetTexture("_MainTex", MainTex); material.SetColor("_Color", color); material.SetFloat("_LightingBias", LightingBias); material.SetFloat("_LightingSharpness", LightingSharpness); if (Scattering == true) { keywords.Add("SGT_A"); SgtHelper.WriteMie(MieSharpness, MieStrength, material); } SgtHelper.WriteLightKeywords(Lights.Count > 0, lightCount, keywords); SgtHelper.WriteShadowKeywords(shadowCount, keywords); SgtHelper.SetKeywords(material, keywords); keywords.Clear(); }
public static void CalculateLight(Light light, Vector3 center, Transform directionTransform, Transform positionTransform, ref Vector3 position, ref Vector3 direction, ref Color color) { if (light != null) { direction = -light.transform.forward; position = light.transform.position; color = SgtHelper.Brighten(light.color, light.intensity); switch (light.type) { case LightType.Point: direction = Vector3.Normalize(position - center); break; case LightType.Directional: position = center + direction * 10000.0f; break; } // Transform into local space? if (directionTransform != null) { direction = directionTransform.InverseTransformDirection(direction); } if (positionTransform != null) { position = positionTransform.InverseTransformPoint(position); } } }
private void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial(SgtHelper.ShaderNamePrefix + "Prominence"); } var color = SgtHelper.Premultiply(SgtHelper.Brighten(Color, Brightness)); var renderQueue = (int)RenderQueue + RenderQueueOffset; material.renderQueue = renderQueue; material.SetTexture("_MainTex", MainTex); material.SetColor("_Color", color); material.SetVector("_WorldPosition", transform.position); if (FadeEdge == true) { keywords.Add("SGT_A"); material.SetFloat("_FadePower", FadePower); } if (ClipNear == true) { keywords.Add("SGT_B"); material.SetFloat("_ClipPower", ClipPower); } SgtHelper.SetKeywords(material, keywords); keywords.Clear(); }
protected virtual void UpdateMaterial() { if (innerMaterial == null) { innerMaterial = SgtHelper.CreateTempMaterial(SgtHelper.ShaderNamePrefix + "CoronaInner"); } if (outerMaterial == null) { outerMaterial = SgtHelper.CreateTempMaterial(SgtHelper.ShaderNamePrefix + "CoronaOuter"); } var scale = SgtHelper.Divide(OuterMeshRadius, OuterRadius); var worldToLocal = SgtHelper.Scaling(scale) * transform.worldToLocalMatrix; var color = SgtHelper.Brighten(Color, Brightness); var renderQueue = (int)RenderQueue + RenderQueueOffset; innerMaterial.renderQueue = renderQueue; innerMaterial.SetColor("_Color", color); innerMaterial.SetTexture("_AtmosphereLut", atmosphereLut); innerMaterial.SetFloat("_AtmosphereScale", DensityScale); innerMaterial.SetFloat("_Power", InnerPower); innerMaterial.SetFloat("_SkyRadius", OuterRadius); innerMaterial.SetFloat("_SkyRadiusRecip", SgtHelper.Reciprocal(OuterRadius)); innerMaterial.SetMatrix("_WorldToLocal", worldToLocal); outerMaterial.renderQueue = renderQueue; outerMaterial.SetColor("_Color", color); outerMaterial.SetTexture("_AtmosphereLut", atmosphereLut); outerMaterial.SetFloat("_AtmosphereScale", DensityScale); outerMaterial.SetMatrix("_WorldToLocal", worldToLocal); }
private void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial(SgtHelper.ShaderNamePrefix + "Cloudsphere"); } var color = SgtHelper.Brighten(Color, Brightness); var renderQueue = (int)RenderQueue + RenderQueueOffset; if (FadeNear == true) { keywords.Add("SGT_A"); material.SetFloat("_FadeRadius", FadeInnerRadius); material.SetFloat("_FadeScale", SgtHelper.Reciprocal(FadeOuterRadius - FadeInnerRadius)); } material.renderQueue = renderQueue; material.SetTexture("_MainTex", MainTex); material.SetColor("_Color", color); material.SetTexture("_RimLut", rimLut); material.SetTexture("_LightingLut", lightingLut); var lightCount = SgtHelper.WriteLights(Lights, 2, transform.position, null, null, material); var shadowCount = SgtHelper.WriteShadows(Shadows, 2, material); SgtHelper.WriteLightKeywords(Lights.Count > 0, lightCount, keywords); SgtHelper.WriteShadowKeywords(shadowCount, keywords); SgtHelper.SetKeywords(material, keywords); keywords.Clear(); }
private void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial(SgtHelper.ShaderNamePrefix + "Singularity"); } var color = SgtHelper.Brighten(Color, Brightness); var renderQueue = (int)RenderQueue + RenderQueueOffset; material.renderQueue = renderQueue; material.SetColor("_Color", color); material.SetVector("_Center", SgtHelper.NewVector4(transform.position, 1.0f)); material.SetFloat("_Power", Power); material.SetFloat("_EdgePower", EdgePower); if (Hole == true) { keywords.Add("SGT_A"); material.SetFloat("_HoleSize", HoleSize); material.SetFloat("_HolePower", HolePower); } SgtHelper.SetKeywords(material, keywords); keywords.Clear(); }
protected virtual void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial(SgtHelper.ShaderNamePrefix + "Spacetime"); } var color = SgtHelper.Brighten(Color, Brightness); var renderQueue = (int)RenderQueue + RenderQueueOffset; var wellCount = WriteWells(12); // 12 is the shader instruction limit material.renderQueue = renderQueue; material.SetTexture("_MainTex", MainTex); material.SetColor("_Color", color); material.SetFloat("_Node", Node); switch (Effect) { case SgtSpacetimeEffect.Pinch: { material.SetFloat("_Power", Power); } break; case SgtSpacetimeEffect.Offset: { keywords.Add("SGT_A"); material.SetVector("_Offset", Offset); } break; } if (Accumulate == true) { keywords.Add("SGT_B"); } if ((wellCount & 1 << 0) != 0) { keywords.Add("SGT_C"); } if ((wellCount & 1 << 1) != 0) { keywords.Add("SGT_D"); } if ((wellCount & 1 << 2) != 0) { keywords.Add("SGT_E"); } if ((wellCount & 1 << 3) != 0) { keywords.Add("LIGHT_0"); } SgtHelper.SetKeywords(material, keywords); keywords.Clear(); }
public void UpdateMaterial() { updateMaterialCalled = true; if (Material == null) { Material = SgtHelper.CreateTempMaterial("Prominence (Generated)", SgtHelper.ShaderNamePrefix + "Prominence"); if (Planes != null) { for (var i = Planes.Count - 1; i >= 0; i--) { var plane = Planes[i]; if (plane != null) { plane.SetMaterial(Material); } } } } var color = SgtHelper.Premultiply(SgtHelper.Brighten(Color, Brightness)); var renderQueue = (int)RenderQueue + RenderQueueOffset; if (Material.renderQueue != renderQueue) { Material.renderQueue = renderQueue; } Material.SetTexture("_MainTex", MainTex); Material.SetColor("_Color", color); Material.SetVector("_WorldPosition", transform.position); SgtHelper.SetTempMaterial(Material); if (FadeEdge == true) { SgtHelper.EnableKeyword("SGT_A"); Material.SetFloat("_FadePower", FadePower); } else { SgtHelper.DisableKeyword("SGT_A"); } if (ClipNear == true) { SgtHelper.EnableKeyword("SGT_B"); Material.SetFloat("_ClipPower", ClipPower); } else { SgtHelper.DisableKeyword("SGT_B"); } }
protected virtual void BuildMaterial() { Material.renderQueue = (int)RenderQueue + RenderQueueOffset; Material.SetTexture("_MainTex", MainTex); Material.SetColor("_Color", SgtHelper.Brighten(Color, Color.a * Brightness)); Material.SetFloat("_Scale", transform.lossyScale.x); Material.SetFloat("_ScaleRecip", SgtHelper.Reciprocal(transform.lossyScale.x)); }
protected virtual void LateUpdate() { // The lights and shadows may have moved, so write them if (Material != null) { SgtHelper.SetTempMaterial(Material); SgtHelper.WriteLights(Lit, Lights, 2, transform.position, null, null, SgtHelper.Brighten(Color, Brightness), 1.0f); SgtHelper.WriteShadows(Shadows, 2); } }
public void UpdateMaterial() { if (Material == null) { Material = SgtHelper.CreateTempMaterial("Skysphere (Generated)", SgtHelper.ShaderNamePrefix + "Skysphere"); } Material.renderQueue = (int)RenderQueue + RenderQueueOffset; Material.SetTexture("_MainTex", MainTex); Material.SetColor("_Color", SgtHelper.Brighten(Color, Brightness)); }
protected abstract void CalculateStars(out List <SgtStarfieldStar> stars, out bool pool); // pool == true when they are temporary protected virtual void UpdateGroupMaterial(SgtStarfieldGroup group) { var color = SgtHelper.Brighten(Color, Color.a * Brightness); var scale = transform.lossyScale.x; var renderQueue = (int)RenderQueue + RenderQueueOffset; if (group.Material == null) { group.Material = SgtHelper.CreateTempMaterial(SgtHelper.ShaderNamePrefix + "Starfield"); } group.Material.renderQueue = renderQueue; group.Material.SetTexture("_Texture", group.Texture); group.Material.SetColor("_Color", color); group.Material.SetFloat("_Scale", scale); if (AllowPulse == true) { keywords.Add("LIGHT_1"); group.Material.SetFloat("_Age", Age); } if (Softness > 0.0f) { keywords.Add("LIGHT_2"); group.Material.SetFloat("_InvFade", SgtHelper.Reciprocal(Softness)); } if (StretchToObservers == true) { keywords.Add("SGT_C"); } if (FadeNear == true) { keywords.Add("SGT_D"); group.Material.SetFloat("_FadeNearRadius", FadeNearRadius); group.Material.SetFloat("_FadeNearScale", SgtHelper.Reciprocal(FadeNearThickness)); } if (FadeFar == true) { keywords.Add("SGT_E"); group.Material.SetFloat("_FadeFarRadius", FadeFarRadius); group.Material.SetFloat("_FadeFarScale", SgtHelper.Reciprocal(FadeFarThickness)); } }
public void UpdateMaterial() { updateMaterialCalled = true; if (Material == null) { Material = SgtHelper.CreateTempMaterial("Spacetime (Generated)", SgtHelper.ShaderNamePrefix + "Spacetime"); ApplyMaterial(); } var ambientColor = SgtHelper.Brighten(AmbientColor, AmbientBrightness); var displacementColor = SgtHelper.Brighten(DisplacementColor, DisplacementBrightness); var higlightColor = SgtHelper.Brighten(HighlightColor, HighlightBrightness); Material.renderQueue = (int)RenderQueue + RenderQueueOffset; Material.SetTexture("_MainTex", MainTex); Material.SetColor("_Color", SgtHelper.Brighten(Color, Brightness)); Material.SetColor("_AmbientColor", ambientColor); Material.SetColor("_DisplacementColor", displacementColor); Material.SetColor("_HighlightColor", higlightColor); Material.SetFloat("_HighlightPower", HighlightPower); Material.SetFloat("_HighlightScale", HighlightScale); Material.SetFloat("_Tile", Tile); if (Displacement == DisplacementType.Pinch) { Material.SetFloat("_Power", Power); } if (Displacement == DisplacementType.Offset) { SgtHelper.EnableKeyword("SGT_A", Material); Material.SetVector("_Offset", Offset); } else { SgtHelper.DisableKeyword("SGT_A", Material); } if (Accumulate == true) { SgtHelper.EnableKeyword("SGT_B", Material); } else { SgtHelper.DisableKeyword("SGT_B", Material); } }
private void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial(SgtHelper.ShaderNamePrefix + "Skysphere"); } var color = SgtHelper.Brighten(Color, Brightness); var renderQueue = (int)RenderQueue + RenderQueueOffset; material.renderQueue = renderQueue; material.SetTexture("_MainTex", MainTex); material.SetColor("_Color", color); }
protected override void CameraPreCull(Camera camera) { base.CameraPreCull(camera); // Change brightness based on viewing angle? if (Material != null) { var dir = (transform.position - camera.transform.position).normalized; var theta = Mathf.Abs(Vector3.Dot(transform.up, dir)); var bright = Mathf.Lerp(HorizontalBrightness, Brightness, Mathf.Pow(theta, HorizontalPower)); var color = SgtHelper.Brighten(Color, Color.a * bright); Material.SetColor("_Color", color); } }
public void UpdateMaterial() { updateMaterialCalled = true; if (Material == null) { Material = SgtHelper.CreateTempMaterial("Cloudsphere (Generated)", SgtHelper.ShaderNamePrefix + "Cloudsphere"); if (Models != null) { for (var i = Models.Count - 1; i >= 0; i--) { var model = Models[i]; if (model != null) { model.SetMaterial(Material); } } } } var renderQueue = (int)RenderQueue + RenderQueueOffset; var color = SgtHelper.Brighten(Color, Brightness); Material.renderQueue = renderQueue; Material.SetColor("_Color", color); Material.SetTexture("_MainTex", MainTex); Material.SetTexture("_DepthTex", DepthTex); if (Fade == true) { SgtHelper.EnableKeyword("SGT_A", Material); // Fade Material.SetTexture("_FadeTex", FadeTex); Material.SetFloat("_FadeDistanceRecip", SgtHelper.Reciprocal(FadeDistance)); } else { SgtHelper.DisableKeyword("SGT_A", Material); // Fade } if (Lit == true) { Material.SetTexture("_LightingTex", LightingTex); } }
public void UpdateMaterial() { if (Material == null) { Material = SgtHelper.CreateTempMaterial("Jovian Material (Generated)", SgtHelper.ShaderNamePrefix + "Jovian"); if (Models != null) { for (var i = Models.Count - 1; i >= 0; i--) { var model = Models[i]; if (model != null) { model.SetMaterial(Material); } } } } Material.renderQueue = (int)RenderQueue + RenderQueueOffset; Material.SetTexture("_MainTex", MainTex); Material.SetTexture("_DepthTex", DepthTex); Material.SetColor("_Color", SgtHelper.Brighten(Color, Brightness)); if (Lit == true) { Material.SetTexture("_LightingTex", LightingTex); } SgtHelper.SetTempMaterial(Material); if (Scattering == true) { Material.SetTexture("_ScatteringTex", ScatteringTex); SgtHelper.EnableKeyword("SGT_B"); // Scattering } else { SgtHelper.DisableKeyword("SGT_B"); // Scattering } UpdateMaterialNonSerialized(); }
protected virtual void LateUpdate() { // The lights and shadows may have moved, so write them if (Material != null) { SgtHelper.SetTempMaterial(Material); SgtHelper.WriteLights(Lit, Lights, 2, transform.position, null, null, SgtHelper.Brighten(Color, Brightness), ScatteringStrength); SgtHelper.WriteShadows(Shadows, 2); if (Detail == true) { if (Application.isPlaying == true) { DetailOffset += DetailSpeed * Time.deltaTime; } Material.SetVector("_DetailOffset", DetailOffset); } } }
protected override void CameraPreCull(Camera camera) { base.CameraPreCull(camera); var dir = (transform.position - camera.transform.position).normalized; var theta = Mathf.Abs(Vector3.Dot(transform.up, dir)); var bright = Mathf.Lerp(HorizontalBrightness, Brightness, Mathf.Pow(theta, HorizontalPower)); var color = SgtHelper.Brighten(Color, Color.a * bright); for (var i = groups.Count - 1; i >= 0; i--) { var group = groups[i]; if (group != null) { if (group.Material != null) { group.Material.SetColor("_Color", color); } } } }
public override void ObserverPreCull(SgtObserver observer) { base.ObserverPreCull(observer); var dir = (transform.position - observer.transform.position).normalized; var theta = Mathf.Abs(Vector3.Dot(transform.up, dir)); var bright = Mathf.Lerp(HorizontalBrightness, Brightness, Mathf.Pow(theta, HorizontalPower)); var color = SgtHelper.Brighten(Color, bright); for (var i = groups.Count - 1; i >= 0; i--) { var group = groups[i]; if (group != null) { if (group.Material != null) { group.Material.SetColor("_Color", color); } } } }
public SgtLightning Spawn() { if (Mesh != null && LifeMin > 0.0f && LifeMax > 0.0f) { var sprite = RandomSprite; if (sprite != null) { var lightning = SgtLightning.Create(this); var material = lightning.Material; var uv = SgtHelper.CalculateSpriteUV(sprite); if (material == null) { material = SgtHelper.CreateTempMaterial("Lightning (Generated)", SgtHelper.ShaderNamePrefix + "Lightning"); lightning.SetMaterial(material); } lightning.Life = Random.Range(LifeMin, LifeMax); lightning.Age = 0.0f; lightning.SetMesh(Mesh); material.SetTexture("_MainTex", sprite.texture); material.SetColor("_Color", SgtHelper.Brighten(RandomColor, Brightness)); material.SetFloat("_Age", 0.0f); material.SetVector("_Offset", new Vector2(uv.x, uv.y)); material.SetVector("_Scale", new Vector2(uv.z - uv.x, uv.w - uv.y)); lightning.transform.localRotation = Random.rotation; return(lightning); } } return(null); }
protected abstract void CalculateAsteroids(out List <SgtBeltAsteroid> asteroids, out bool pool); // pool == true when they are temporary protected virtual void UpdateGroupMaterial(SgtBeltGroup group) { if (group.Material == null) { group.Material = SgtHelper.CreateTempMaterial(SgtHelper.ShaderNamePrefix + "Belt"); } var scale = transform.lossyScale.x; var color = SgtHelper.Brighten(Color, Brightness); var renderQueue = (int)RenderQueue + RenderQueueOffset; var lightCount = SgtHelper.WriteLights(Lights, 2, transform.position, null, null, group.Material); var shadowCount = SgtHelper.WriteShadows(Shadows, 2, group.Material); SgtHelper.WriteLightKeywords(Lights.Count > 0, lightCount, keywords); SgtHelper.WriteShadowKeywords(shadowCount, keywords); group.Material.renderQueue = renderQueue; group.Material.SetTexture("_MainTex", group.MainTex); group.Material.SetTexture("_HeightTex", group.HeightTex); group.Material.SetColor("_Color", color); group.Material.SetFloat("_Scale", scale); group.Material.SetFloat("_Age", Age); }
private void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial(SgtHelper.ShaderNamePrefix + "Jovian"); } var color = SgtHelper.Brighten(Color, Brightness); var renderQueue = (int)RenderQueue + RenderQueueOffset; var localToWorld = transform.localToWorldMatrix * SgtHelper.Scaling(MeshRadius * 2.0f); // Double mesh radius so the max thickness caps at 1.0 material.renderQueue = renderQueue; material.SetTexture("_MainTex", MainTex); material.SetColor("_Color", color); material.SetFloat("_Power", Power); material.SetFloat("_Density", Density); material.SetMatrix("_WorldToLocal", localToWorld.inverse); material.SetMatrix("_LocalToWorld", localToWorld); material.SetTexture("_RimLut", rimLut); material.SetTexture("_LightingLut", lightingLut); lightCount = SgtHelper.WriteLights(Lights, 2, transform.position, transform, null, material); shadowCount = SgtHelper.WriteShadows(Shadows, 2, material); }
protected virtual void OnWillRenderObject() { if (meshRenderer != null) { if (Sprite != null && Life > 0.0f && MaxLife > 0.0f) { var uv = SgtHelper.CalculateSpriteUV(Sprite); material.SetTexture("_MainTex", Sprite.texture); material.SetFloat("_Age", 1.0f - Life / MaxLife); material.SetColor("_Color", SgtHelper.Brighten(Color, Brightness)); material.SetVector("_Offset", new Vector2(uv.x, uv.y)); material.SetVector("_Scale", new Vector2(uv.z - uv.x, uv.w - uv.y)); } else { SgtComponentPool <SgtLightning> .Add(this); } } }
public virtual void UpdateMaterial() { updateMaterialCalled = true; if (Material == null) { Material = SgtHelper.CreateTempMaterial("Ring (Generated)", ShaderName); if (Models != null) { for (var i = Models.Count - 1; i >= 0; i--) { var model = Models[i]; if (model != null) { model.SetMaterial(Material); } } } } var color = SgtHelper.Brighten(Color, Brightness); var renderQueue = (int)RenderQueue + RenderQueueOffset; Material.renderQueue = renderQueue; Material.SetColor("_Color", color); Material.SetTexture("_MainTex", MainTex); if (Detail == true) { SgtHelper.EnableKeyword("SGT_B", Material); // Detail Material.SetTexture("_DetailTex", DetailTex); Material.SetVector("_DetailScale", new Vector2(DetailScaleX, DetailScaleY)); Material.SetFloat("_DetailTwist", DetailTwist); Material.SetFloat("_DetailTwistBias", DetailTwistBias); } else { SgtHelper.DisableKeyword("SGT_B", Material); // Detail } if (Fade == true) { SgtHelper.EnableKeyword("SGT_C", Material); // Fade Material.SetTexture("_FadeTex", FadeTex); Material.SetFloat("_FadeDistanceRecip", SgtHelper.Reciprocal(FadeDistance)); } else { SgtHelper.DisableKeyword("SGT_C", Material); // Fade } if (Lit == true) { Material.SetTexture("_LightingTex", LightingTex); } if (Scattering == true) { SgtHelper.EnableKeyword("SGT_A", Material); // Scattering Material.SetFloat("_ScatteringMie", ScatteringMie * ScatteringMie); } else { SgtHelper.DisableKeyword("SGT_A", Material); // Scattering } UpdateMaterialNonSerialized(); }
public void UpdateMaterials() { updateMaterialsCalled = true; if (InnerMaterial == null) { InnerMaterial = SgtHelper.CreateTempMaterial("Atmosphere Inner (Generated)", SgtHelper.ShaderNamePrefix + "AtmosphereInner"); if (InnerRenderers != null) { for (var i = InnerRenderers.Count - 1; i >= 0; i--) { var innerRenderer = InnerRenderers[i]; if (innerRenderer != null) { SgtHelper.AddMaterial(innerRenderer, InnerMaterial); } } } UpdateTerrainMaterials(); } if (OuterMaterial == null) { OuterMaterial = SgtHelper.CreateTempMaterial("Atmosphere Outer (Generated)", SgtHelper.ShaderNamePrefix + "AtmosphereOuter"); if (Outers != null) { for (var i = Outers.Count - 1; i >= 0; i--) { var outer = Outers[i]; if (outer != null) { outer.SetMaterial(OuterMaterial); } } } } var color = SgtHelper.Brighten(Color, Brightness); var renderQueue = (int)RenderQueue + RenderQueueOffset; InnerMaterial.renderQueue = renderQueue; OuterMaterial.renderQueue = renderQueue; InnerMaterial.SetColor("_Color", color); OuterMaterial.SetColor("_Color", color); InnerMaterial.SetTexture("_DepthTex", InnerDepthTex); OuterMaterial.SetTexture("_DepthTex", OuterDepthTex); if (Lit == true) { InnerMaterial.SetTexture("_LightingTex", LightingTex); OuterMaterial.SetTexture("_LightingTex", LightingTex); if (Scattering == true) { OuterMaterial.SetTexture("_ScatteringTex", ScatteringTex); OuterMaterial.SetFloat("_ScatteringMie", ScatteringMie); OuterMaterial.SetFloat("_ScatteringRayleigh", ScatteringRayleigh); SgtHelper.EnableKeyword("SGT_B", OuterMaterial); // Scattering if (GroundScattering == true) { InnerMaterial.SetTexture("_ScatteringTex", ScatteringTex); InnerMaterial.SetFloat("_ScatteringMie", ScatteringMie); InnerMaterial.SetFloat("_ScatteringRayleigh", ScatteringRayleigh); SgtHelper.EnableKeyword("SGT_B", InnerMaterial); // Scattering } else { SgtHelper.DisableKeyword("SGT_B", InnerMaterial); // Scattering } } else { SgtHelper.DisableKeyword("SGT_B", InnerMaterial); // Scattering SgtHelper.DisableKeyword("SGT_B", OuterMaterial); // Scattering } } SgtHelper.SetTempMaterial(InnerMaterial, OuterMaterial); UpdateMaterialNonSerialized(); }
protected virtual void LateUpdate() { // The lights and shadows may have moved, so write them if (InnerMaterial != null && OuterMaterial != null) { SgtHelper.SetTempMaterial(InnerMaterial, OuterMaterial); SgtHelper.WriteLights(Lit, Lights, 2, transform.position, transform, null, SgtHelper.Brighten(Color, Brightness), ScatteringStrength); SgtHelper.WriteShadows(Shadows, 2); } }
public void UpdateMaterial() { updateMaterialCalled = true; if (Material == null) { Material = SgtHelper.CreateTempMaterial("Aurora (Generated)", SgtHelper.ShaderNamePrefix + "Aurora"); if (Models != null) { for (var i = Models.Count - 1; i >= 0; i--) { var model = Models[i]; if (model != null) { model.SetMaterial(Material); } } } } var color = SgtHelper.Premultiply(SgtHelper.Brighten(Color, Brightness)); var renderQueue = (int)RenderQueue + RenderQueueOffset; if (Material.renderQueue != renderQueue) { Material.renderQueue = renderQueue; } Material.SetColor("_Color", color); Material.SetTexture("_MainTex", MainTex); Material.SetFloat("_RadiusMin", RadiusMin); Material.SetFloat("_RadiusSize", RadiusMax - RadiusMin); SgtHelper.SetTempMaterial(Material); if (FadeNear == true) { SgtHelper.EnableKeyword("SGT_A"); // FadeNear Material.SetTexture("_FadeNearTex", FadeNearTex); Material.SetFloat("_FadeNearRadius", FadeNearRadius); Material.SetFloat("_FadeNearScale", SgtHelper.Reciprocal(FadeNearThickness)); } else { SgtHelper.DisableKeyword("SGT_A"); // FadeNear } if (Anim == true) { SgtHelper.EnableKeyword("SGT_B"); // Anim Material.SetFloat("_AnimOffset", AnimOffset); } else { SgtHelper.DisableKeyword("SGT_B"); // Anim } }
protected virtual void LateUpdate() { if (Application.isPlaying == true) { OrbitOffset += Time.deltaTime * OrbitSpeed; } if (Material != null) { Material.SetFloat("_Age", OrbitOffset); } // The lights and shadows may have moved, so write them if (Material != null) { SgtHelper.SetTempMaterial(Material); SgtHelper.WriteLights(Lit, Lights, 2, transform.position, transform, null, SgtHelper.Brighten(Color, Brightness), 1.0f); SgtHelper.WriteShadows(Shadows, 2); } }