Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEditor.Graphing;
- namespace UnityEditor.ShaderGraph
- {
- [Title("Custom", "Input", "Texture", "_CameraDepthNormalsTexture")]
- class DepthNormalsTextureNode : AbstractMaterialNode
- {
- public const int OutputSlotId = 0;
- const string kOutputSlotName = "Out";
- private string inputTexture;
- public DepthNormalsTextureNode()
- {
- name = "_CameraDepthNormalsTexture";
- inputTexture = "_CameraDepthNormalsTexture";
- UpdateNodeAfterDeserialization();
- }
- public sealed override void UpdateNodeAfterDeserialization()
- {
- AddSlot(new Texture2DMaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));
- RemoveSlotsNameNotMatching(new[] {OutputSlotId});
- }
- public override void CollectShaderProperties(PropertyCollector properties, GenerationMode generationMode)
- {
- properties.AddShaderProperty(new TextureShaderProperty
- {
- displayName = "Main Texture",
- overrideReferenceName = GetVariableNameForSlot(OutputSlotId),
- generatePropertyBlock = false
- });
- }
- public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
- {
- properties.Add(new PreviewProperty(PropertyType.Texture2D)
- {
- name = GetVariableNameForSlot(OutputSlotId),
- textureValue = Shader.GetGlobalTexture(inputTexture)
- });
- }
- public override string GetVariableNameForSlot(int slotId)
- {
- return slotId == OutputSlotId ? inputTexture : base.GetVariableNameForSlot(slotId);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement