Texture3DShaderProperty.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using UnityEngine;
  3. namespace UnityEditor.ShaderGraph.Internal
  4. {
  5. [Serializable]
  6. [FormerName("UnityEditor.ShaderGraph.Texture3DShaderProperty")]
  7. public sealed class Texture3DShaderProperty : AbstractShaderProperty<SerializableTexture>
  8. {
  9. internal Texture3DShaderProperty()
  10. {
  11. displayName = "Texture3D";
  12. value = new SerializableTexture();
  13. }
  14. public override PropertyType propertyType => PropertyType.Texture3D;
  15. internal override bool isBatchable => false;
  16. internal override bool isExposable => true;
  17. internal override bool isRenamable => true;
  18. internal string modifiableTagString => modifiable ? "" : "[NonModifiableTextureData]";
  19. internal override string GetPropertyBlockString()
  20. {
  21. return $"{hideTagString}{modifiableTagString}[NoScaleOffset]{referenceName}(\"{displayName}\", 3D) = \"white\" {{}}";
  22. }
  23. internal override string GetPropertyDeclarationString(string delimiter = ";")
  24. {
  25. return $"TEXTURE3D({referenceName}){delimiter} SAMPLER(sampler{referenceName}){delimiter}";
  26. }
  27. internal override string GetPropertyAsArgumentString()
  28. {
  29. return $"TEXTURE3D_PARAM({referenceName}, sampler{referenceName})";
  30. }
  31. [SerializeField]
  32. bool m_Modifiable = true;
  33. public bool modifiable
  34. {
  35. get => m_Modifiable;
  36. set => m_Modifiable = value;
  37. }
  38. internal override AbstractMaterialNode ToConcreteNode()
  39. {
  40. return new Texture3DAssetNode { texture = value.texture as Texture3D };
  41. }
  42. internal override PreviewProperty GetPreviewMaterialProperty()
  43. {
  44. return new PreviewProperty(propertyType)
  45. {
  46. name = referenceName,
  47. textureValue = value.texture
  48. };
  49. }
  50. internal override ShaderInput Copy()
  51. {
  52. return new Texture3DShaderProperty()
  53. {
  54. displayName = displayName,
  55. hidden = hidden,
  56. value = value
  57. };
  58. }
  59. }
  60. }