CubemapShaderProperty.cs 2.2 KB

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