protected override void BuildMaterial() { base.BuildMaterial(); if (Softness > 0.0f) { SgtHelper.EnableKeyword("LIGHT_2", material); // Softness material.SetFloat("_SoftParticlesFactor", SgtHelper.Reciprocal(Softness)); } else { SgtHelper.DisableKeyword("LIGHT_2", material); // Softness } if (Far == true) { SgtHelper.EnableKeyword("SGT_E", material); // Far material.SetTexture("_FarTex", FarTex); material.SetFloat("_FarRadius", FarRadius); material.SetFloat("_FarScale", SgtHelper.Reciprocal(FarThickness)); } else { SgtHelper.DisableKeyword("SGT_E", material); // Far } material.SetVector("_WrapSize", Size); material.SetVector("_WrapScale", SgtHelper.Reciprocal3(Size)); }
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 } }
protected override void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial("Starfield (Generated)", SgtHelper.ShaderNamePrefix + "Backdrop"); } base.UpdateMaterial(); if (blendMode == BlendModeType.Default) { BuildAdditive(); } if (powerRgb == true) { SgtHelper.EnableKeyword("SGT_B", material); // PowerRgb } else { SgtHelper.DisableKeyword("SGT_B", material); // PowerRgb } if (clampSize == true) { SgtHelper.EnableKeyword("SGT_C", material); // Clamp Size material.SetFloat(SgtShader._ClampSizeMin, clampSizeMin * radius); } else { SgtHelper.DisableKeyword("SGT_C", material); // Clamp Size } }
protected override void BuildMaterial() { base.BuildMaterial(); if (BlendMode == BlendModeType.Default) { BuildAlphaTest(); } material.SetFloat(SgtShader._Age, OrbitOffset); if (Lit == true) { material.SetTexture(SgtShader._LightingTex, LightingTex); material.SetColor(SgtShader._AmbientColor, AmbientColor); } if (PowerRgb == true) { SgtHelper.EnableKeyword("SGT_B", material); // PowerRgb } else { SgtHelper.DisableKeyword("SGT_B", material); // PowerRgb } }
protected override void BuildMaterial() { base.BuildMaterial(); if (BlendMode == BlendModeType.Default) { BuildAdditive(); } if (PowerRgb == true) { SgtHelper.EnableKeyword("SGT_B", material); // PowerRgb } else { SgtHelper.DisableKeyword("SGT_B", material); // PowerRgb } if (ClampSize == true) { SgtHelper.EnableKeyword("SGT_C", material); // Clamp Size material.SetFloat(SgtShader._ClampSizeMin, ClampSizeMin * Radius); } else { SgtHelper.DisableKeyword("SGT_C", material); // Clamp Size } }
protected override void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial("Starfield (Generated)", SgtHelper.ShaderNamePrefix + "Belt"); } base.UpdateMaterial(); if (blendMode == BlendModeType.Default) { BuildAlphaTest(); } material.SetFloat(SgtShader._Age, orbitOffset); if (lit == true) { material.SetTexture(SgtShader._LightingTex, lightingTex); material.SetColor(SgtShader._AmbientColor, ambientColor); } if (powerRgb == true) { SgtHelper.EnableKeyword("SGT_B", material); // PowerRgb } else { SgtHelper.DisableKeyword("SGT_B", material); // PowerRgb } material.SetTexture(SgtShader._LightingTex, lightingTex); }
public void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial("Singulairty (Generated)", SgtHelper.ShaderNamePrefix + "Singularity"); if (model != null) { model.SetMaterial(material); } } material.renderQueue = RenderQueue; material.SetVector(SgtShader._Center, SgtHelper.NewVector4(transform.position, 1.0f)); material.SetFloat(SgtShader._PinchPower, PinchPower); material.SetFloat(SgtShader._PinchScale, SgtHelper.Reciprocal(1.0f - PinchOffset)); material.SetFloat(SgtShader._PinchOffset, PinchOffset); material.SetFloat(SgtShader._HolePower, HolePower); material.SetColor(SgtShader._HoleColor, HoleColor); SgtHelper.SetTempMaterial(material); if (Tint == true) { SgtHelper.EnableKeyword("SGT_A"); // Tint material.SetFloat(SgtShader._TintPower, TintPower); material.SetColor(SgtShader._TintColor, TintColor); } else { SgtHelper.DisableKeyword("SGT_A"); // Tint } if (EdgeFade == EdgeFadeType.Center) { SgtHelper.EnableKeyword("SGT_B"); // Fade Center material.SetFloat(SgtShader._EdgeFadePower, EdgeFadePower); } else { SgtHelper.DisableKeyword("SGT_B"); // Fade Center } if (EdgeFade == EdgeFadeType.Fragment) { SgtHelper.EnableKeyword("SGT_C"); // Fade Fragment material.SetFloat(SgtShader._EdgeFadePower, EdgeFadePower); } else { SgtHelper.DisableKeyword("SGT_C"); // Fade Fragment } }
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 } }
protected void BuildAdditiveSmooth() { material.SetInt(SgtShader._SrcMode, (int)UnityEngine.Rendering.BlendMode.One); material.SetInt(SgtShader._DstMode, (int)UnityEngine.Rendering.BlendMode.OneMinusSrcColor); material.SetInt(SgtShader._ZWriteMode, 0); SgtHelper.DisableKeyword("SGT_A", material); // Alpha Test }
protected void BuildAdditive() { material.SetInt("_SrcMode", (int)UnityEngine.Rendering.BlendMode.One); material.SetInt("_DstMode", (int)UnityEngine.Rendering.BlendMode.One); material.SetInt("_ZWriteMode", 0); SgtHelper.DisableKeyword("SGT_A", material); // Alpha Test }
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 static void Write(bool lit, Vector3 center, Transform directionTransform, Transform positionTransform, float scatterStrength, int maxLights) { var lightCount = 0; if (lit == true) { var lights = Find(); for (var i = 0; i < lights.Count; i++) { var light = lights[i]; var properties = GetLightProperties(lightCount++); var direction = default(Vector3); var position = default(Vector3); var color = default(Color); Calculate(light.CachedLight, center, directionTransform, positionTransform, ref position, ref direction, ref color); for (var j = SgtHelper.tempMaterials.Count - 1; j >= 0; j--) { var tempMaterial = SgtHelper.tempMaterials[j]; if (tempMaterial != null) { tempMaterial.SetVector(properties.Direction, direction); tempMaterial.SetVector(properties.Position, SgtHelper.NewVector4(position, 1.0f)); tempMaterial.SetColor(properties.Color, color); tempMaterial.SetColor(properties.Scatter, color * scatterStrength); } } if (lightCount >= maxLights) { break; } } } for (var i = 0; i <= maxLights; i++) { var keyword = GetLightKeyword(i); if (lit == true && i == lightCount) { SgtHelper.EnableKeyword(keyword); } else { SgtHelper.DisableKeyword(keyword); } } }
protected override void BuildMaterial() { base.BuildMaterial(); if (BlendMode == SgtQuads.BlendModeType.Default) { BuildAdditive(); } if (PowerRgb == true) { SgtHelper.EnableKeyword("SGT_B", material); // PowerRgb } else { SgtHelper.DisableKeyword("SGT_B", material); // PowerRgb } if (Stretch == true) { SgtHelper.EnableKeyword("SGT_C", material); // Stretch } else { SgtHelper.DisableKeyword("SGT_C", material); // Stretch } if (Near == true) { SgtHelper.EnableKeyword("SGT_D", material); // Near material.SetTexture(SgtShader._NearTex, NearTex); material.SetFloat(SgtShader._NearScale, SgtHelper.Reciprocal(NearThickness)); } else { SgtHelper.DisableKeyword("SGT_D", material); // Near } if (Pulse == true) { SgtHelper.EnableKeyword("LIGHT_1", material); // Pulse // This is also set in Update material.SetFloat(SgtShader._PulseOffset, PulseOffset); } else { SgtHelper.DisableKeyword("LIGHT_1", material); // Pulse } }
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); } }
private void CameraPreRender(Camera camera) { if (model != null) { model.Restore(camera); } // Write camera-dependant shader values if (innerMaterial != null && outerMaterial != null) { var cameraPosition = camera.transform.position; var localCameraPosition = transform.InverseTransformPoint(cameraPosition); var localDistance = localCameraPosition.magnitude; var clampedSky = Mathf.InverseLerp(OuterRadius, InnerMeshRadius, localDistance); var innerAtmosphereDepth = default(float); var outerAtmosphereDepth = default(float); var radiusRatio = SgtHelper.Divide(InnerMeshRadius, OuterRadius); var scaleDistance = SgtHelper.Divide(localDistance, OuterRadius); var innerDensity = 1.0f - InnerFog; var outerDensity = 1.0f - OuterFog; SgtHelper.CalculateAtmosphereThicknessAtHorizon(radiusRatio, 1.0f, scaleDistance, out innerAtmosphereDepth, out outerAtmosphereDepth); SgtHelper.SetTempMaterial(innerMaterial, outerMaterial); if (scaleDistance > 1.0f) { SgtHelper.EnableKeyword("SGT_A"); // Outside } else { SgtHelper.DisableKeyword("SGT_A"); // Outside } innerMaterial.SetFloat("_HorizonLengthRecip", SgtHelper.Reciprocal(innerAtmosphereDepth * innerDensity)); outerMaterial.SetFloat("_HorizonLengthRecip", SgtHelper.Reciprocal(outerAtmosphereDepth * outerDensity)); if (OuterDepthTex != null) { #if UNITY_EDITOR SgtHelper.MakeTextureReadable(OuterDepthTex); #endif outerMaterial.SetFloat("_Sky", GetSky(camera) * OuterDepthTex.GetPixelBilinear(clampedSky / outerDensity, 0.0f).a); } UpdateMaterialNonSerialized(); } }
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(); }
private void CameraPreRender(Camera camera) { if (material != null) { var cameraPosition = camera.transform.position; var localCameraPosition = transform.InverseTransformPoint(cameraPosition); var localDistance = localCameraPosition.magnitude; var scaleDistance = SgtHelper.Divide(localDistance, Radius); if (scaleDistance > 1.0f) { SgtHelper.EnableKeyword("SGT_A", material); // Outside } else { SgtHelper.DisableKeyword("SGT_A", material); // Outside if (DepthTex != null) { #if UNITY_EDITOR SgtHelper.MakeTextureReadable(DepthTex); #endif material.SetFloat("_Sky", Sky * DepthTex.GetPixelBilinear(1.0f - scaleDistance, 0.0f).a); } } // Write these once to save CPU if (renderedThisFrame == false) { renderedThisFrame = true; // Write lights and shadows SgtHelper.SetTempMaterial(material); SgtLight.Write(Lit, transform.position, transform, null, ScatteringStrength, 2); SgtShadow.Write(Lit, gameObject, 2); // Write matrices var localToWorld = transform.localToWorldMatrix * SgtHelper.Scaling(Radius * 2.0f); // Double mesh radius so the max thickness caps at 1.0 material.SetMatrix("_WorldToLocal", localToWorld.inverse); material.SetMatrix("_LocalToWorld", localToWorld); } } }
protected override void BuildMaterial() { base.BuildMaterial(); if (BlendMode == BlendModeType.Default) { BuildAdditive(); } if (PowerRgb == true) { SgtHelper.EnableKeyword("SGT_B", material); // PowerRgb } else { SgtHelper.DisableKeyword("SGT_B", material); // PowerRgb } }
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 } }
public static void Write(bool lit, int mask, int maxShadows) { var shadowCount = 0; for (var i = 0; i < tempShadows.Count; i++) { var shadow = tempShadows[i]; var properties = GetShadowProperties(shadowCount++); for (var j = SgtHelper.tempMaterials.Count - 1; j >= 0; j--) { var tempMaterial = SgtHelper.tempMaterials[j]; if (tempMaterial != null) { tempMaterial.SetTexture(properties.Texture, shadow.cachedTexture); tempMaterial.SetMatrix(properties.Matrix, shadow.cachedMatrix); tempMaterial.SetFloat(properties.Ratio, shadow.cachedRatio); } } if (shadowCount >= maxShadows) { break; } } for (var i = 0; i <= maxShadows; i++) { var keyword = GetShadowKeyword(i); if (lit == true && i == shadowCount) { SgtHelper.EnableKeyword(keyword); } else { SgtHelper.DisableKeyword(keyword); } } }
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 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 } }
protected override void UpdateMaterial() { if (material == null) { material = SgtHelper.CreateTempMaterial("Starfield (Generated)", SgtHelper.ShaderNamePrefix + "StarfieldInfinite"); } base.UpdateMaterial(); if (softness > 0.0f) { SgtHelper.EnableKeyword("LIGHT_2", material); // Softness material.SetFloat(SgtShader._SoftParticlesFactor, SgtHelper.Reciprocal(softness)); } else { SgtHelper.DisableKeyword("LIGHT_2", material); // Softness } if (far == true) { SgtHelper.EnableKeyword("SGT_E", material); // Far material.SetTexture(SgtShader._FarTex, farTex); material.SetFloat(SgtShader._FarRadius, farRadius); material.SetFloat(SgtShader._FarScale, SgtHelper.Reciprocal(farThickness)); } else { SgtHelper.DisableKeyword("SGT_E", material); // Far } material.SetVector(SgtShader._WrapSize, size); material.SetVector(SgtShader._WrapScale, SgtHelper.Reciprocal3(size)); }
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 } }