123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- using UnityEngine;
- using UnityEditor.ShaderGraph.Internal;
-
- namespace UnityEditor.ShaderGraph
- {
- // This whole file is regrettable.
- // However, right now we need an abstraction for MaterialSlot for use with BlockFieldDescriptors.
- // MaterialSlot is very leaky, so we cant make it public but we need BlockFieldDescriptor to be public.
- // All MaterialSlot types required by a BlockFieldDescriptor need a matching Control here.
- // We also need a corresponding case in BlockNode.AddSlot for each control.
-
- public interface IControl
- {
- ShaderGraphRequirements GetRequirements();
- }
-
- public class PositionControl : IControl
- {
- public CoordinateSpace space { get; private set; }
-
- public PositionControl(CoordinateSpace space)
- {
- this.space = space;
- }
-
- public ShaderGraphRequirements GetRequirements()
- {
- return new ShaderGraphRequirements() { requiresPosition = space.ToNeededCoordinateSpace() };
- }
- }
-
- public class NormalControl : IControl
- {
- public CoordinateSpace space { get; private set; }
-
- public NormalControl(CoordinateSpace space)
- {
- this.space = space;
- }
-
- public ShaderGraphRequirements GetRequirements()
- {
- return new ShaderGraphRequirements() { requiresNormal = space.ToNeededCoordinateSpace() };
- }
- }
-
- public class TangentControl : IControl
- {
- public CoordinateSpace space { get; private set; }
-
- public TangentControl(CoordinateSpace space)
- {
- this.space = space;
- }
-
- public ShaderGraphRequirements GetRequirements()
- {
- return new ShaderGraphRequirements() { requiresTangent = space.ToNeededCoordinateSpace() };
- }
- }
-
- public class ColorControl : IControl
- {
- public Color value { get; private set; }
- public bool hdr { get; private set; }
-
- public ColorControl(Color value, bool hdr)
- {
- this.value = value;
- this.hdr = hdr;
- }
-
- public ShaderGraphRequirements GetRequirements()
- {
- return ShaderGraphRequirements.none;
- }
- }
-
- public class ColorRGBAControl : IControl
- {
- public Color value { get; private set; }
-
- public ColorRGBAControl(Color value)
- {
- this.value = value;
- }
-
- public ShaderGraphRequirements GetRequirements()
- {
- return ShaderGraphRequirements.none;
- }
- }
-
- public class FloatControl : IControl
- {
- public float value { get; private set; }
-
- public FloatControl(float value)
- {
- this.value = value;
- }
-
- public ShaderGraphRequirements GetRequirements()
- {
- return ShaderGraphRequirements.none;
- }
- }
-
- public class Vector2Control : IControl
- {
- public Vector2 value { get; private set; }
-
- public Vector2Control(Vector2 value)
- {
- this.value = value;
- }
-
- public ShaderGraphRequirements GetRequirements()
- {
- return ShaderGraphRequirements.none;
- }
- }
-
- public class Vector3Control : IControl
- {
- public Vector3 value { get; private set; }
-
- public Vector3Control(Vector3 value)
- {
- this.value = value;
- }
-
- public ShaderGraphRequirements GetRequirements()
- {
- return ShaderGraphRequirements.none;
- }
- }
-
- public class Vector4Control : IControl
- {
- public Vector4 value { get; private set; }
-
- public Vector4Control(Vector4 value)
- {
- this.value = value;
- }
-
- public ShaderGraphRequirements GetRequirements()
- {
- return ShaderGraphRequirements.none;
- }
- }
-
- public class VertexColorControl : IControl
- {
- public Color value { get; private set; }
-
- public VertexColorControl(Color value)
- {
- this.value = value;
- }
-
- public ShaderGraphRequirements GetRequirements()
- {
- return new ShaderGraphRequirements() { requiresVertexColor = true };
- }
- }
- }
|