public void CollectShaderProperties(PropertyCollector collector, GenerationMode generationMode) { foreach (var prop in properties) { if (generationMode == GenerationMode.Preview && prop.propertyType == PropertyType.Gradient) { GradientShaderProperty gradientProperty = prop as GradientShaderProperty; GradientUtils.GetGradientPropertiesForPreview(collector, gradientProperty.referenceName, gradientProperty.value); continue; } collector.AddShaderProperty(prop); } }
public override void AddDefaultProperty(PropertyCollector properties, GenerationMode generationMode) { var matOwner = owner as AbstractMaterialNode; if (matOwner == null) { throw new Exception(string.Format("Slot {0} either has no owner, or the owner is not a {1}", this, typeof(AbstractMaterialNode))); } if (generationMode == GenerationMode.Preview) { properties.AddShaderProperty(new Vector1ShaderProperty() { overrideReferenceName = string.Format("{0}_Type", matOwner.GetVariableNameForSlot(id)), value = (int)value.mode, generatePropertyBlock = false }); properties.AddShaderProperty(new Vector1ShaderProperty() { overrideReferenceName = string.Format("{0}_ColorsLength", matOwner.GetVariableNameForSlot(id)), value = value.colorKeys.Length, generatePropertyBlock = false }); properties.AddShaderProperty(new Vector1ShaderProperty() { overrideReferenceName = string.Format("{0}_AlphasLength", matOwner.GetVariableNameForSlot(id)), value = value.alphaKeys.Length, generatePropertyBlock = false }); for (int i = 0; i < 8; i++) { properties.AddShaderProperty(new Vector4ShaderProperty() { overrideReferenceName = string.Format("{0}_ColorKey{1}", matOwner.GetVariableNameForSlot(id), i), value = i < value.colorKeys.Length ? GradientUtils.ColorKeyToVector(value.colorKeys[i]) : Vector4.zero, generatePropertyBlock = false }); } for (int i = 0; i < 8; i++) { properties.AddShaderProperty(new Vector4ShaderProperty() { overrideReferenceName = string.Format("{0}_AlphaKey{1}", matOwner.GetVariableNameForSlot(id), i), value = i < value.alphaKeys.Length ? GradientUtils.AlphaKeyToVector(value.alphaKeys[i]) : Vector2.zero, generatePropertyBlock = false }); } } var prop = new GradientShaderProperty(); prop.overrideReferenceName = matOwner.GetVariableNameForSlot(id); prop.generatePropertyBlock = false; prop.value = value; if (generationMode == GenerationMode.Preview) { prop.OverrideMembers(matOwner.GetVariableNameForSlot(id)); } properties.AddShaderProperty(prop); }