public void UpdateMaterials() { if (innerMaterial == null) { innerMaterial = SgtHelper.CreateTempMaterial("Corona Inner (Generated)", SgtHelper.ShaderNamePrefix + "CoronaInner"); CachedSharedMaterial.Material = innerMaterial; } if (outerMaterial == null) { outerMaterial = SgtHelper.CreateTempMaterial("Corona Outer (Generated)", SgtHelper.ShaderNamePrefix + "CoronaOuter"); if (model != null) { model.SetMaterial(outerMaterial); } } var color = SgtHelper.Brighten(Color, Brightness); innerMaterial.renderQueue = outerMaterial.renderQueue = RenderQueue; innerMaterial.SetColor("_Color", color); outerMaterial.SetColor("_Color", color); innerMaterial.SetTexture("_DepthTex", InnerDepthTex); outerMaterial.SetTexture("_DepthTex", OuterDepthTex); UpdateMaterialNonSerialized(); }
public void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial("Cloudsphere (Generated)", SgtHelper.ShaderNamePrefix + "Cloudsphere"); if (model != null) { model.SetMaterial(material); } } var color = SgtHelper.Brighten(Color, Brightness); material.renderQueue = RenderQueue; material.SetColor("_Color", color); material.SetTexture("_MainTex", MainTex); material.SetTexture("_DepthTex", DepthTex); material.SetTexture("_LightingTex", LightingTex); if (Near == true) { SgtHelper.EnableKeyword("SGT_A", material); // Near material.SetTexture("_NearTex", NearTex); material.SetFloat("_NearScale", SgtHelper.Reciprocal(NearDistance)); } else { SgtHelper.DisableKeyword("SGT_A", material); // Near } }
public static void Calculate(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 * 10000000.0f; break; } // Transform into local space? if (directionTransform != null) { direction = directionTransform.InverseTransformDirection(direction); } if (positionTransform != null) { position = positionTransform.InverseTransformPoint(position); } } }
public void UpdateMaterial() { renderedThisFrame = false; if (material == null) { material = SgtHelper.CreateTempMaterial("Cloudsphere (Generated)", SgtHelper.ShaderNamePrefix + "Cloudsphere"); if (model != null) { model.SetMaterial(material); } } var color = SgtHelper.Brighten(Color, Brightness); material.renderQueue = RenderQueue; material.SetColor(SgtShader._Color, color); material.SetTexture(SgtShader._CubeTex, MainTex); material.SetTexture(SgtShader._DepthTex, DepthTex); material.SetTexture(SgtShader._LightingTex, LightingTex); if (Near == true) { SgtHelper.EnableKeyword("SGT_A", material); // Near material.SetTexture(SgtShader._NearTex, NearTex); material.SetFloat(SgtShader._NearScale, SgtHelper.Reciprocal(NearDistance)); } else { SgtHelper.DisableKeyword("SGT_A", material); // Near } if (Detail == true) { SgtHelper.EnableKeyword("SGT_B", material); // Detail material.SetTexture(SgtShader._DetailTex, DetailTex); material.SetFloat(SgtShader._DetailScale, DetailScale); material.SetFloat(SgtShader._DetailTiling, DetailTiling); } else { SgtHelper.DisableKeyword("SGT_B", material); // Detail } if (Softness > 0.0f) { SgtHelper.EnableKeyword("SGT_C", material); // Softness material.SetFloat(SgtShader._SoftParticlesFactor, SgtHelper.Reciprocal(Softness)); } else { SgtHelper.DisableKeyword("SGT_C", material); // Softness } }
public virtual void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial("Ring (Generated)", SgtHelper.ShaderNamePrefix + "Ring"); } var color = SgtHelper.Brighten(this.color, brightness); material.renderQueue = renderQueue; material.SetColor(SgtShader._Color, color); material.SetTexture(SgtShader._MainTex, mainTex); if (detail == true) { SgtHelper.EnableKeyword("SGT_B", material); // Detail material.SetTexture(SgtShader._DetailTex, detailTex); material.SetVector(SgtShader._DetailOffset, detailOffset); material.SetVector(SgtShader._DetailScale, new Vector2(detailScaleX, detailScaleY)); material.SetFloat(SgtShader._DetailTwist, detailTwist); material.SetFloat(SgtShader._DetailTwistBias, detailTwistBias); } else { SgtHelper.DisableKeyword("SGT_B", material); // Detail } if (near == true) { SgtHelper.EnableKeyword("SGT_C", material); // Near material.SetTexture(SgtShader._NearTex, nearTex); material.SetFloat(SgtShader._NearScale, SgtHelper.Reciprocal(nearDistance)); } else { SgtHelper.DisableKeyword("SGT_C", material); // Near } if (lit == true) { material.SetTexture(SgtShader._LightingTex, lightingTex); material.SetColor(SgtShader._AmbientColor, ambientColor); } if (scattering == true) { SgtHelper.EnableKeyword("SGT_A", material); // Scattering material.SetFloat(SgtShader._ScatteringMie, scatteringMie * scatteringMie); } else { SgtHelper.DisableKeyword("SGT_A", material); // Scattering } }
private void UpdateMaterial() { if (generatedMaterial == null) { generatedMaterial = SgtHelper.CreateTempMaterial("Cloudsphere (Generated)", SgtHelper.ShaderNamePrefix + "Cloudsphere"); } var color = SgtHelper.Brighten(this.color, brightness); generatedMaterial.renderQueue = renderQueue; generatedMaterial.SetColor(SgtShader._Color, color); generatedMaterial.SetTexture(SgtShader._CubeTex, mainTex); generatedMaterial.SetTexture(SgtShader._DepthTex, depthTex); if (lit == true) { generatedMaterial.SetTexture(SgtShader._LightingTex, lightingTex); generatedMaterial.SetColor(SgtShader._AmbientColor, ambientColor); } if (near == true) { SgtHelper.EnableKeyword("SGT_A", generatedMaterial); // Near generatedMaterial.SetTexture(SgtShader._NearTex, nearTex); generatedMaterial.SetFloat(SgtShader._NearScale, SgtHelper.Reciprocal(nearDistance)); } else { SgtHelper.DisableKeyword("SGT_A", generatedMaterial); // Near } if (detail == true) { SgtHelper.EnableKeyword("SGT_B", generatedMaterial); // Detail generatedMaterial.SetTexture(SgtShader._DetailTex, detailTex); generatedMaterial.SetFloat(SgtShader._DetailScale, detailScale); generatedMaterial.SetFloat(SgtShader._DetailTiling, detailTiling); } else { SgtHelper.DisableKeyword("SGT_B", generatedMaterial); // Detail } if (softness > 0.0f) { SgtHelper.EnableKeyword("SGT_C", generatedMaterial); // Softness generatedMaterial.SetFloat(SgtShader._SoftParticlesFactor, SgtHelper.Reciprocal(softness)); } else { SgtHelper.DisableKeyword("SGT_C", generatedMaterial); // Softness } }
public void UpdateMaterial() { 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)); material.renderQueue = RenderQueue; material.SetColor(SgtShader._Color, color); material.SetTexture(SgtShader._MainTex, MainTex); material.SetFloat(SgtShader._RadiusMin, RadiusMin); material.SetFloat(SgtShader._RadiusSize, RadiusMax - RadiusMin); SgtHelper.SetTempMaterial(material); if (Near == true) { SgtHelper.EnableKeyword("SGT_A"); // Near material.SetTexture(SgtShader._NearTex, NearTex); material.SetFloat(SgtShader._NearScale, SgtHelper.Reciprocal(NearDistance)); } else { SgtHelper.DisableKeyword("SGT_A"); // Near } if (Anim == true) { SgtHelper.EnableKeyword("SGT_B"); // Anim material.SetFloat(SgtShader._AnimOffset, AnimOffset); } else { SgtHelper.DisableKeyword("SGT_B"); // Anim } }
public void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial("Prominence (Generated)", SgtHelper.ShaderNamePrefix + "Prominence"); 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)); 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"); } }
public virtual void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial("Accretion (Generated)", SgtHelper.ShaderNamePrefix + "Accretion"); if (models != null) { for (var i = models.Count - 1; i >= 0; i--) { var model = models[i]; if (model != null) { model.SetMaterial(material); } } } } material.renderQueue = RenderQueue; material.SetColor("_Color", SgtHelper.Brighten(Color, Brightness)); 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 (Near == true) { SgtHelper.EnableKeyword("SGT_C", material); // Near material.SetTexture("_NearTex", NearTex); material.SetFloat("_NearScale", SgtHelper.Reciprocal(NearDistance)); } else { SgtHelper.DisableKeyword("SGT_C", material); // Near } }
public void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial("Spacetime (Generated)", SgtHelper.ShaderNamePrefix + "Spacetime"); CachedSharedMaterial.Material = material; } var ambientColor = SgtHelper.Brighten(AmbientColor, AmbientBrightness); var displacementColor = SgtHelper.Brighten(DisplacementColor, DisplacementBrightness); var higlightColor = SgtHelper.Brighten(HighlightColor, HighlightBrightness); material.renderQueue = RenderQueue; 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); } }
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); } }
private void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial("Spacetime (Generated)", SgtHelper.ShaderNamePrefix + "Spacetime"); } var ambientColor = SgtHelper.Brighten(this.ambientColor, ambientBrightness); var displacementColor = SgtHelper.Brighten(this.displacementColor, displacementBrightness); var higlightColor = SgtHelper.Brighten(highlightColor, highlightBrightness); material.renderQueue = renderQueue; material.SetTexture(SgtShader._MainTex, mainTex); material.SetColor(SgtShader._Color, SgtHelper.Brighten(color, brightness)); material.SetColor(SgtShader._AmbientColor, ambientColor); material.SetColor(SgtShader._DisplacementColor, displacementColor); material.SetColor(SgtShader._HighlightColor, higlightColor); material.SetFloat(SgtShader._HighlightPower, highlightPower); material.SetFloat(SgtShader._HighlightScale, highlightScale); material.SetFloat(SgtShader._Tile, tile); if (displacement == DisplacementType.Pinch) { material.SetFloat(SgtShader._Power, power); } if (displacement == DisplacementType.Offset) { SgtHelper.EnableKeyword("SGT_A", material); material.SetVector(SgtShader._Offset, offset); } else { SgtHelper.DisableKeyword("SGT_A", material); } if (accumulate == true) { SgtHelper.EnableKeyword("SGT_B", material); } else { SgtHelper.DisableKeyword("SGT_B", material); } }
public void UpdateMaterials() { if (innerMaterial == null) { innerMaterial = SgtHelper.CreateTempMaterial("Corona Inner (Generated)", SgtHelper.ShaderNamePrefix + "CoronaInner"); CachedSharedMaterial.Material = innerMaterial; } if (outerMaterial == null) { outerMaterial = SgtHelper.CreateTempMaterial("Corona Outer (Generated)", SgtHelper.ShaderNamePrefix + "CoronaOuter"); if (model != null) { model.SetMaterial(outerMaterial); } } var color = SgtHelper.Brighten(Color, Brightness); var innerRatio = SgtHelper.Divide(InnerMeshRadius, OuterRadius); innerMaterial.renderQueue = outerMaterial.renderQueue = RenderQueue; innerMaterial.SetColor(SgtShader._Color, color); outerMaterial.SetColor(SgtShader._Color, color); innerMaterial.SetTexture(SgtShader._DepthTex, InnerDepthTex); outerMaterial.SetTexture(SgtShader._DepthTex, OuterDepthTex); innerMaterial.SetFloat(SgtShader._InnerRatio, innerRatio); innerMaterial.SetFloat(SgtShader._InnerScale, 1.0f / (1.0f - innerRatio)); if (OuterSoftness > 0.0f) { SgtHelper.EnableKeyword("SGT_A", outerMaterial); // Softness outerMaterial.SetFloat(SgtShader._SoftParticlesFactor, SgtHelper.Reciprocal(OuterSoftness)); } else { SgtHelper.DisableKeyword("SGT_A", outerMaterial); // Softness } UpdateMaterialNonSerialized(); }
protected virtual void BuildMaterial() { material.renderQueue = RenderQueue; switch (BlendMode) { case BlendModeType.Additive: BuildAdditive(); break; case BlendModeType.AlphaTest: BuildAlphaTest(); break; case BlendModeType.AdditiveSmooth: BuildAdditiveSmooth(); break; } material.SetTexture(SgtShader._MainTex, MainTex); material.SetColor(SgtShader._Color, SgtHelper.Brighten(Color, Color.a * Brightness)); material.SetFloat(SgtShader._Scale, transform.lossyScale.x); material.SetFloat(SgtShader._ScaleRecip, SgtHelper.Reciprocal(transform.lossyScale.x)); }
protected virtual void UpdateMaterial() { dirtyMaterial = false; material.renderQueue = renderQueue; switch (blendMode) { case BlendModeType.Additive: BuildAdditive(); break; case BlendModeType.AlphaTest: BuildAlphaTest(); break; case BlendModeType.AdditiveSmooth: BuildAdditiveSmooth(); break; } material.SetTexture(SgtShader._MainTex, mainTex); material.SetColor(SgtShader._Color, SgtHelper.Brighten(Color, Color.a * Brightness, false)); }
public static void Calculate(SgtLight light, Vector3 center, Transform directionTransform, Transform positionTransform, ref Vector3 position, ref Vector3 direction, ref Color color) { if (light != null) { var cachedLight = light.CachedLight; direction = -light.transform.forward; position = light.transform.position; color = SgtHelper.Brighten(cachedLight.color, light.intensityInSGT * light.multiplier, false); switch (cachedLight.type) { case LightType.Point: { direction = Vector3.Normalize(position - center); } break; case LightType.Directional: { if (light.treatAsPoint == true) { direction = Vector3.Normalize(position - center); } else { position = center + direction * 10000000.0f; } } break; } // Transform into local space? if (directionTransform != null) { direction = directionTransform.InverseTransformDirection(direction); } if (positionTransform != null) { position = positionTransform.InverseTransformPoint(position); } } }
protected override void HandleCameraDraw(Camera camera) { if (SgtHelper.CanDraw(gameObject, camera) == false) { return; } var properties = shaderProperties.GetProperties(material, camera); // Change brightness based on viewing angle? 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); properties.SetColor(SgtShader._Color, color); Graphics.DrawMesh(mesh, transform.localToWorldMatrix, material, gameObject.layer, camera, 0, properties); }
private void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial("Aurora (Generated)", SgtHelper.ShaderNamePrefix + "Aurora"); } var color = SgtHelper.Premultiply(SgtHelper.Brighten(this.color, brightness)); material.renderQueue = renderQueue; material.SetColor(SgtShader._Color, color); material.SetTexture(SgtShader._MainTex, mainTex); material.SetFloat(SgtShader._RadiusMin, radiusMin); material.SetFloat(SgtShader._RadiusSize, radiusMax - radiusMin); SgtHelper.SetTempMaterial(material); if (near == true) { SgtHelper.EnableKeyword("SGT_A"); // Near material.SetTexture(SgtShader._NearTex, nearTex); material.SetFloat(SgtShader._NearScale, SgtHelper.Reciprocal(nearDistance)); } else { SgtHelper.DisableKeyword("SGT_A"); // Near } if (anim == true) { SgtHelper.EnableKeyword("SGT_B"); // Anim material.SetFloat(SgtShader._AnimOffset, animOffset); } else { SgtHelper.DisableKeyword("SGT_B"); // Anim } }
private void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial("Accretion (Generated)", SgtHelper.ShaderNamePrefix + "Accretion"); } material.renderQueue = renderQueue; material.SetColor(SgtShader._Color, SgtHelper.Brighten(color, brightness)); material.SetTexture(SgtShader._MainTex, mainTex); if (detail == true) { SgtHelper.EnableKeyword("SGT_B", material); // Detail material.SetTexture(SgtShader._DetailTex, detailTex); material.SetVector(SgtShader._DetailScale, new Vector2(detailScaleX, detailScaleY)); material.SetFloat(SgtShader._DetailTwist, detailTwist); material.SetFloat(SgtShader._DetailTwistBias, detailTwistBias); } else { SgtHelper.DisableKeyword("SGT_B", material); // Detail } if (near == true) { SgtHelper.EnableKeyword("SGT_C", material); // Near material.SetTexture(SgtShader._NearTex, nearTex); material.SetFloat(SgtShader._NearScale, SgtHelper.Reciprocal(nearDistance)); } else { SgtHelper.DisableKeyword("SGT_C", material); // Near } }
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(SgtShader._MainTex, sprite.texture); material.SetColor(SgtShader._Color, SgtHelper.Brighten(RandomColor, Brightness)); material.SetFloat(SgtShader._Age, 0.0f); material.SetVector(SgtShader._Offset, new Vector2(uv.x, uv.y)); material.SetVector(SgtShader._Scale, new Vector2(uv.z - uv.x, uv.w - uv.y)); lightning.transform.localRotation = Random.rotation; return(lightning); } } return(null); }
public void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial("Jovian Material (Generated)", SgtHelper.ShaderNamePrefix + "Jovian"); if (model != null) { model.SetMaterial(material); } } material.renderQueue = RenderQueue; material.SetTexture(SgtShader._CubeTex, MainTex); material.SetTexture(SgtShader._DepthTex, DepthTex); material.SetColor(SgtShader._Color, SgtHelper.Brighten(Color, Brightness)); if (Lit == true) { material.SetTexture(SgtShader._LightingTex, LightingTex); material.SetColor(SgtShader._AmbientColor, AmbientColor); } SgtHelper.SetTempMaterial(material); if (Scattering == true) { material.SetTexture(SgtShader._ScatteringTex, ScatteringTex); SgtHelper.EnableKeyword("SGT_B"); // Scattering } else { SgtHelper.DisableKeyword("SGT_B"); // Scattering } }
private void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial("Jovian Material (Generated)", SgtHelper.ShaderNamePrefix + "Jovian"); } material.renderQueue = renderQueue; material.SetTexture(SgtShader._CubeTex, mainTex); material.SetTexture("_FlowTex", flowTex); material.SetFloat("_FlowSpeed", flowSpeed); material.SetFloat("_FlowStrength", flowStrength); material.SetFloat("_FlowNoiseTiling", flowNoiseTiling); material.SetTexture(SgtShader._DepthTex, depthTex); material.SetColor(SgtShader._Color, SgtHelper.Brighten(color, brightness)); if (lit == true) { material.SetTexture(SgtShader._LightingTex, lightingTex); material.SetColor(SgtShader._AmbientColor, ambientColor); } SgtHelper.SetTempMaterial(material); if (scattering == true) { material.SetTexture(SgtShader._ScatteringTex, scatteringTex); SgtHelper.EnableKeyword("SGT_B"); // Scattering } else { SgtHelper.DisableKeyword("SGT_B"); // Scattering } }
public void UpdateMaterials() { if (innerMaterial == null) { innerMaterial = SgtHelper.CreateTempMaterial("Atmosphere Inner (Generated)", SgtHelper.ShaderNamePrefix + "AtmosphereInner"); CachedSharedMaterial.Material = innerMaterial; } if (outerMaterial == null) { outerMaterial = SgtHelper.CreateTempMaterial("Atmosphere Outer (Generated)", SgtHelper.ShaderNamePrefix + "AtmosphereOuter"); if (model != null) { model.SetMaterial(outerMaterial); } } var color = SgtHelper.Brighten(Color, Brightness); innerMaterial.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 } } UpdateMaterialNonSerialized(); }
public void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial("Prominence (Generated)", SgtHelper.ShaderNamePrefix + "Prominence"); 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)); material.renderQueue = RenderQueue; material.SetTexture(SgtShader._MainTex, MainTex); material.SetColor(SgtShader._Color, color); material.SetVector(SgtShader._WorldPosition, transform.position); SgtHelper.SetTempMaterial(material); if (FadeEdge == true) { SgtHelper.EnableKeyword("SGT_A"); material.SetFloat(SgtShader._FadePower, FadePower); } else { SgtHelper.DisableKeyword("SGT_A"); } if (ClipNear == true) { SgtHelper.EnableKeyword("SGT_B"); material.SetFloat(SgtShader._ClipPower, ClipPower); } else { SgtHelper.DisableKeyword("SGT_B"); } if (Distort == true) { SgtHelper.EnableKeyword("SGT_C", material); // Distort material.SetTexture(SgtShader._DistortTex, DistortTex); material.SetVector(SgtShader._DistortScale, new Vector2(DistortScaleX, DistortScaleY)); material.SetFloat(SgtShader._DistortStrength, DistortStrength); } else { SgtHelper.DisableKeyword("SGT_C", material); // Distort } if (Detail == true) { SgtHelper.EnableKeyword("SGT_D", material); // Detail material.SetTexture(SgtShader._DetailTex, DetailTex); material.SetVector(SgtShader._DetailScale, new Vector2(DetailScaleX, DetailScaleY)); material.SetFloat(SgtShader._DetailStrength, DetailStrength); } else { SgtHelper.DisableKeyword("SGT_D", material); // Detail } }
public void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial("Prominence (Generated)", SgtHelper.ShaderNamePrefix + "Prominence"); } material.renderQueue = renderQueue; material.SetTexture(SgtShader._MainTex, mainTex); material.SetColor(SgtShader._Color, SgtHelper.Premultiply(SgtHelper.Brighten(this.color, brightness))); material.SetVector(SgtShader._WorldPosition, transform.position); SgtHelper.SetTempMaterial(material); if (fadeEdge == true) { SgtHelper.EnableKeyword("SGT_A"); material.SetFloat(SgtShader._FadePower, fadePower); } else { SgtHelper.DisableKeyword("SGT_A"); } if (clipNear == true) { SgtHelper.EnableKeyword("SGT_B"); material.SetFloat(SgtShader._ClipPower, clipPower); } else { SgtHelper.DisableKeyword("SGT_B"); } if (distort == true) { SgtHelper.EnableKeyword("SGT_C", material); // Distort material.SetTexture(SgtShader._DistortTex, distortTex); material.SetVector(SgtShader._DistortScale, new Vector2(distortScaleX, distortScaleY)); material.SetFloat(SgtShader._DistortStrength, distortStrength); } else { SgtHelper.DisableKeyword("SGT_C", material); // Distort } if (detail == true) { SgtHelper.EnableKeyword("SGT_D", material); // Detail material.SetTexture(SgtShader._DetailTex, detailTex); material.SetVector(SgtShader._DetailScale, new Vector2(detailScaleX, detailScaleY)); material.SetFloat(SgtShader._DetailStrength, detailStrength); } else { SgtHelper.DisableKeyword("SGT_D", material); // Detail } }
public void UpdateMaterials() { CacheTransform(); if (innerMaterial == null) { innerMaterial = SgtHelper.CreateTempMaterial("Atmosphere Inner (Generated)", SgtHelper.ShaderNamePrefix + "AtmosphereInner"); CachedSharedMaterial.Material = innerMaterial; } if (outerMaterial == null) { outerMaterial = SgtHelper.CreateTempMaterial("Atmosphere Outer (Generated)", SgtHelper.ShaderNamePrefix + "AtmosphereOuter"); if (model != null) { model.SetMaterial(outerMaterial); } } var color = SgtHelper.Brighten(Color, Brightness); var innerRatio = SgtHelper.Divide(InnerMeshRadius, OuterRadius); innerMaterial.renderQueue = outerMaterial.renderQueue = RenderQueue; innerMaterial.SetColor(SgtShader._Color, color); outerMaterial.SetColor(SgtShader._Color, color); innerMaterial.SetTexture(SgtShader._DepthTex, InnerDepthTex); outerMaterial.SetTexture(SgtShader._DepthTex, OuterDepthTex); innerMaterial.SetFloat(SgtShader._InnerRatio, innerRatio); innerMaterial.SetFloat(SgtShader._InnerScale, 1.0f / (1.0f - innerRatio)); if (OuterSoftness > 0.0f) { SgtHelper.EnableKeyword("SGT_A", outerMaterial); // Softness outerMaterial.SetFloat(SgtShader._SoftParticlesFactor, SgtHelper.Reciprocal(OuterSoftness)); } else { SgtHelper.DisableKeyword("SGT_A", outerMaterial); // Softness } if (Lit == true) { innerMaterial.SetColor(SgtShader._AmbientColor, AmbientColor); outerMaterial.SetColor(SgtShader._AmbientColor, AmbientColor); innerMaterial.SetTexture(SgtShader._LightingTex, LightingTex); outerMaterial.SetTexture(SgtShader._LightingTex, LightingTex); if (Scattering == true) { outerMaterial.SetTexture(SgtShader._ScatteringTex, ScatteringTex); outerMaterial.SetFloat(SgtShader._ScatteringMie, ScatteringMie); outerMaterial.SetFloat(SgtShader._ScatteringRayleigh, ScatteringRayleigh); SgtHelper.EnableKeyword("SGT_B", outerMaterial); // Scattering if (GroundScattering == true) { innerMaterial.SetTexture(SgtShader._ScatteringTex, ScatteringTex); innerMaterial.SetFloat(SgtShader._ScatteringMie, ScatteringMie); innerMaterial.SetFloat(SgtShader._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 } } }
public virtual void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial("Ring (Generated)", SgtHelper.ShaderNamePrefix + "Ring"); 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); material.renderQueue = RenderQueue; material.SetColor(SgtShader._Color, color); material.SetTexture(SgtShader._MainTex, MainTex); if (Detail == true) { SgtHelper.EnableKeyword("SGT_B", material); // Detail material.SetTexture(SgtShader._DetailTex, DetailTex); material.SetVector(SgtShader._DetailOffset, DetailOffset); material.SetVector(SgtShader._DetailScale, new Vector2(DetailScaleX, DetailScaleY)); material.SetFloat(SgtShader._DetailTwist, DetailTwist); material.SetFloat(SgtShader._DetailTwistBias, DetailTwistBias); } else { SgtHelper.DisableKeyword("SGT_B", material); // Detail } if (Near == true) { SgtHelper.EnableKeyword("SGT_C", material); // Near material.SetTexture(SgtShader._NearTex, NearTex); material.SetFloat(SgtShader._NearScale, SgtHelper.Reciprocal(NearDistance)); } else { SgtHelper.DisableKeyword("SGT_C", material); // Near } if (Lit == true) { material.SetTexture(SgtShader._LightingTex, LightingTex); } if (Scattering == true) { SgtHelper.EnableKeyword("SGT_A", material); // Scattering material.SetFloat(SgtShader._ScatteringMie, ScatteringMie * ScatteringMie); } else { SgtHelper.DisableKeyword("SGT_A", material); // Scattering } }
protected virtual void UpdateMaterials() { if (innerMaterial == null) { innerMaterial = SgtHelper.CreateTempMaterial("Atmosphere Inner (Generated)", SgtHelper.ShaderNamePrefix + "AtmosphereInner"); } if (outerMaterial == null) { outerMaterial = SgtHelper.CreateTempMaterial("Atmosphere Outer (Generated)", SgtHelper.ShaderNamePrefix + "AtmosphereOuter"); } var color = SgtHelper.Brighten(this.color, brightness); var innerRatio = SgtHelper.Divide(innerMeshRadius, OuterRadius); innerMaterial.renderQueue = outerMaterial.renderQueue = renderQueue; innerMaterial.SetColor(SgtShader._Color, color); outerMaterial.SetColor(SgtShader._Color, color); innerMaterial.SetTexture(SgtShader._DepthTex, innerDepthTex); outerMaterial.SetTexture(SgtShader._DepthTex, outerDepthTex); innerMaterial.SetFloat(SgtShader._InnerRatio, innerRatio); innerMaterial.SetFloat(SgtShader._InnerScale, 1.0f / (1.0f - innerRatio)); if (SgtShaderBundle.IsHDRP(SgtShaderBundle.DetectProjectPipeline()) == true) { innerMaterial.SetFloat(SgtShader._Offset, -1.0f); } else { innerMaterial.SetFloat(SgtShader._Offset, -0.001f); } if (outerSoftness > 0.0f) { SgtHelper.EnableKeyword("SGT_A", outerMaterial); // Softness outerMaterial.SetFloat(SgtShader._SoftParticlesFactor, SgtHelper.Reciprocal(outerSoftness)); } else { SgtHelper.DisableKeyword("SGT_A", outerMaterial); // Softness } if (lit == true) { innerMaterial.SetColor(SgtShader._AmbientColor, ambientColor); outerMaterial.SetColor(SgtShader._AmbientColor, ambientColor); innerMaterial.SetTexture(SgtShader._LightingTex, lightingTex); outerMaterial.SetTexture(SgtShader._LightingTex, lightingTex); if (scattering == true) { outerMaterial.SetTexture(SgtShader._ScatteringTex, scatteringTex); outerMaterial.SetFloat(SgtShader._ScatteringMie, scatteringMie); outerMaterial.SetFloat(SgtShader._ScatteringRayleigh, scatteringRayleigh); SgtHelper.EnableKeyword("SGT_B", outerMaterial); // Scattering if (groundScattering == true) { innerMaterial.SetTexture(SgtShader._ScatteringTex, scatteringTex); innerMaterial.SetFloat(SgtShader._ScatteringMie, scatteringMie); innerMaterial.SetFloat(SgtShader._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 } } CachedSharedMaterial.Material = innerMaterial; }