diff --git a/Assets/Examples/Subgraph Tests.meta b/Assets/Examples/Subgraph Tests.meta new file mode 100644 index 00000000..ee312373 --- /dev/null +++ b/Assets/Examples/Subgraph Tests.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 38ac833a995a69a48ae472b6f9910a2d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Examples/Subgraph Tests/Main Graph.asset b/Assets/Examples/Subgraph Tests/Main Graph.asset new file mode 100644 index 00000000..eb023af3 --- /dev/null +++ b/Assets/Examples/Subgraph Tests/Main Graph.asset @@ -0,0 +1,741 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &-7875340718680561422 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Hidden/Mixture/Blend + m_Shader: {fileID: 4800000, guid: 5d69ff00d9a32944ea012824393d489a, type: 3} + m_ShaderKeywords: CRT_2D _REMOVENEGATIVE_ON + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _Mask_2D: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Mask_3D: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Mask_Cube: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Source_2D: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Source_3D: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Source_Cube: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Target_2D: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Target_3D: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Target_Cube: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BlendMode: 0 + - _MaskMode: 4 + - _Opacity: 1 + - _RemoveNegative: 1 + m_Colors: [] + m_BuildTextureStacks: [] +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3b113f958e0564f309164e29c24b042d, type: 3} + m_Name: Main Graph + m_EditorClassIdentifier: + serializedNodes: [] + nodes: + - id: 0 + - id: 1 + - id: 2 + - id: 3 + - id: 4 + - id: 5 + edges: + - GUID: 1384a81f-53b4-4d5f-b216-3deb2d540226 + owner: {fileID: 11400000} + inputNodeGUID: 80b20471-f979-480e-9687-ae5aaa991b12 + outputNodeGUID: a1340b7e-3380-4f7f-8559-d773e9964719 + inputFieldName: subgraphInputs + outputFieldName: sinTime + inputPortIdentifier: 0 + outputPortIdentifier: + - GUID: 46f0e39f-ad5f-493c-af9c-7fe95c631481 + owner: {fileID: 11400000} + inputNodeGUID: 80b20471-f979-480e-9687-ae5aaa991b12 + outputNodeGUID: a1340b7e-3380-4f7f-8559-d773e9964719 + inputFieldName: subgraphInputs + outputFieldName: cosTime + inputPortIdentifier: 1 + outputPortIdentifier: + - GUID: 88f64c21-2520-44c1-bcc1-d1ef01a86fd7 + owner: {fileID: 11400000} + inputNodeGUID: a045b9e4-aea5-46af-b231-97d43ea7d027 + outputNodeGUID: a1340b7e-3380-4f7f-8559-d773e9964719 + inputFieldName: subgraphInputs + outputFieldName: sinTime + inputPortIdentifier: 0 + outputPortIdentifier: + - GUID: 853a8fad-2c47-437f-b8cc-6bd918645e9c + owner: {fileID: 11400000} + inputNodeGUID: a045b9e4-aea5-46af-b231-97d43ea7d027 + outputNodeGUID: a1340b7e-3380-4f7f-8559-d773e9964719 + inputFieldName: subgraphInputs + outputFieldName: cosTime + inputPortIdentifier: 1 + outputPortIdentifier: + - GUID: 2b9bd05f-0d53-4707-aaaa-5b8030b1cc80 + owner: {fileID: 11400000} + inputNodeGUID: 5148d767-ad87-44e4-9cf9-3230bee3dddd + outputNodeGUID: a045b9e4-aea5-46af-b231-97d43ea7d027 + inputFieldName: materialInputs + outputFieldName: subgraphOutputs + inputPortIdentifier: _Source_2D + outputPortIdentifier: 0 + - GUID: 76a55201-936f-4ea7-b85f-0d0764fb0d64 + owner: {fileID: 11400000} + inputNodeGUID: 5148d767-ad87-44e4-9cf9-3230bee3dddd + outputNodeGUID: 80b20471-f979-480e-9687-ae5aaa991b12 + inputFieldName: materialInputs + outputFieldName: subgraphOutputs + inputPortIdentifier: _Target_2D + outputPortIdentifier: 0 + - GUID: 2db5ed57-a000-49d9-8b56-2be2e2360533 + owner: {fileID: 11400000} + inputNodeGUID: 691aa737-9a89-40dd-b56d-201a248e396d + outputNodeGUID: 5148d767-ad87-44e4-9cf9-3230bee3dddd + inputFieldName: outputTextureSettings + outputFieldName: output + inputPortIdentifier: Main Texture + outputPortIdentifier: output + - GUID: 7b954cac-7843-4c78-8b92-957c5c43ccb9 + owner: {fileID: 11400000} + inputNodeGUID: 5148d767-ad87-44e4-9cf9-3230bee3dddd + outputNodeGUID: 2d310966-d166-4ec2-8941-758f6cc902e9 + inputFieldName: materialInputs + outputFieldName: texture + inputPortIdentifier: _Mask_2D + outputPortIdentifier: + groups: [] + stackNodes: [] + pinnedElements: + - position: + serializedVersion: 2 + x: 0 + y: 99 + width: 244 + height: 461 + opened: 0 + editorType: + serializedType: Mixture.MixtureParameterView, Unity.ShaderGraph.GraphicsTests, + Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + exposedParameters: [] + serializedParameterList: [] + stickyNotes: [] + nodeInspectorReference: {fileID: 0} + position: {x: 513, y: 329, z: 0} + scale: {x: 0.43232757, y: 0.43232757, z: 1} + version: 1 + type: 1 + realtimePreview: 1 + isRealtime: 0 + isParameterViewOpen: 0 + embedInBuild: 0 + defaultNodeInheritanceMode: -2 + objectReferences: + - {fileID: 3859369412456319183} + - {fileID: -7875340718680561422} + variants: [] + _mainOutputTexture: {fileID: 2582063969297267981} + _outputTextures: + - {fileID: 2582063969297267981} + - {fileID: 2582063969297267981} + settings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 256 + height: 256 + depth: 256 + potSize: 256 + sizeMode: 1 + dimension: 2 + outputChannels: 1 + outputPrecision: 3 + editFlags: 128 + doubleBuffered: 0 + wrapMode: 0 + filterMode: 0 + refreshMode: 2 + period: 17 + references: + version: 1 + 00000000: + type: {class: OutputNode, ns: Mixture, asm: Mixture.Runtime} + data: + nodeCustomName: + GUID: 691aa737-9a89-40dd-b56d-201a248e396d + computeOrder: 5 + position: + serializedVersion: 2 + x: 139.46619 + y: -220 + width: 350 + height: 500 + expanded: 0 + debug: 0 + nodeLock: 0 + settings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 512 + height: 512 + depth: 1 + potSize: 512 + sizeMode: -2 + dimension: -2 + outputChannels: -2 + outputPrecision: -2 + editFlags: 471 + doubleBuffered: 0 + wrapMode: -2 + filterMode: -2 + refreshMode: 0 + period: 0 + rtSettings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 0 + height: 0 + depth: 0 + potSize: 0 + sizeMode: 0 + dimension: 0 + outputChannels: 0 + outputPrecision: 0 + editFlags: 0 + doubleBuffered: 0 + wrapMode: 0 + filterMode: 0 + refreshMode: 0 + period: 0 + isPreviewCollapsed: 0 + previewMode: 7 + previewSRGB: 0 + previewMip: 0 + previewVisible: 1 + previewEV100: 0 + previewSlice: 0 + isPinned: 0 + outputTextureSettings: + - inputTexture: {fileID: 0} + name: Main Texture + enableCompression: 1 + compressionFormat: 12 + compressionQuality: 100 + hasMipMaps: 0 + isMain: 1 + enableConversion: 0 + conversionFormat: 0 + sRGB: 0 + finalCopyMaterial: {fileID: 3859369412456319183} + _selectedPreviewIndex: 0 + 00000001: + type: {class: SubgraphNode, ns: Mixture, asm: Mixture.Runtime} + data: + nodeCustomName: + GUID: 80b20471-f979-480e-9687-ae5aaa991b12 + computeOrder: 2 + position: + serializedVersion: 2 + x: -454.334 + y: 197.27237 + width: 250 + height: 417 + expanded: 0 + debug: 0 + nodeLock: 0 + settings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 1024 + height: 1024 + depth: 1 + potSize: 0 + sizeMode: -2 + dimension: -2 + outputChannels: -2 + outputPrecision: -2 + editFlags: -257 + doubleBuffered: 0 + wrapMode: -2 + filterMode: -2 + refreshMode: 0 + period: 0 + rtSettings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 0 + height: 0 + depth: 0 + potSize: 0 + sizeMode: 0 + dimension: 0 + outputChannels: 0 + outputPrecision: 0 + editFlags: 0 + doubleBuffered: 0 + wrapMode: 0 + filterMode: 0 + refreshMode: 0 + period: 0 + isPreviewCollapsed: 0 + previewMode: 7 + previewSRGB: 0 + previewMip: 0 + previewVisible: 1 + previewEV100: 0 + previewSlice: 0 + isPinned: 0 + subgraph: {fileID: 11400000, guid: d446ae005dee81646884ad1b8c344225, type: 2} + subgraphTexture: {fileID: 4256279983331766550, guid: d446ae005dee81646884ad1b8c344225, + type: 2} + previewOutputIndex: 0 + 00000002: + type: {class: TimeNode, ns: Mixture, asm: Mixture.Runtime} + data: + nodeCustomName: + GUID: a1340b7e-3380-4f7f-8559-d773e9964719 + computeOrder: 0 + position: + serializedVersion: 2 + x: -677.94 + y: -220.00003 + width: 120 + height: 176 + expanded: 0 + debug: 0 + nodeLock: 0 + settings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 1024 + height: 1024 + depth: 1 + potSize: 0 + sizeMode: -2 + dimension: -2 + outputChannels: -2 + outputPrecision: -2 + editFlags: -257 + doubleBuffered: 0 + wrapMode: -2 + filterMode: -2 + refreshMode: 0 + period: 0 + rtSettings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 0 + height: 0 + depth: 0 + potSize: 0 + sizeMode: 0 + dimension: 0 + outputChannels: 0 + outputPrecision: 0 + editFlags: 0 + doubleBuffered: 0 + wrapMode: 0 + filterMode: 0 + refreshMode: 0 + period: 0 + isPreviewCollapsed: 0 + previewMode: 15 + previewSRGB: 0 + previewMip: 0 + previewVisible: 1 + previewEV100: 0 + previewSlice: 0 + isPinned: 0 + 00000003: + type: {class: SubgraphNode, ns: Mixture, asm: Mixture.Runtime} + data: + nodeCustomName: + GUID: a045b9e4-aea5-46af-b231-97d43ea7d027 + computeOrder: 1 + position: + serializedVersion: 2 + x: -454 + y: -219.99994 + width: 250 + height: 417 + expanded: 0 + debug: 0 + nodeLock: 0 + settings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 1024 + height: 1024 + depth: 1 + potSize: 0 + sizeMode: -2 + dimension: -2 + outputChannels: -2 + outputPrecision: -2 + editFlags: -257 + doubleBuffered: 0 + wrapMode: -2 + filterMode: -2 + refreshMode: 0 + period: 0 + rtSettings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 0 + height: 0 + depth: 0 + potSize: 0 + sizeMode: 0 + dimension: 0 + outputChannels: 0 + outputPrecision: 0 + editFlags: 0 + doubleBuffered: 0 + wrapMode: 0 + filterMode: 0 + refreshMode: 0 + period: 0 + isPreviewCollapsed: 0 + previewMode: 7 + previewSRGB: 0 + previewMip: 0 + previewVisible: 1 + previewEV100: 0 + previewSlice: 0 + isPinned: 0 + subgraph: {fileID: 11400000, guid: 2fac220b3e4d4e44ca84f14e3fb933ec, type: 2} + subgraphTexture: {fileID: -8981516031013929624, guid: 2fac220b3e4d4e44ca84f14e3fb933ec, + type: 2} + previewOutputIndex: 0 + 00000004: + type: {class: BlendNode, ns: Mixture, asm: Mixture.Runtime} + data: + nodeCustomName: + GUID: 5148d767-ad87-44e4-9cf9-3230bee3dddd + computeOrder: 4 + position: + serializedVersion: 2 + x: -110.533775 + y: -220 + width: 250 + height: 503 + expanded: 0 + debug: 0 + nodeLock: 0 + settings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 1024 + height: 1024 + depth: 1 + potSize: 0 + sizeMode: -2 + dimension: -2 + outputChannels: -2 + outputPrecision: -2 + editFlags: -257 + doubleBuffered: 0 + wrapMode: -2 + filterMode: -2 + refreshMode: 0 + period: 0 + rtSettings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 0 + height: 0 + depth: 0 + potSize: 0 + sizeMode: 0 + dimension: 0 + outputChannels: 0 + outputPrecision: 0 + editFlags: 0 + doubleBuffered: 0 + wrapMode: 0 + filterMode: 0 + refreshMode: 0 + period: 0 + isPreviewCollapsed: 0 + previewMode: 7 + previewSRGB: 0 + previewMip: 0 + previewVisible: 1 + previewEV100: 0 + previewSlice: 0 + isPinned: 0 + output: {fileID: 0} + shader: {fileID: 4800000, guid: 5d69ff00d9a32944ea012824393d489a, type: 3} + material: {fileID: -7875340718680561422} + exposedProperties: + - displayName: Source + referenceName: _Source_2D + tooltip: + type: + serializedType: UnityEngine.Texture2D, UnityEngine.CoreModule, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + - displayName: Target + referenceName: _Target_2D + tooltip: + type: + serializedType: UnityEngine.Texture2D, UnityEngine.CoreModule, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + - displayName: Mask + referenceName: _Mask_2D + tooltip: + type: + serializedType: UnityEngine.Texture2D, UnityEngine.CoreModule, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + - displayName: Opacity + referenceName: _Opacity + tooltip: Opacity of the Blend, 0 means that only Source is visible and + 1 that only Target is visible + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Blend Mode + referenceName: _BlendMode + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Mask Mode + referenceName: _MaskMode + tooltip: Select which channel is used to sample the mask value + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Clamp Negative + referenceName: _RemoveNegative + tooltip: Avoids having negative values in the output texture + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + shaderGUID: 5d69ff00d9a32944ea012824393d489a + 00000005: + type: {class: GradientNode, ns: Mixture, asm: Mixture.Runtime} + data: + nodeCustomName: + GUID: 2d310966-d166-4ec2-8941-758f6cc902e9 + computeOrder: 3 + position: + serializedVersion: 2 + x: -453.99985 + y: 613.9999 + width: 250 + height: 114 + expanded: 0 + debug: 0 + nodeLock: 0 + settings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 1024 + height: 1024 + depth: 1 + potSize: 0 + sizeMode: -2 + dimension: -2 + outputChannels: -2 + outputPrecision: -2 + editFlags: -257 + doubleBuffered: 0 + wrapMode: -2 + filterMode: -2 + refreshMode: 0 + period: 0 + rtSettings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 0 + height: 0 + depth: 0 + potSize: 0 + sizeMode: 0 + dimension: 0 + outputChannels: 0 + outputPrecision: 0 + editFlags: 0 + doubleBuffered: 0 + wrapMode: 0 + filterMode: 0 + refreshMode: 0 + period: 0 + isPreviewCollapsed: 0 + previewMode: 15 + previewSRGB: 0 + previewMip: 0 + previewVisible: 1 + previewEV100: 0 + previewSlice: 0 + isPinned: 0 + texture: {fileID: 0} + gradient: + serializedVersion: 2 + key0: {r: 1, g: 1, b: 1, a: 0} + key1: {r: 1, g: 1, b: 1, a: 1} + key2: {r: 0, g: 0, b: 0, a: 0} + key3: {r: 0, g: 0, b: 0, a: 0} + key4: {r: 0, g: 0, b: 0, a: 0} + key5: {r: 0, g: 0, b: 0, a: 0} + key6: {r: 0, g: 0, b: 0, a: 0} + key7: {r: 0, g: 0, b: 0, a: 0} + ctime0: 0 + ctime1: 65535 + ctime2: 0 + ctime3: 0 + ctime4: 0 + ctime5: 0 + ctime6: 0 + ctime7: 0 + atime0: 0 + atime1: 65535 + atime2: 0 + atime3: 0 + atime4: 0 + atime5: 0 + atime6: 0 + atime7: 0 + m_Mode: 0 + m_NumColorKeys: 2 + m_NumAlphaKeys: 2 +--- !u!86 &2582063969297267981 +CustomRenderTexture: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Main Graph + m_ImageContentsHash: + serializedVersion: 2 + Hash: 00000000000000000000000000000000 + m_ForcedFallbackFormat: 4 + m_DownscaleFallback: 0 + m_IsAlphaChannelOptional: 0 + serializedVersion: 3 + m_Width: 256 + m_Height: 256 + m_AntiAliasing: 1 + m_MipCount: -1 + m_DepthFormat: 0 + m_ColorFormat: 48 + m_MipMap: 0 + m_GenerateMips: 0 + m_SRGB: 0 + m_UseDynamicScale: 0 + m_BindMS: 0 + m_EnableCompatibleFormat: 1 + m_TextureSettings: + serializedVersion: 2 + m_FilterMode: 0 + m_Aniso: 1 + m_MipBias: 0 + m_WrapU: 0 + m_WrapV: 0 + m_WrapW: 0 + m_Dimension: 2 + m_VolumeDepth: 1 + m_Material: {fileID: 3859369412456319183} + m_InitSource: 0 + m_InitMaterial: {fileID: 0} + m_InitColor: {r: 1, g: 1, b: 1, a: 1} + m_InitTexture: {fileID: 0} + m_UpdateMode: 1 + m_InitializationMode: 2 + m_UpdateZoneSpace: 0 + m_CurrentUpdateZoneSpace: 0 + m_UpdateZones: [] + m_UpdatePeriod: 0.017 + m_ShaderPass: 0 + m_CubemapFaceMask: 4294967295 + m_DoubleBuffered: 0 + m_WrapUpdateZones: 0 +--- !u!21 &3859369412456319183 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Hidden/Mixture/FinalCopy + m_Shader: {fileID: 4800000, guid: 513c040fbfb854aebb92cf147e30125a, type: 3} + m_ShaderKeywords: CRT_2D + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _Source_2D: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Source_3D: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Source_Cube: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: [] + m_Colors: [] + m_BuildTextureStacks: [] diff --git a/Assets/Examples/Subgraph Tests/Main Graph.asset.meta b/Assets/Examples/Subgraph Tests/Main Graph.asset.meta new file mode 100644 index 00000000..330bfec8 --- /dev/null +++ b/Assets/Examples/Subgraph Tests/Main Graph.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e6d79df5c728a0e498b847cfc07825e2 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2582063969297267981 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Examples/Subgraph Tests/Subgraph 1.asset b/Assets/Examples/Subgraph Tests/Subgraph 1.asset new file mode 100644 index 00000000..86edf788 --- /dev/null +++ b/Assets/Examples/Subgraph Tests/Subgraph 1.asset @@ -0,0 +1,731 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!86 &-8981516031013929624 +CustomRenderTexture: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Subgraph 1 + m_ImageContentsHash: + serializedVersion: 2 + Hash: 00000000000000000000000000000000 + m_ForcedFallbackFormat: 4 + m_DownscaleFallback: 0 + m_IsAlphaChannelOptional: 0 + serializedVersion: 3 + m_Width: 256 + m_Height: 256 + m_AntiAliasing: 1 + m_MipCount: -1 + m_DepthFormat: 0 + m_ColorFormat: 48 + m_MipMap: 0 + m_GenerateMips: 0 + m_SRGB: 0 + m_UseDynamicScale: 0 + m_BindMS: 0 + m_EnableCompatibleFormat: 1 + m_TextureSettings: + serializedVersion: 2 + m_FilterMode: 0 + m_Aniso: 1 + m_MipBias: 0 + m_WrapU: 0 + m_WrapV: 0 + m_WrapW: 0 + m_Dimension: 2 + m_VolumeDepth: 1 + m_Material: {fileID: -5317009649483353877} + m_InitSource: 0 + m_InitMaterial: {fileID: 0} + m_InitColor: {r: 1, g: 1, b: 1, a: 1} + m_InitTexture: {fileID: 0} + m_UpdateMode: 1 + m_InitializationMode: 2 + m_UpdateZoneSpace: 0 + m_CurrentUpdateZoneSpace: 0 + m_UpdateZones: [] + m_UpdatePeriod: 0.017 + m_ShaderPass: 0 + m_CubemapFaceMask: 4294967295 + m_DoubleBuffered: 0 + m_WrapUpdateZones: 0 +--- !u!21 &-6859354532008877545 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Hidden/Mixture/RidgedCellularNoise + m_Shader: {fileID: 4800000, guid: 709dbd2e7ab678c4cb23bcf7fcf6fb2f, type: 3} + m_ShaderKeywords: CRT_2D USE_CUSTOM_UV _TILINGMODE_TILED + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _UV_2D: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _UV_3D: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _UV_Cube: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _CellSize: 1 + - _CellsModeA: 0 + - _CellsModeB: 0 + - _CellsModeG: 0 + - _CellsModeR: 0 + - _Channels: 0 + - _DistanceMode: 0 + - _Frequency: 1 + - _Lacunarity: 1.5 + - _Octaves: 4 + - _Persistance: 1 + - _Seed: 42 + - _TilingMode: 1 + - _UVMode: 0 + m_Colors: + - _OutputRange: {r: -1, g: 1, b: 0, a: 0} + m_BuildTextureStacks: [] +--- !u!21 &-5317009649483353877 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Hidden/Mixture/FinalCopy + m_Shader: {fileID: 4800000, guid: 513c040fbfb854aebb92cf147e30125a, type: 3} + m_ShaderKeywords: CRT_2D + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _Source_2D: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Source_3D: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Source_Cube: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: [] + m_Colors: [] + m_BuildTextureStacks: [] +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3b113f958e0564f309164e29c24b042d, type: 3} + m_Name: Subgraph 1 + m_EditorClassIdentifier: + serializedNodes: [] + nodes: + - id: 0 + - id: 1 + - id: 2 + - id: 3 + - id: 4 + - id: 5 + edges: + - GUID: c127e920-a9d3-4f91-82a3-d77704e2abc9 + owner: {fileID: 11400000} + inputNodeGUID: 691aa737-9a89-40dd-b56d-201a248e396d + outputNodeGUID: d9625908-fafa-495d-9c48-3674d3b83078 + inputFieldName: outputTextureSettings + outputFieldName: output + inputPortIdentifier: Main Texture + outputPortIdentifier: output + - GUID: 32ae602b-57fb-490e-9e70-309f7dcc1369 + owner: {fileID: 11400000} + inputNodeGUID: d9625908-fafa-495d-9c48-3674d3b83078 + outputNodeGUID: 7c264d5b-1c55-4c06-abe9-62e5b25032a8 + inputFieldName: materialInputs + outputFieldName: output + inputPortIdentifier: _UV_2D + outputPortIdentifier: output + - GUID: 6746679b-1759-4d43-8511-624dd53f133d + owner: {fileID: 11400000} + inputNodeGUID: 1f93e02b-cf49-403c-9a31-7a5a0c1cd579 + outputNodeGUID: e48d9bab-0980-4301-b44a-6d8a3491d6a1 + inputFieldName: X + outputFieldName: output + inputPortIdentifier: + outputPortIdentifier: output + - GUID: 42a4f57f-1eea-415e-963d-a3a1145c530c + owner: {fileID: 11400000} + inputNodeGUID: 1f93e02b-cf49-403c-9a31-7a5a0c1cd579 + outputNodeGUID: b8605e27-64e6-47cc-827e-2f80d5d575ea + inputFieldName: Y + outputFieldName: output + inputPortIdentifier: + outputPortIdentifier: output + - GUID: 9df10754-26b2-463a-83b5-bcc7ed2679dd + owner: {fileID: 11400000} + inputNodeGUID: 7c264d5b-1c55-4c06-abe9-62e5b25032a8 + outputNodeGUID: 1f93e02b-cf49-403c-9a31-7a5a0c1cd579 + inputFieldName: materialInputs + outputFieldName: vector + inputPortIdentifier: _Bias + outputPortIdentifier: + groups: [] + stackNodes: [] + pinnedElements: + - position: + serializedVersion: 2 + x: 0 + y: 99 + width: 244 + height: 461 + opened: 1 + editorType: + serializedType: Mixture.MixtureParameterView, Unity.ShaderGraph.GraphicsTests, + Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + exposedParameters: + - id: 6 + - id: 7 + serializedParameterList: [] + stickyNotes: [] + nodeInspectorReference: {fileID: 0} + position: {x: 1165, y: 174, z: 0} + scale: {x: 0.7561437, y: 0.7561437, z: 1} + version: 1 + type: 1 + realtimePreview: 1 + isRealtime: 0 + isParameterViewOpen: 1 + embedInBuild: 0 + defaultNodeInheritanceMode: -2 + objectReferences: + - {fileID: -5317009649483353877} + - {fileID: -6859354532008877545} + - {fileID: 6317978329802964027} + variants: [] + _mainOutputTexture: {fileID: -8981516031013929624} + _outputTextures: + - {fileID: -8981516031013929624} + - {fileID: -8981516031013929624} + settings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 256 + height: 256 + depth: 256 + potSize: 256 + sizeMode: 1 + dimension: 2 + outputChannels: 1 + outputPrecision: 3 + editFlags: 128 + doubleBuffered: 0 + wrapMode: 0 + filterMode: 0 + refreshMode: 2 + period: 17 + references: + version: 1 + 00000000: + type: {class: OutputNode, ns: Mixture, asm: Mixture.Runtime} + data: + nodeCustomName: + GUID: 691aa737-9a89-40dd-b56d-201a248e396d + computeOrder: 5 + position: + serializedVersion: 2 + x: -191.00006 + y: -51.00003 + width: 350 + height: 500 + expanded: 0 + debug: 0 + nodeLock: 0 + settings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 512 + height: 512 + depth: 1 + potSize: 512 + sizeMode: -2 + dimension: -2 + outputChannels: -2 + outputPrecision: -2 + editFlags: 471 + doubleBuffered: 0 + wrapMode: -2 + filterMode: -2 + refreshMode: 0 + period: 0 + rtSettings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 0 + height: 0 + depth: 0 + potSize: 0 + sizeMode: 0 + dimension: 0 + outputChannels: 0 + outputPrecision: 0 + editFlags: 0 + doubleBuffered: 0 + wrapMode: 0 + filterMode: 0 + refreshMode: 0 + period: 0 + isPreviewCollapsed: 0 + previewMode: 7 + previewSRGB: 0 + previewMip: 0 + previewVisible: 1 + previewEV100: 0 + previewSlice: 0 + isPinned: 0 + outputTextureSettings: + - inputTexture: {fileID: 0} + name: Main Texture + enableCompression: 1 + compressionFormat: 12 + compressionQuality: 100 + hasMipMaps: 0 + isMain: 1 + enableConversion: 0 + conversionFormat: 0 + sRGB: 1 + finalCopyMaterial: {fileID: -5317009649483353877} + _selectedPreviewIndex: 0 + 00000001: + type: {class: RidgedCellularNoise, ns: Mixture, asm: Mixture.Runtime} + data: + nodeCustomName: + GUID: d9625908-fafa-495d-9c48-3674d3b83078 + computeOrder: 4 + position: + serializedVersion: 2 + x: -441.21478 + y: -50.99997 + width: 250 + height: 582 + expanded: 0 + debug: 0 + nodeLock: 0 + settings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 1024 + height: 1024 + depth: 1 + potSize: 0 + sizeMode: -2 + dimension: -2 + outputChannels: -2 + outputPrecision: -2 + editFlags: -257 + doubleBuffered: 0 + wrapMode: -2 + filterMode: -2 + refreshMode: 0 + period: 0 + rtSettings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 0 + height: 0 + depth: 0 + potSize: 0 + sizeMode: 0 + dimension: 0 + outputChannels: 0 + outputPrecision: 0 + editFlags: 0 + doubleBuffered: 0 + wrapMode: 0 + filterMode: 0 + refreshMode: 0 + period: 0 + isPreviewCollapsed: 0 + previewMode: 7 + previewSRGB: 0 + previewMip: 0 + previewVisible: 1 + previewEV100: 0 + previewSlice: 0 + isPinned: 0 + output: {fileID: 0} + shader: {fileID: 4800000, guid: 709dbd2e7ab678c4cb23bcf7fcf6fb2f, type: 3} + material: {fileID: -6859354532008877545} + exposedProperties: + - displayName: UVs + referenceName: _UV_2D + tooltip: + type: + serializedType: UnityEngine.Texture2D, UnityEngine.CoreModule, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + - displayName: Tiling Mode + referenceName: _TilingMode + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: UV Mode + referenceName: _UVMode + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Distance Mode + referenceName: _DistanceMode + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Output Range + referenceName: _OutputRange + tooltip: + type: + serializedType: UnityEngine.Vector4, UnityEngine.CoreModule, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + - displayName: Lacunarity + referenceName: _Lacunarity + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Frequency + referenceName: _Frequency + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Persistance + referenceName: _Persistance + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Octaves + referenceName: _Octaves + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Cell Size + referenceName: _CellSize + tooltip: Act as a multiplier for the distance function + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Seed + referenceName: _Seed + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Channels + referenceName: _Channels + tooltip: Select how many noise to genereate and on which channel. The more + different channel you use the more expensive it is (max 4 noise evaluation). + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Cells Mode R + referenceName: _CellsModeR + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Cells Mode G + referenceName: _CellsModeG + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Cells Mode B + referenceName: _CellsModeB + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Cells Mode A + referenceName: _CellsModeA + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + shaderGUID: 709dbd2e7ab678c4cb23bcf7fcf6fb2f + 00000002: + type: {class: UVNode, ns: Mixture, asm: Mixture.Runtime} + data: + nodeCustomName: + GUID: 7c264d5b-1c55-4c06-abe9-62e5b25032a8 + computeOrder: 3 + position: + serializedVersion: 2 + x: -691.00006 + y: -51.00003 + width: 250 + height: 415 + expanded: 0 + debug: 0 + nodeLock: 0 + settings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 1024 + height: 1024 + depth: 1 + potSize: 0 + sizeMode: -2 + dimension: -2 + outputChannels: -2 + outputPrecision: -2 + editFlags: -257 + doubleBuffered: 0 + wrapMode: -2 + filterMode: -2 + refreshMode: 0 + period: 0 + rtSettings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 0 + height: 0 + depth: 0 + potSize: 0 + sizeMode: 0 + dimension: 0 + outputChannels: 0 + outputPrecision: 0 + editFlags: 0 + doubleBuffered: 0 + wrapMode: 0 + filterMode: 0 + refreshMode: 0 + period: 0 + isPreviewCollapsed: 0 + previewMode: 15 + previewSRGB: 0 + previewMip: 0 + previewVisible: 1 + previewEV100: 0 + previewSlice: 0 + isPinned: 0 + output: {fileID: 0} + shader: {fileID: 4800000, guid: 0e57459cc2eca8e4eb3e062b8ed60321, type: 3} + material: {fileID: 6317978329802964027} + exposedProperties: + - displayName: UV Scale + referenceName: _Scale + tooltip: + type: + serializedType: UnityEngine.Vector4, UnityEngine.CoreModule, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + - displayName: UV Bias + referenceName: _Bias + tooltip: + type: + serializedType: UnityEngine.Vector4, UnityEngine.CoreModule, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + shaderGUID: 0e57459cc2eca8e4eb3e062b8ed60321 + 00000003: + type: {class: ParameterNode, ns: GraphProcessor, asm: com.alelievr.NodeGraphProcessor.Runtime} + data: + nodeCustomName: + GUID: e48d9bab-0980-4301-b44a-6d8a3491d6a1 + computeOrder: 1 + position: + serializedVersion: 2 + x: -1001.6452 + y: -51.00003 + width: 97 + height: 37 + expanded: 0 + debug: 0 + nodeLock: 0 + parameterGUID: 9b709eb3-f79a-4561-8958-7d9a65fe10a6 + accessor: 0 + 00000004: + type: {class: MakeVectorNode, ns: Mixture, asm: Mixture.Runtime} + data: + nodeCustomName: + GUID: 1f93e02b-cf49-403c-9a31-7a5a0c1cd579 + computeOrder: 2 + position: + serializedVersion: 2 + x: -867.4502 + y: -51.00003 + width: 150 + height: 152 + expanded: 0 + debug: 0 + nodeLock: 0 + settings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 1024 + height: 1024 + depth: 1 + potSize: 0 + sizeMode: -2 + dimension: -2 + outputChannels: -2 + outputPrecision: -2 + editFlags: -257 + doubleBuffered: 0 + wrapMode: -2 + filterMode: -2 + refreshMode: 0 + period: 0 + rtSettings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 0 + height: 0 + depth: 0 + potSize: 0 + sizeMode: 0 + dimension: 0 + outputChannels: 0 + outputPrecision: 0 + editFlags: 0 + doubleBuffered: 0 + wrapMode: 0 + filterMode: 0 + refreshMode: 0 + period: 0 + isPreviewCollapsed: 0 + previewMode: 15 + previewSRGB: 0 + previewMip: 0 + previewVisible: 1 + previewEV100: 0 + previewSlice: 0 + isPinned: 0 + X: -0.24913323 + Y: 0.9684692 + Z: 0 + W: 0 + vector: {x: -0.24913323, y: 0.9684692, z: 0, w: 0} + 00000005: + type: {class: ParameterNode, ns: GraphProcessor, asm: com.alelievr.NodeGraphProcessor.Runtime} + data: + nodeCustomName: + GUID: b8605e27-64e6-47cc-827e-2f80d5d575ea + computeOrder: 0 + position: + serializedVersion: 2 + x: -1001.6452 + y: -14.000036 + width: 97 + height: 37 + expanded: 0 + debug: 0 + nodeLock: 0 + parameterGUID: 0fdd7be4-ae01-48aa-a1ff-bd58687894fa + accessor: 0 + 00000006: + type: {class: FloatParameter, ns: GraphProcessor, asm: com.alelievr.NodeGraphProcessor.Runtime} + data: + guid: 9b709eb3-f79a-4561-8958-7d9a65fe10a6 + name: Translate X + type: + serializedValue: + serializedType: + serializedName: + serializedValue: + input: 1 + settings: + id: 8 + val: -0.24913323 + 00000007: + type: {class: FloatParameter, ns: GraphProcessor, asm: com.alelievr.NodeGraphProcessor.Runtime} + data: + guid: 0fdd7be4-ae01-48aa-a1ff-bd58687894fa + name: Translate Y + type: + serializedValue: + serializedType: + serializedName: + serializedValue: + input: 1 + settings: + id: 9 + val: 0.9684692 + 00000008: + type: {class: FloatParameter/FloatSettings, ns: GraphProcessor, asm: com.alelievr.NodeGraphProcessor.Runtime} + data: + isHidden: 0 + expanded: 0 + guid: 9b709eb3-f79a-4561-8958-7d9a65fe10a6 + mode: 0 + min: 0 + max: 1 + 00000009: + type: {class: FloatParameter/FloatSettings, ns: GraphProcessor, asm: com.alelievr.NodeGraphProcessor.Runtime} + data: + isHidden: 0 + expanded: 0 + guid: 0fdd7be4-ae01-48aa-a1ff-bd58687894fa + mode: 0 + min: 0 + max: 1 +--- !u!21 &6317978329802964027 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Hidden/Mixture/UV + m_Shader: {fileID: 4800000, guid: 0e57459cc2eca8e4eb3e062b8ed60321, type: 3} + m_ShaderKeywords: CRT_2D + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: [] + m_Floats: [] + m_Colors: + - _Bias: {r: -0.24913323, g: 0.9684692, b: 0, a: 0} + - _Scale: {r: 2, g: 2, b: 1, a: 0} + m_BuildTextureStacks: [] diff --git a/Assets/Examples/Subgraph Tests/Subgraph 1.asset.meta b/Assets/Examples/Subgraph Tests/Subgraph 1.asset.meta new file mode 100644 index 00000000..5e586369 --- /dev/null +++ b/Assets/Examples/Subgraph Tests/Subgraph 1.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2fac220b3e4d4e44ca84f14e3fb933ec +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: -8981516031013929624 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Examples/Subgraph Tests/Subgraph 2.asset b/Assets/Examples/Subgraph Tests/Subgraph 2.asset new file mode 100644 index 00000000..30fcae29 --- /dev/null +++ b/Assets/Examples/Subgraph Tests/Subgraph 2.asset @@ -0,0 +1,689 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3b113f958e0564f309164e29c24b042d, type: 3} + m_Name: Subgraph 2 + m_EditorClassIdentifier: + serializedNodes: [] + nodes: + - id: 0 + - id: 1 + - id: 2 + - id: 3 + - id: 4 + - id: 5 + edges: + - GUID: 0d196eb0-5c4c-4c50-a338-e78cebc405c4 + owner: {fileID: 11400000} + inputNodeGUID: 691aa737-9a89-40dd-b56d-201a248e396d + outputNodeGUID: 45b55e43-50ed-49df-b940-105b197c4bb0 + inputFieldName: outputTextureSettings + outputFieldName: output + inputPortIdentifier: Main Texture + outputPortIdentifier: output + - GUID: 784e3fa9-773d-4752-b438-affcaad95ab5 + owner: {fileID: 11400000} + inputNodeGUID: 45b55e43-50ed-49df-b940-105b197c4bb0 + outputNodeGUID: 3de26369-3ab3-4da4-8025-5953a99e2ead + inputFieldName: materialInputs + outputFieldName: output + inputPortIdentifier: _UV_2D + outputPortIdentifier: output + - GUID: 764e4ba9-77d2-4e01-a3db-23202ddb4507 + owner: {fileID: 11400000} + inputNodeGUID: fa002829-debb-4c60-8046-d99e4d4ea4b2 + outputNodeGUID: 85d5714d-9337-4353-969a-58eb527c69ab + inputFieldName: X + outputFieldName: output + inputPortIdentifier: + outputPortIdentifier: output + - GUID: adce2bca-64cc-4cc0-9421-5e1058787651 + owner: {fileID: 11400000} + inputNodeGUID: fa002829-debb-4c60-8046-d99e4d4ea4b2 + outputNodeGUID: f00f78ea-136b-48bd-9ee7-20db0071266e + inputFieldName: Y + outputFieldName: output + inputPortIdentifier: + outputPortIdentifier: output + - GUID: dcb839b3-dde9-4974-b7eb-d46ef77ec85c + owner: {fileID: 11400000} + inputNodeGUID: 3de26369-3ab3-4da4-8025-5953a99e2ead + outputNodeGUID: fa002829-debb-4c60-8046-d99e4d4ea4b2 + inputFieldName: materialInputs + outputFieldName: vector + inputPortIdentifier: _Bias + outputPortIdentifier: + groups: [] + stackNodes: [] + pinnedElements: + - position: + serializedVersion: 2 + x: 0 + y: 99 + width: 244 + height: 461 + opened: 1 + editorType: + serializedType: Mixture.MixtureParameterView, Unity.ShaderGraph.GraphicsTests, + Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + exposedParameters: + - id: 6 + - id: 7 + serializedParameterList: [] + stickyNotes: [] + nodeInspectorReference: {fileID: 0} + position: {x: 847, y: 77, z: 0} + scale: {x: 0.65751624, y: 0.65751624, z: 1} + version: 1 + type: 1 + realtimePreview: 0 + isRealtime: 0 + isParameterViewOpen: 1 + embedInBuild: 0 + defaultNodeInheritanceMode: -2 + objectReferences: + - {fileID: 4652733402955201651} + - {fileID: 5249714637275404893} + - {fileID: 8054274073769734054} + variants: [] + _mainOutputTexture: {fileID: 4256279983331766550} + _outputTextures: + - {fileID: 4256279983331766550} + - {fileID: 4256279983331766550} + settings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 256 + height: 256 + depth: 256 + potSize: 256 + sizeMode: 1 + dimension: 2 + outputChannels: 1 + outputPrecision: 3 + editFlags: 128 + doubleBuffered: 0 + wrapMode: 0 + filterMode: 0 + refreshMode: 0 + period: 17 + references: + version: 1 + 00000000: + type: {class: OutputNode, ns: Mixture, asm: Mixture.Runtime} + data: + nodeCustomName: + GUID: 691aa737-9a89-40dd-b56d-201a248e396d + computeOrder: 5 + position: + serializedVersion: 2 + x: -42.26087 + y: -44.000004 + width: 350 + height: 500 + expanded: 0 + debug: 0 + nodeLock: 0 + settings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 512 + height: 512 + depth: 1 + potSize: 512 + sizeMode: -2 + dimension: -2 + outputChannels: -2 + outputPrecision: -2 + editFlags: 471 + doubleBuffered: 0 + wrapMode: -2 + filterMode: -2 + refreshMode: 0 + period: 0 + rtSettings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 0 + height: 0 + depth: 0 + potSize: 0 + sizeMode: 0 + dimension: 0 + outputChannels: 0 + outputPrecision: 0 + editFlags: 0 + doubleBuffered: 0 + wrapMode: 0 + filterMode: 0 + refreshMode: 0 + period: 0 + isPreviewCollapsed: 0 + previewMode: 7 + previewSRGB: 0 + previewMip: 0 + previewVisible: 1 + previewEV100: 0 + previewSlice: 0 + isPinned: 0 + outputTextureSettings: + - inputTexture: {fileID: 0} + name: Main Texture + enableCompression: 1 + compressionFormat: 12 + compressionQuality: 100 + hasMipMaps: 0 + isMain: 1 + enableConversion: 0 + conversionFormat: 0 + sRGB: 1 + finalCopyMaterial: {fileID: 4652733402955201651} + _selectedPreviewIndex: 0 + 00000001: + type: {class: RidgedPerlinNoise, ns: Mixture, asm: Mixture.Runtime} + data: + nodeCustomName: + GUID: 45b55e43-50ed-49df-b940-105b197c4bb0 + computeOrder: 4 + position: + serializedVersion: 2 + x: -312 + y: -44 + width: 250 + height: 585 + expanded: 0 + debug: 0 + nodeLock: 0 + settings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 512 + height: 512 + depth: 1 + potSize: 0 + sizeMode: -2 + dimension: -2 + outputChannels: -2 + outputPrecision: -2 + editFlags: 255 + doubleBuffered: 0 + wrapMode: -2 + filterMode: -2 + refreshMode: 0 + period: 0 + rtSettings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 0 + height: 0 + depth: 0 + potSize: 0 + sizeMode: 0 + dimension: 0 + outputChannels: 0 + outputPrecision: 0 + editFlags: 0 + doubleBuffered: 0 + wrapMode: 0 + filterMode: 0 + refreshMode: 0 + period: 0 + isPreviewCollapsed: 0 + previewMode: 7 + previewSRGB: 0 + previewMip: 0 + previewVisible: 1 + previewEV100: 0 + previewSlice: 0 + isPinned: 0 + output: {fileID: 0} + shader: {fileID: 4800000, guid: 49eed0c8b6dca3949a7864570e424043, type: 3} + material: {fileID: 5249714637275404893} + exposedProperties: + - displayName: UVs + referenceName: _UV_2D + tooltip: + type: + serializedType: UnityEngine.Texture2D, UnityEngine.CoreModule, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + - displayName: Tiling Mode + referenceName: _TilingMode + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: UV Mode + referenceName: _UVMode + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Output Range + referenceName: _OutputRange + tooltip: + type: + serializedType: UnityEngine.Vector4, UnityEngine.CoreModule, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + - displayName: Lacunarity + referenceName: _Lacunarity + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Frequency + referenceName: _Frequency + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Persistance + referenceName: _Persistance + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Octaves + referenceName: _Octaves + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Seed + referenceName: _Seed + tooltip: + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + - displayName: Channels + referenceName: _Channels + tooltip: Select how many noise to genereate and on which channel. The more + different channel you use the more expensive it is (max 4 noise evaluation). + type: + serializedType: System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, + PublicKeyToken=b77a5c561934e089 + shaderGUID: 49eed0c8b6dca3949a7864570e424043 + 00000002: + type: {class: UVNode, ns: Mixture, asm: Mixture.Runtime} + data: + nodeCustomName: + GUID: 3de26369-3ab3-4da4-8025-5953a99e2ead + computeOrder: 3 + position: + serializedVersion: 2 + x: -594 + y: -44 + width: 250 + height: 435 + expanded: 0 + debug: 0 + nodeLock: 0 + settings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 1024 + height: 1024 + depth: 1 + potSize: 0 + sizeMode: -2 + dimension: -2 + outputChannels: -2 + outputPrecision: -2 + editFlags: -257 + doubleBuffered: 0 + wrapMode: -2 + filterMode: -2 + refreshMode: 0 + period: 0 + rtSettings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 0 + height: 0 + depth: 0 + potSize: 0 + sizeMode: 0 + dimension: 0 + outputChannels: 0 + outputPrecision: 0 + editFlags: 0 + doubleBuffered: 0 + wrapMode: 0 + filterMode: 0 + refreshMode: 0 + period: 0 + isPreviewCollapsed: 0 + previewMode: 15 + previewSRGB: 0 + previewMip: 0 + previewVisible: 1 + previewEV100: 0 + previewSlice: 0 + isPinned: 0 + output: {fileID: 0} + shader: {fileID: 4800000, guid: 0e57459cc2eca8e4eb3e062b8ed60321, type: 3} + material: {fileID: 8054274073769734054} + exposedProperties: + - displayName: UV Scale + referenceName: _Scale + tooltip: + type: + serializedType: UnityEngine.Vector4, UnityEngine.CoreModule, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + - displayName: UV Bias + referenceName: _Bias + tooltip: + type: + serializedType: UnityEngine.Vector4, UnityEngine.CoreModule, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + shaderGUID: 0e57459cc2eca8e4eb3e062b8ed60321 + 00000003: + type: {class: ParameterNode, ns: GraphProcessor, asm: com.alelievr.NodeGraphProcessor.Runtime} + data: + nodeCustomName: + GUID: 85d5714d-9337-4353-969a-58eb527c69ab + computeOrder: 1 + position: + serializedVersion: 2 + x: -928.95 + y: -44 + width: 97 + height: 37 + expanded: 0 + debug: 0 + nodeLock: 0 + parameterGUID: c32cb7cc-0913-4e8d-89e1-d86ccfcc8c4b + accessor: 0 + 00000004: + type: {class: MakeVectorNode, ns: Mixture, asm: Mixture.Runtime} + data: + nodeCustomName: + GUID: fa002829-debb-4c60-8046-d99e4d4ea4b2 + computeOrder: 2 + position: + serializedVersion: 2 + x: -786.85 + y: -44 + width: 150 + height: 152 + expanded: 0 + debug: 0 + nodeLock: 0 + settings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 1024 + height: 1024 + depth: 1 + potSize: 0 + sizeMode: -2 + dimension: -2 + outputChannels: -2 + outputPrecision: -2 + editFlags: -257 + doubleBuffered: 0 + wrapMode: -2 + filterMode: -2 + refreshMode: 0 + period: 0 + rtSettings: + widthScale: 1 + heightScale: 1 + depthScale: 1 + width: 0 + height: 0 + depth: 0 + potSize: 0 + sizeMode: 0 + dimension: 0 + outputChannels: 0 + outputPrecision: 0 + editFlags: 0 + doubleBuffered: 0 + wrapMode: 0 + filterMode: 0 + refreshMode: 0 + period: 0 + isPreviewCollapsed: 0 + previewMode: 15 + previewSRGB: 0 + previewMip: 0 + previewVisible: 1 + previewEV100: 0 + previewSlice: 0 + isPinned: 0 + X: -0.24913323 + Y: 0.9684692 + Z: 0 + W: 0 + vector: {x: -0.24913323, y: 0.9684692, z: 0, w: 0} + 00000005: + type: {class: ParameterNode, ns: GraphProcessor, asm: com.alelievr.NodeGraphProcessor.Runtime} + data: + nodeCustomName: + GUID: f00f78ea-136b-48bd-9ee7-20db0071266e + computeOrder: 0 + position: + serializedVersion: 2 + x: -928.95 + y: -7.000007 + width: 97 + height: 37 + expanded: 0 + debug: 0 + nodeLock: 0 + parameterGUID: 99f9dc46-ccf9-47fd-aa97-db0ca86ce21a + accessor: 0 + 00000006: + type: {class: FloatParameter, ns: GraphProcessor, asm: com.alelievr.NodeGraphProcessor.Runtime} + data: + guid: c32cb7cc-0913-4e8d-89e1-d86ccfcc8c4b + name: Translate X + type: + serializedValue: + serializedType: + serializedName: + serializedValue: + input: 1 + settings: + id: 8 + val: -0.24913323 + 00000007: + type: {class: FloatParameter, ns: GraphProcessor, asm: com.alelievr.NodeGraphProcessor.Runtime} + data: + guid: 99f9dc46-ccf9-47fd-aa97-db0ca86ce21a + name: Translate Y + type: + serializedValue: + serializedType: + serializedName: + serializedValue: + input: 1 + settings: + id: 9 + val: 0.9684692 + 00000008: + type: {class: FloatParameter/FloatSettings, ns: GraphProcessor, asm: com.alelievr.NodeGraphProcessor.Runtime} + data: + isHidden: 0 + expanded: 0 + guid: c32cb7cc-0913-4e8d-89e1-d86ccfcc8c4b + mode: 0 + min: 0 + max: 1 + 00000009: + type: {class: FloatParameter/FloatSettings, ns: GraphProcessor, asm: com.alelievr.NodeGraphProcessor.Runtime} + data: + isHidden: 0 + expanded: 0 + guid: 99f9dc46-ccf9-47fd-aa97-db0ca86ce21a + mode: 0 + min: 0 + max: 1 +--- !u!86 &4256279983331766550 +CustomRenderTexture: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Subgraph 2 + m_ImageContentsHash: + serializedVersion: 2 + Hash: 00000000000000000000000000000000 + m_ForcedFallbackFormat: 4 + m_DownscaleFallback: 0 + m_IsAlphaChannelOptional: 0 + serializedVersion: 3 + m_Width: 256 + m_Height: 256 + m_AntiAliasing: 1 + m_MipCount: -1 + m_DepthFormat: 0 + m_ColorFormat: 48 + m_MipMap: 0 + m_GenerateMips: 0 + m_SRGB: 0 + m_UseDynamicScale: 0 + m_BindMS: 0 + m_EnableCompatibleFormat: 1 + m_TextureSettings: + serializedVersion: 2 + m_FilterMode: 0 + m_Aniso: 1 + m_MipBias: 0 + m_WrapU: 0 + m_WrapV: 0 + m_WrapW: 0 + m_Dimension: 2 + m_VolumeDepth: 1 + m_Material: {fileID: 4652733402955201651} + m_InitSource: 0 + m_InitMaterial: {fileID: 0} + m_InitColor: {r: 1, g: 1, b: 1, a: 1} + m_InitTexture: {fileID: 0} + m_UpdateMode: 0 + m_InitializationMode: 2 + m_UpdateZoneSpace: 0 + m_CurrentUpdateZoneSpace: 0 + m_UpdateZones: [] + m_UpdatePeriod: 0 + m_ShaderPass: 0 + m_CubemapFaceMask: 4294967295 + m_DoubleBuffered: 0 + m_WrapUpdateZones: 0 +--- !u!21 &4652733402955201651 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Hidden/Mixture/FinalCopy + m_Shader: {fileID: 4800000, guid: 513c040fbfb854aebb92cf147e30125a, type: 3} + m_ShaderKeywords: CRT_2D + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _Source_2D: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Source_3D: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Source_Cube: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: [] + m_Colors: [] + m_BuildTextureStacks: [] +--- !u!21 &5249714637275404893 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Hidden/Mixture/RidgedPerlinNoise + m_Shader: {fileID: 4800000, guid: 49eed0c8b6dca3949a7864570e424043, type: 3} + m_ShaderKeywords: CRT_2D USE_CUSTOM_UV _TILINGMODE_TILED + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _UV_2D: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _UV_3D: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _UV_Cube: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _Channels: 0 + - _Frequency: 1 + - _Lacunarity: 2 + - _Octaves: 4 + - _Persistance: 1 + - _Seed: 42 + - _TilingMode: 1 + - _UVMode: 0 + m_Colors: + - _OutputRange: {r: 0, g: 1, b: 0, a: 0} + m_BuildTextureStacks: [] +--- !u!21 &8054274073769734054 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Hidden/Mixture/UV + m_Shader: {fileID: 4800000, guid: 0e57459cc2eca8e4eb3e062b8ed60321, type: 3} + m_ShaderKeywords: CRT_2D + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: [] + m_Floats: [] + m_Colors: + - _Bias: {r: -0.24913323, g: 0.9684692, b: 0, a: 0} + - _Scale: {r: 2, g: 2, b: 1, a: 0} + m_BuildTextureStacks: [] diff --git a/Assets/Examples/Subgraph Tests/Subgraph 2.asset.meta b/Assets/Examples/Subgraph Tests/Subgraph 2.asset.meta new file mode 100644 index 00000000..9752e929 --- /dev/null +++ b/Assets/Examples/Subgraph Tests/Subgraph 2.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d446ae005dee81646884ad1b8c344225 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 4256279983331766550 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.alelievr.mixture/Editor/Views/SubgraphNodeView.cs b/Packages/com.alelievr.mixture/Editor/Views/SubgraphNodeView.cs new file mode 100644 index 00000000..7f115cc0 --- /dev/null +++ b/Packages/com.alelievr.mixture/Editor/Views/SubgraphNodeView.cs @@ -0,0 +1,133 @@ +using GraphProcessor; +using System.Linq; +using UnityEditor; +using UnityEditor.UIElements; +using UnityEngine; +using UnityEngine.UIElements; + +namespace Mixture +{ + [NodeCustomEditor(typeof(SubgraphNode))] + public class SubgraphNodeView : MixtureNodeView + { + SubgraphNode _node; + + protected override void DrawPreviewToolbar(Texture texture) + { + base.DrawPreviewToolbar(texture); + + var settings = _node.subgraph.outputNode.outputTextureSettings; + + _node.previewOutputIndex = EditorGUILayout.Popup( + Mathf.Clamp(_node.previewOutputIndex, 0, settings.Count - 1), + settings.Select(setting => setting.name).ToArray(), + EditorStyles.toolbarDropDown, + GUILayout.Width(150) + ); + } + + public override void Enable(bool fromInspector) + { + base.Enable(fromInspector); + + _node = nodeTarget as SubgraphNode; + + var subgraphTextureField = new ObjectField("Subgraph Texture") + { + value = _node.subgraphTexture, + objectType = typeof(CustomRenderTexture) + }; + subgraphTextureField.RegisterValueChangedCallback(e => + { + _node.subgraphTexture = e.newValue as CustomRenderTexture; + UpdateSubgraph(); + title = _node.name; + }); + + controlsContainer.Add(subgraphTextureField); + + _node.onAfterEdgeDisconnected += UpdateSubgraph; + + UpdateSubgraph(); + } + + public override void Disable() + { + base.Disable(); + + if (_node != null) _node.onAfterEdgeDisconnected -= UpdateSubgraph; + } + + void UpdateSubgraph(SerializableEdge _) => UpdateSubgraph(); + + void UpdateSubgraph() + { + if (_node.subgraph != null) + { + _node.subgraph.onExposedParameterModified -= UpdateSubgraphInputs; + _node.subgraph.onExposedParameterListChanged -= UpdateSubgraphInputs; + _node.subgraph.outputNode.onPortsUpdated -= UpdateSubgraphOutputs; + } + + _node.subgraph = MixtureDatabase.GetGraphFromTexture(_node.subgraphTexture); + + if (ValidateSubgraph()) + { + _node.subgraph.onExposedParameterModified += UpdateSubgraphInputs; + _node.subgraph.onExposedParameterListChanged += UpdateSubgraphInputs; + _node.subgraph.outputNode.onPortsUpdated += UpdateSubgraphOutputs; + + _node.UpdateOutputTextures(); + } + else + { + _node.previewOutputIndex = -1; + _node.ReleaseOutputTextures(); + } + + ForceUpdatePorts(); + NotifyNodeChanged(); + } + + void UpdateSubgraphInputs() + { + ForceUpdatePorts(); + NotifyNodeChanged(); + } + + void UpdateSubgraphInputs(ExposedParameter _) => UpdateSubgraphInputs(); + + void UpdateSubgraphOutputs() + { + _node.UpdateOutputTextures(); + ForceUpdatePorts(); + NotifyNodeChanged(); + } + + void UpdateSubgraphOutputs(string _) => UpdateSubgraphOutputs(); + + bool ValidateSubgraph() + { + _node.ClearMessages(); + + if (_node.subgraphTexture == null) + { + return false; + } + + if (_node.subgraph == null) + { + _node.AddMessage($"Cannot find Mixture graph for texture: {_node.subgraphTexture.name}", NodeMessageType.Error); + return false; + } + + if (_node.subgraph == _node.graph) + { + _node.AddMessage($"Cannot execute graph recursively!", NodeMessageType.Error); + return false; + } + + return true; + } + } +} diff --git a/Packages/com.alelievr.mixture/Editor/Views/SubgraphNodeView.cs.meta b/Packages/com.alelievr.mixture/Editor/Views/SubgraphNodeView.cs.meta new file mode 100644 index 00000000..416c9b5b --- /dev/null +++ b/Packages/com.alelievr.mixture/Editor/Views/SubgraphNodeView.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 089cce484dd09d44bb16d9ef8c704de3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.alelievr.mixture/Runtime/Nodes/SubgraphNode.cs b/Packages/com.alelievr.mixture/Runtime/Nodes/SubgraphNode.cs new file mode 100644 index 00000000..5dd62260 --- /dev/null +++ b/Packages/com.alelievr.mixture/Runtime/Nodes/SubgraphNode.cs @@ -0,0 +1,198 @@ +using GraphProcessor; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEngine.Rendering; + +namespace Mixture +{ + [System.Serializable, NodeMenuItem("Subgraph")] + public class SubgraphNode : MixtureNode, ICreateNodeFrom + { + // Placeholders for custom port behaviours + [Input, System.NonSerialized] public int subgraphInputs; + [Output, System.NonSerialized] public int subgraphOutputs; + + public MixtureGraph subgraph; + public CustomRenderTexture subgraphTexture; + public int previewOutputIndex = -1; + + List _outputTextures = new List(); + + public override string name => subgraph?.name ?? "Subgraph"; + public override bool isRenamable => true; + public override bool hasPreview => -1 < previewOutputIndex && previewOutputIndex < _outputTextures.Count; + public override bool canEditPreviewSRGB => false; + public override Texture previewTexture => hasPreview ? _outputTextures[previewOutputIndex] : null; + + public bool InitializeNodeFromObject(CustomRenderTexture texture) + { + subgraph = MixtureDatabase.GetGraphFromTexture(texture); + + if (subgraph == null) return false; + + subgraphTexture = texture; + previewOutputIndex = Mathf.Clamp(previewOutputIndex, 0, subgraph.outputNode.outputTextureSettings.Count - 1); + + return true; + } + + [CustomPortBehavior(nameof(subgraphInputs))] + public IEnumerable ListGraphInputs(List edges) + { + if (subgraph == null || subgraph == graph) yield break; + + for (var i = 0; i < subgraph.exposedParameters.Count; i++) + { + var parameter = subgraph.exposedParameters[i]; + + yield return new PortData + { + identifier = System.Convert.ToString(i), + displayName = parameter.name, + displayType = parameter.GetValueType(), + acceptMultipleEdges = false, + }; + } + } + + [CustomPortBehavior(nameof(subgraphOutputs))] + public IEnumerable ListGraphOutputs(List edges) + { + if (subgraph == null || subgraph == graph) yield break; + + var settings = subgraph.outputNode.outputTextureSettings; + var textureType = GetSubgraphTextureType(); + + for (var i = 0; i < settings.Count; i++) + { + yield return new PortData + { + identifier = System.Convert.ToString(i), + displayName = settings[i].name, + displayType = textureType, + acceptMultipleEdges = true, + }; + } + } + + [CustomPortInput(nameof(subgraphInputs), typeof(object))] + public void AssignGraphInputs(List edges) + { + foreach (var edge in edges) + { + var index = System.Convert.ToInt32(edge.inputPortIdentifier); + var parameter = subgraph.exposedParameters[index]; + + switch (edge.passThroughBuffer) + { + case float v: parameter.value = CoerceVectorValue(parameter, new Vector4(v, v, v, v)); break; + case Vector2 v: parameter.value = CoerceVectorValue(parameter, v); break; + case Vector3 v: parameter.value = CoerceVectorValue(parameter, v); break; + case Vector4 v: parameter.value = CoerceVectorValue(parameter, v); break; + default: parameter.value = edge.passThroughBuffer; break; + } + } + } + + [CustomPortOutput(nameof(subgraphOutputs), typeof(object))] + public void AssignGraphOutputs(List edges) + { + foreach (var edge in edges) + { + var index = System.Convert.ToInt32(edge.outputPortIdentifier); + edge.passThroughBuffer = _outputTextures[index]; + } + } + + public void UpdateOutputTextures() + { + ReleaseOutputTextures(); + + if (subgraph != null && subgraph != graph) GenerateOutputTextures(); + } + + public void GenerateOutputTextures() + { + var settings = subgraph.outputNode.outputTextureSettings; + + _outputTextures.Capacity = Mathf.Max(_outputTextures.Capacity, settings.Count); + + foreach (var setting in settings) + { + CustomRenderTexture outputTexture = null; + UpdateTempRenderTexture(ref outputTexture); + _outputTextures.Add(outputTexture); + } + } + + public void ReleaseOutputTextures() + { + foreach (var texture in _outputTextures) texture?.Release(); + + _outputTextures.Clear(); + } + + protected override void Enable() + { + base.Enable(); + + UpdateOutputTextures(); + } + + protected override void Disable() + { + base.Disable(); + + ReleaseOutputTextures(); + } + + public override bool canProcess => base.canProcess && subgraph != null && subgraph != graph; + + protected override bool ProcessNode(CommandBuffer cmd) + { + if (!base.ProcessNode(cmd)) return false; + + MixtureGraphProcessor.RunOnce(subgraph); + + using (var copyCmd = new CommandBuffer { name = $"{graph.name}/{subgraph.name}" }) + { + for (int i = 0; i < _outputTextures.Count; i++) + { + var outputTexture = _outputTextures[i]; + UpdateTempRenderTexture(ref outputTexture); + copyCmd.Blit(subgraph.outputNode.outputTextureSettings[i].finalCopyRT, outputTexture); + } + + Graphics.ExecuteCommandBuffer(copyCmd); + } + + return true; + } + + System.Type GetSubgraphTextureType() + { + var textureDimension = subgraph.settings.GetResolvedTextureDimension(subgraph); + + switch (textureDimension) + { + case UnityEngine.Rendering.TextureDimension.Tex2D: return typeof(Texture2D); + case UnityEngine.Rendering.TextureDimension.Tex3D: return typeof(Texture3D); + case UnityEngine.Rendering.TextureDimension.Cube: return typeof(Cubemap); + default: throw new System.Exception($"Texture dimension not supported: {textureDimension}"); + } + } + + object CoerceVectorValue(ExposedParameter parameter, Vector4 vector) + { + switch (parameter.value) + { + case float _: return vector.x; + case Vector2 _: return (Vector2)vector; + case Vector3 _: return (Vector3)vector; + case Vector4 _: return vector; + default: throw new System.Exception($"Cannot cast vector to {parameter.GetValueType()}"); + } + } + } +} diff --git a/Packages/com.alelievr.mixture/Runtime/Nodes/SubgraphNode.cs.meta b/Packages/com.alelievr.mixture/Runtime/Nodes/SubgraphNode.cs.meta new file mode 100644 index 00000000..5d5b660a --- /dev/null +++ b/Packages/com.alelievr.mixture/Runtime/Nodes/SubgraphNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: af92575172ca01046abd9c33bf5d217a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: