コード例 #1
0
        public override AbstractShaderProperty Copy()
        {
            var copied = new Vector4ShaderProperty();

            copied.displayName = displayName;
            copied.value       = value;
            return(copied);
        }
コード例 #2
0
        public override void AddDefaultProperty(PropertyCollector properties, GenerationMode generationMode)
        {
            if (!generationMode.IsPreview())
            {
                return;
            }

            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)));
            }

            IShaderProperty property;

            switch (concreteValueType)
            {
            case ConcreteSlotValueType.Vector4:
                property = new Vector4ShaderProperty();
                break;

            case ConcreteSlotValueType.Vector3:
                property = new Vector3ShaderProperty();
                break;

            case ConcreteSlotValueType.Vector2:
                property = new Vector2ShaderProperty();
                break;

            case ConcreteSlotValueType.Vector1:
                property = new Vector1ShaderProperty();
                break;

            case ConcreteSlotValueType.Matrix4:
                property = new Matrix4ShaderProperty();
                break;

            case ConcreteSlotValueType.Matrix3:
                property = new Matrix3ShaderProperty();
                break;

            case ConcreteSlotValueType.Matrix2:
                property = new Matrix2ShaderProperty();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            property.overrideReferenceName = matOwner.GetVariableNameForSlot(id);
            property.generatePropertyBlock = false;
            properties.AddShaderProperty(property);
        }
        public override void AddDefaultProperty(PropertyCollector properties, GenerationMode generationMode)
        {
            if (!generationMode.IsPreview())
            {
                return;
            }

            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)));
            }

            AbstractShaderProperty property;

            switch (concreteValueType)
            {
            case ConcreteSlotValueType.Vector4:
                property = new Vector4ShaderProperty();
                break;

            case ConcreteSlotValueType.Vector3:
                property = new Vector3ShaderProperty();
                break;

            case ConcreteSlotValueType.Vector2:
                property = new Vector2ShaderProperty();
                break;

            case ConcreteSlotValueType.Vector1:
                property = new Vector1ShaderProperty();
                break;

            default:
                // This shouldn't happen due to edge validation. The generated shader will
                // have errors.
                Debug.LogError($"Invalid value type {concreteValueType} passed to Vector Slot {displayName}. Value will be ignored, please plug in an edge with a vector type.");
                return;
            }

            property.overrideReferenceName = matOwner.GetVariableNameForSlot(id);
            property.generatePropertyBlock = false;
            properties.AddShaderProperty(property);
        }
コード例 #4
0
        public override void AddDefaultProperty(PropertyCollector properties, GenerationMode generationMode)
        {
            if (!generationMode.IsPreview())
            {
                return;
            }

            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)));
            }

            var property = new Vector4ShaderProperty()
            {
                overrideReferenceName = matOwner.GetVariableNameForSlot(id),
                generatePropertyBlock = false,
                value = value
            };

            properties.AddShaderProperty(property);
        }