A game about forced loneliness, made by TACStudios
at master 87 lines 2.9 kB view raw
1using System; 2using UnityEngine; 3 4namespace UnityEditor.ShaderGraph.Internal 5{ 6 [Serializable] 7 [FormerName("UnityEditor.ShaderGraph.Texture3DShaderProperty")] 8 [BlackboardInputInfo(52)] 9 public sealed class Texture3DShaderProperty : AbstractShaderProperty<SerializableTexture> 10 { 11 internal Texture3DShaderProperty() 12 { 13 displayName = "Texture3D"; 14 value = new SerializableTexture(); 15 } 16 17 public override PropertyType propertyType => PropertyType.Texture3D; 18 19 internal override bool isExposable => true; 20 internal override bool isRenamable => true; 21 22 internal string modifiableTagString => modifiable ? "" : "[NonModifiableTextureData]"; 23 24 internal override string GetPropertyBlockString() 25 { 26 return $"{hideTagString}{modifiableTagString}[NoScaleOffset]{referenceName}(\"{displayName}\", 3D) = \"white\" {{}}"; 27 } 28 29 internal override bool AllowHLSLDeclaration(HLSLDeclaration decl) => (decl != HLSLDeclaration.HybridPerInstance) && (decl != HLSLDeclaration.DoNotDeclare); 30 31 internal override void ForeachHLSLProperty(Action<HLSLProperty> action) 32 { 33 action(new HLSLProperty(HLSLType._Texture3D, referenceName, HLSLDeclaration.Global)); 34 action(new HLSLProperty(HLSLType._SamplerState, "sampler" + referenceName, HLSLDeclaration.Global)); 35 } 36 37 internal override string GetPropertyAsArgumentString(string precisionString) 38 { 39 return "UnityTexture3D " + referenceName; 40 } 41 42 internal override string GetPropertyAsArgumentStringForVFX(string precisionString) 43 { 44 return "TEXTURE3D(" + referenceName + ")"; 45 } 46 47 internal override string GetHLSLVariableName(bool isSubgraphProperty, GenerationMode mode) 48 { 49 if (isSubgraphProperty) 50 return referenceName; 51 else 52 return $"UnityBuildTexture3DStruct({referenceName})"; 53 } 54 55 [SerializeField] 56 bool m_Modifiable = true; 57 58 public bool modifiable 59 { 60 get => m_Modifiable; 61 set => m_Modifiable = value; 62 } 63 64 internal override AbstractMaterialNode ToConcreteNode() 65 { 66 return new Texture3DAssetNode { texture = value.texture as Texture3D }; 67 } 68 69 internal override PreviewProperty GetPreviewMaterialProperty() 70 { 71 return new PreviewProperty(propertyType) 72 { 73 name = referenceName, 74 textureValue = value.texture 75 }; 76 } 77 78 internal override ShaderInput Copy() 79 { 80 return new Texture3DShaderProperty() 81 { 82 displayName = displayName, 83 value = value, 84 }; 85 } 86 } 87}