From 577853226c2aafc8bfc95069d9614328a36f30ff Mon Sep 17 00:00:00 2001 From: Alix Carolan Date: Wed, 27 Mar 2024 18:09:03 +0000 Subject: [PATCH 1/3] Add [ConvertPointAttributes] op A simple operator that takes one point attribute and converts it into a different one. --- .../point/modify/ConvertPointAttributes.cs | 56 +++++ ...es_c154b616-8aaf-4d43-ae95-035951b531c8.t3 | 227 ++++++++++++++++++ ..._c154b616-8aaf-4d43-ae95-035951b531c8.t3ui | 123 ++++++++++ .../points/modify/ConvertPointAttributes.hlsl | 130 ++++++++++ 4 files changed, 536 insertions(+) create mode 100644 Operators/Types/lib/point/modify/ConvertPointAttributes.cs create mode 100644 Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3 create mode 100644 Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3ui create mode 100644 Resources/lib/points/modify/ConvertPointAttributes.hlsl diff --git a/Operators/Types/lib/point/modify/ConvertPointAttributes.cs b/Operators/Types/lib/point/modify/ConvertPointAttributes.cs new file mode 100644 index 000000000..accda2053 --- /dev/null +++ b/Operators/Types/lib/point/modify/ConvertPointAttributes.cs @@ -0,0 +1,56 @@ +using T3.Core.DataTypes; +using T3.Core.Operator; +using T3.Core.Operator.Attributes; +using T3.Core.Operator.Slots; + +namespace T3.Operators.Types.Id_c154b616_8aaf_4d43_ae95_035951b531c8 +{ + public class ConvertPointAttributes : Instance + { + + [Output(Guid = "5ea9c3fa-7c27-4d4f-a056-c37b70ae4796")] + public readonly Slot Output = new(); + + [Input(Guid = "cace5c6d-5411-4835-97c0-b2690b4e1b26")] + public readonly InputSlot Points = new InputSlot(); + + [Input(Guid = "ec70d9cc-d0ed-4490-8f50-542e442f38cd", MappedType = typeof(ConvertOptions))] + public readonly InputSlot ConvertFrom = new InputSlot(); + + [Input(Guid = "035af505-295a-4ecd-9230-8e1e22f38c4a", MappedType = typeof(ConvertOptions))] + public readonly InputSlot ConvertTo = new InputSlot(); + + [Input(Guid = "ab049e91-c918-43f2-97b5-457c4eaffa89")] + public readonly InputSlot Amount = new InputSlot(); + + [Input(Guid = "2d55ff51-5f1b-421a-95ab-9c18d34b0efe")] + public readonly InputSlot Offset = new InputSlot(); + + + private enum ConvertOptions + { + Position_X, + Position_Y, + Position_Z, + Rotation_X, + Rotation_Y, + Rotation_Z, + Stretch_X, + Stretch_Y, + Stretch_Z, + Color_R, + Color_G, + Color_B, + Color_A, + W, + } + + private enum Modes + { + Replace, + Multiply, + Add, + } + } +} + diff --git a/Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3 b/Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3 new file mode 100644 index 000000000..a56cb33a5 --- /dev/null +++ b/Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3 @@ -0,0 +1,227 @@ +{ + "Name": "ConvertPointAttributes", + "Id": "c154b616-8aaf-4d43-ae95-035951b531c8", + "Namespace": "lib.point.modify", + "Inputs": [ + { + "Id": "cace5c6d-5411-4835-97c0-b2690b4e1b26"/*Points*/, + "DefaultValue": null + }, + { + "Id": "ec70d9cc-d0ed-4490-8f50-542e442f38cd"/*ConvertFrom*/, + "DefaultValue": 0 + }, + { + "Id": "035af505-295a-4ecd-9230-8e1e22f38c4a"/*ConvertTo*/, + "DefaultValue": 0 + }, + { + "Id": "ab049e91-c918-43f2-97b5-457c4eaffa89"/*Amount*/, + "DefaultValue": 1.0 + }, + { + "Id": "2d55ff51-5f1b-421a-95ab-9c18d34b0efe"/*Offset*/, + "DefaultValue": 0.0 + } + ], + "Children": [ + { + "Id": "0ef2108d-1bdf-4c0b-b1f5-035b2f467814"/*ComputeShader*/, + "SymbolId": "a256d70f-adb3-481d-a926-caf35bd3e64c", + "InputValues": [ + { + "Id": "afb69c81-5063-4cb9-9d42-841b994b5ec0"/*Source*/, + "Type": "System.String", + "Value": "Resources\\lib\\points\\modify\\ConvertPointAttributes.hlsl" + } + ], + "Outputs": [] + }, + { + "Id": "ee3b14ba-d455-42c6-b247-303f741b251c"/*ComputeShaderStage*/, + "SymbolId": "8bef116d-7d1c-4c1b-b902-25c1d5e925a9", + "InputValues": [ + { + "Id": "180cae35-10e3-47f3-8191-f6ecea7d321c"/*Dispatch*/, + "Type": "T3.Core.DataTypes.Vector.Int3", + "Value": { + "X": 64, + "Y": 1, + "Z": 1 + } + } + ], + "Outputs": [] + }, + { + "Id": "e254d581-cb71-45c8-96e6-c7d10b0fcaf7"/*ExecuteBufferUpdate*/, + "SymbolId": "58351c8f-4a73-448e-b7bb-69412e71bd76", + "InputValues": [], + "Outputs": [] + }, + { + "Id": "4e42d81b-02a0-4e5f-8997-fe2a8a09edc8"/*CalcDispatchCount*/, + "SymbolId": "eb68addb-ec59-416f-8608-ff9d2319f3a3", + "InputValues": [], + "Outputs": [] + }, + { + "Id": "cf3f4c55-8981-4ef1-8425-79539356727e"/*StructuredBufferWithViews*/, + "SymbolId": "b6c5be1d-b133-45e9-a269-8047ea0d6ad7", + "InputValues": [ + { + "Id": "0016dd87-8756-4a97-a0da-096e1a879c05"/*Stride*/, + "Type": "System.Int32", + "Value": 64 + } + ], + "Outputs": [] + }, + { + "Id": "226ce4bf-0dd2-4b94-b437-2625941fec09"/*GetBufferComponents*/, + "SymbolId": "80dff680-5abf-484a-b9e0-81d72f3b7aa4", + "InputValues": [], + "Outputs": [] + }, + { + "Id": "2260fb25-f406-4a72-b79b-e632be281f54"/*GetBufferComponents*/, + "SymbolId": "80dff680-5abf-484a-b9e0-81d72f3b7aa4", + "InputValues": [], + "Outputs": [] + }, + { + "Id": "c3dd7c91-1785-4a81-8c05-5a6164c20c69"/*FloatsToBuffer*/, + "SymbolId": "724da755-2d0c-42ab-8335-8c88ec5fb078", + "InputValues": [], + "Outputs": [] + }, + { + "Id": "c969ecbe-910a-4886-8ce0-44078040bbc8"/*IntToFloat*/, + "SymbolId": "17db8a36-079d-4c83-8a2a-7ea4c1aa49e6", + "InputValues": [], + "Outputs": [] + }, + { + "Id": "c69394fc-2ff1-4f1b-b729-ee3cd51f9d05"/*IntToFloat*/, + "SymbolId": "17db8a36-079d-4c83-8a2a-7ea4c1aa49e6", + "InputValues": [], + "Outputs": [] + } + ], + "Connections": [ + { + "SourceParentOrChildId": "e254d581-cb71-45c8-96e6-c7d10b0fcaf7", + "SourceSlotId": "9a66687e-a834-452c-a652-ba1fc70c2c7b", + "TargetParentOrChildId": "00000000-0000-0000-0000-000000000000", + "TargetSlotId": "5ea9c3fa-7c27-4d4f-a056-c37b70ae4796" + }, + { + "SourceParentOrChildId": "cf3f4c55-8981-4ef1-8425-79539356727e", + "SourceSlotId": "c997268d-6709-49de-980e-64d7a47504f7", + "TargetParentOrChildId": "2260fb25-f406-4a72-b79b-e632be281f54", + "TargetSlotId": "7a13b834-21e5-4cef-ad5b-23c3770ea763" + }, + { + "SourceParentOrChildId": "00000000-0000-0000-0000-000000000000", + "SourceSlotId": "cace5c6d-5411-4835-97c0-b2690b4e1b26", + "TargetParentOrChildId": "226ce4bf-0dd2-4b94-b437-2625941fec09", + "TargetSlotId": "7a13b834-21e5-4cef-ad5b-23c3770ea763" + }, + { + "SourceParentOrChildId": "0ef2108d-1bdf-4c0b-b1f5-035b2f467814", + "SourceSlotId": "a6fe06e0-b6a9-463c-9e62-930c58b0a0a1", + "TargetParentOrChildId": "4e42d81b-02a0-4e5f-8997-fe2a8a09edc8", + "TargetSlotId": "3979e440-7888-4249-9975-74b21c6b813c" + }, + { + "SourceParentOrChildId": "226ce4bf-0dd2-4b94-b437-2625941fec09", + "SourceSlotId": "d7918fd8-906e-424d-8c5c-9631941cfc9d", + "TargetParentOrChildId": "4e42d81b-02a0-4e5f-8997-fe2a8a09edc8", + "TargetSlotId": "f79ccc37-05fd-4f81-97d6-6c1cafca180c" + }, + { + "SourceParentOrChildId": "c969ecbe-910a-4886-8ce0-44078040bbc8", + "SourceSlotId": "db1073a1-b9d8-4d52-bc5c-7ae8c0ee1ac3", + "TargetParentOrChildId": "c3dd7c91-1785-4a81-8c05-5a6164c20c69", + "TargetSlotId": "49556d12-4cd1-4341-b9d8-c356668d296c" + }, + { + "SourceParentOrChildId": "c69394fc-2ff1-4f1b-b729-ee3cd51f9d05", + "SourceSlotId": "db1073a1-b9d8-4d52-bc5c-7ae8c0ee1ac3", + "TargetParentOrChildId": "c3dd7c91-1785-4a81-8c05-5a6164c20c69", + "TargetSlotId": "49556d12-4cd1-4341-b9d8-c356668d296c" + }, + { + "SourceParentOrChildId": "00000000-0000-0000-0000-000000000000", + "SourceSlotId": "ab049e91-c918-43f2-97b5-457c4eaffa89", + "TargetParentOrChildId": "c3dd7c91-1785-4a81-8c05-5a6164c20c69", + "TargetSlotId": "49556d12-4cd1-4341-b9d8-c356668d296c" + }, + { + "SourceParentOrChildId": "00000000-0000-0000-0000-000000000000", + "SourceSlotId": "2d55ff51-5f1b-421a-95ab-9c18d34b0efe", + "TargetParentOrChildId": "c3dd7c91-1785-4a81-8c05-5a6164c20c69", + "TargetSlotId": "49556d12-4cd1-4341-b9d8-c356668d296c" + }, + { + "SourceParentOrChildId": "00000000-0000-0000-0000-000000000000", + "SourceSlotId": "035af505-295a-4ecd-9230-8e1e22f38c4a", + "TargetParentOrChildId": "c69394fc-2ff1-4f1b-b729-ee3cd51f9d05", + "TargetSlotId": "01809b63-4b4a-47be-9588-98d5998ddb0c" + }, + { + "SourceParentOrChildId": "00000000-0000-0000-0000-000000000000", + "SourceSlotId": "ec70d9cc-d0ed-4490-8f50-542e442f38cd", + "TargetParentOrChildId": "c969ecbe-910a-4886-8ce0-44078040bbc8", + "TargetSlotId": "01809b63-4b4a-47be-9588-98d5998ddb0c" + }, + { + "SourceParentOrChildId": "226ce4bf-0dd2-4b94-b437-2625941fec09", + "SourceSlotId": "d7918fd8-906e-424d-8c5c-9631941cfc9d", + "TargetParentOrChildId": "cf3f4c55-8981-4ef1-8425-79539356727e", + "TargetSlotId": "16f98211-fe97-4235-b33a-ddbbd2b5997f" + }, + { + "SourceParentOrChildId": "ee3b14ba-d455-42c6-b247-303f741b251c", + "SourceSlotId": "c382284f-7e37-4eb0-b284-bc735247f26b", + "TargetParentOrChildId": "e254d581-cb71-45c8-96e6-c7d10b0fcaf7", + "TargetSlotId": "51110d89-083e-42b8-b566-87b144dfbed9" + }, + { + "SourceParentOrChildId": "cf3f4c55-8981-4ef1-8425-79539356727e", + "SourceSlotId": "c997268d-6709-49de-980e-64d7a47504f7", + "TargetParentOrChildId": "e254d581-cb71-45c8-96e6-c7d10b0fcaf7", + "TargetSlotId": "72cfe742-88fb-41cd-b6cf-d96730b24b23" + }, + { + "SourceParentOrChildId": "4e42d81b-02a0-4e5f-8997-fe2a8a09edc8", + "SourceSlotId": "35c0e513-812f-49e2-96fa-17541751c19b", + "TargetParentOrChildId": "ee3b14ba-d455-42c6-b247-303f741b251c", + "TargetSlotId": "180cae35-10e3-47f3-8191-f6ecea7d321c" + }, + { + "SourceParentOrChildId": "c3dd7c91-1785-4a81-8c05-5a6164c20c69", + "SourceSlotId": "f5531ffb-dbde-45d3-af2a-bd90bcbf3710", + "TargetParentOrChildId": "ee3b14ba-d455-42c6-b247-303f741b251c", + "TargetSlotId": "34cf06fe-8f63-4f14-9c59-35a2c021b817" + }, + { + "SourceParentOrChildId": "2260fb25-f406-4a72-b79b-e632be281f54", + "SourceSlotId": "f03246a7-e39f-4a41-a0c3-22bc976a6000", + "TargetParentOrChildId": "ee3b14ba-d455-42c6-b247-303f741b251c", + "TargetSlotId": "599384c2-bf6c-4953-be74-d363292ab1c7" + }, + { + "SourceParentOrChildId": "0ef2108d-1bdf-4c0b-b1f5-035b2f467814", + "SourceSlotId": "6c118567-8827-4422-86cc-4d4d00762d87", + "TargetParentOrChildId": "ee3b14ba-d455-42c6-b247-303f741b251c", + "TargetSlotId": "5c0e9c96-9aba-4757-ae1f-cc50fb6173f1" + }, + { + "SourceParentOrChildId": "226ce4bf-0dd2-4b94-b437-2625941fec09", + "SourceSlotId": "1368ab8e-d75e-429f-8ecd-0944f3ede9ab", + "TargetParentOrChildId": "ee3b14ba-d455-42c6-b247-303f741b251c", + "TargetSlotId": "88938b09-d5a7-437c-b6e1-48a5b375d756" + } + ] +} \ No newline at end of file diff --git a/Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3ui b/Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3ui new file mode 100644 index 000000000..e2cf0c0f4 --- /dev/null +++ b/Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3ui @@ -0,0 +1,123 @@ +{ + "Id": "c154b616-8aaf-4d43-ae95-035951b531c8"/*ConvertPointAttributes*/, + "Description": "", + "InputUis": [ + { + "InputId": "cace5c6d-5411-4835-97c0-b2690b4e1b26"/*Points*/, + "Relevancy": "Required", + "Position": { + "X": -501.39294, + "Y": 452.90167 + } + }, + { + "InputId": "ec70d9cc-d0ed-4490-8f50-542e442f38cd"/*ConvertFrom*/, + "Position": { + "X": -483.93066, + "Y": 673.4205 + } + }, + { + "InputId": "035af505-295a-4ecd-9230-8e1e22f38c4a"/*ConvertTo*/, + "Position": { + "X": -483.93066, + "Y": 718.4206 + } + }, + { + "InputId": "ab049e91-c918-43f2-97b5-457c4eaffa89"/*Amount*/, + "Position": { + "X": -483.93066, + "Y": 763.4206 + } + }, + { + "InputId": "2d55ff51-5f1b-421a-95ab-9c18d34b0efe"/*Offset*/, + "Position": { + "X": -483.93066, + "Y": 808.42084 + } + } + ], + "SymbolChildUis": [ + { + "ChildId": "0ef2108d-1bdf-4c0b-b1f5-035b2f467814"/*ComputeShader*/, + "Position": { + "X": -98.3772, + "Y": 545.09485 + } + }, + { + "ChildId": "ee3b14ba-d455-42c6-b247-303f741b251c"/*ComputeShaderStage*/, + "Position": { + "X": 317.05783, + "Y": 532.0112 + } + }, + { + "ChildId": "e254d581-cb71-45c8-96e6-c7d10b0fcaf7"/*ExecuteBufferUpdate*/, + "Position": { + "X": 499.75, + "Y": 420.2702 + } + }, + { + "ChildId": "4e42d81b-02a0-4e5f-8997-fe2a8a09edc8"/*CalcDispatchCount*/, + "Position": { + "X": 147.17853, + "Y": 571.37103 + } + }, + { + "ChildId": "cf3f4c55-8981-4ef1-8425-79539356727e"/*StructuredBufferWithViews*/, + "Position": { + "X": -98.3772, + "Y": 502.09485 + } + }, + { + "ChildId": "226ce4bf-0dd2-4b94-b437-2625941fec09"/*GetBufferComponents*/, + "Position": { + "X": -351.39294, + "Y": 452.90167 + } + }, + { + "ChildId": "2260fb25-f406-4a72-b79b-e632be281f54"/*GetBufferComponents*/, + "Position": { + "X": 147.17853, + "Y": 640.37103 + } + }, + { + "ChildId": "c3dd7c91-1785-4a81-8c05-5a6164c20c69"/*FloatsToBuffer*/, + "Position": { + "X": -99.74078, + "Y": 668.5633 + } + }, + { + "ChildId": "c969ecbe-910a-4886-8ce0-44078040bbc8"/*IntToFloat*/, + "Position": { + "X": -333.93066, + "Y": 673.4205 + } + }, + { + "ChildId": "c69394fc-2ff1-4f1b-b729-ee3cd51f9d05"/*IntToFloat*/, + "Position": { + "X": -333.93066, + "Y": 729.4205 + } + } + ], + "OutputUis": [ + { + "OutputId": "5ea9c3fa-7c27-4d4f-a056-c37b70ae4796"/*Output*/, + "Position": { + "X": 649.75, + "Y": 420.2702 + } + } + ] +} \ No newline at end of file diff --git a/Resources/lib/points/modify/ConvertPointAttributes.hlsl b/Resources/lib/points/modify/ConvertPointAttributes.hlsl new file mode 100644 index 000000000..c3f7d4758 --- /dev/null +++ b/Resources/lib/points/modify/ConvertPointAttributes.hlsl @@ -0,0 +1,130 @@ +#include "lib/shared/hash-functions.hlsl" +#include "lib/shared/noise-functions.hlsl" +#include "lib/shared/point.hlsl" +#include "lib/shared/quat-functions.hlsl" + +cbuffer Params : register(b0) +{ + float ConvertFrom; + float ConvertTo; + + float Amount; + float Offset; +} + +StructuredBuffer SourcePoints : t0; + +RWStructuredBuffer ResultPoints : u0; + + +[numthreads(64,1,1)] +void main(uint3 i : SV_DispatchThreadID) +{ + uint index = (uint)i.x; + uint pointCount, stride; + SourcePoints.GetDimensions(pointCount, stride); + if(index >= pointCount) { + return; + } + + Point p = SourcePoints[index]; + float conversionValue; + + switch (ConvertFrom) + { + case 0: + conversionValue = p.Position.x; + break; + case 1: + conversionValue = p.Position.y; + break; + case 2: + conversionValue = p.Position.z; + break; + case 3: + conversionValue = p.Rotation.x; + break; + case 4: + conversionValue = p.Rotation.y; + break; + case 5: + conversionValue = p.Rotation.z; + break; + case 6: + conversionValue = p.Stretch.x; + break; + case 7: + conversionValue = p.Stretch.y; + break; + case 8: + conversionValue = p.Stretch.z; + break; + case 9: + conversionValue = p.Color.r; + break; + case 10: + conversionValue = p.Color.g; + break; + case 11: + conversionValue = p.Color.b; + break; + case 12: + conversionValue = p.Color.a; + break; + case 13: + conversionValue = p.W; + break; + } + + conversionValue *= Amount; + conversionValue += Offset; + + switch (ConvertTo) + { + case 0: + p.Position.x = conversionValue; + break; + case 1: + p.Position.y = conversionValue; + break; + case 2: + p.Position.z = conversionValue; + break; + case 3: + p.Rotation.x = conversionValue; + break; + case 4: + p.Rotation.y = conversionValue; + break; + case 5: + p.Rotation.z = conversionValue; + break; + case 6: + p.Stretch.x = conversionValue; + break; + case 7: + p.Stretch.y = conversionValue; + break; + case 8: + p.Stretch.z = conversionValue; + break; + case 9: + p.Color.r = conversionValue; + break; + case 10: + p.Color.g = conversionValue; + break; + case 11: + p.Color.b = conversionValue; + break; + case 12: + p.Color.a = conversionValue; + break; + case 13: + p.W = conversionValue; + break; + } + + ResultPoints[index] = p; +} + From c9b1b5b933839e745aec23a483b734620e718c52 Mon Sep 17 00:00:00 2001 From: Alix Carolan Date: Thu, 28 Mar 2024 01:39:31 +0000 Subject: [PATCH 2/3] Refactor ConvertPointAttributes shader; add Mode selection --- .../point/modify/ConvertPointAttributes.cs | 4 + ...es_c154b616-8aaf-4d43-ae95-035951b531c8.t3 | 26 +- ..._c154b616-8aaf-4d43-ae95-035951b531c8.t3ui | 24 +- .../points/modify/ConvertPointAttributes.hlsl | 228 +++++++++++------- 4 files changed, 188 insertions(+), 94 deletions(-) diff --git a/Operators/Types/lib/point/modify/ConvertPointAttributes.cs b/Operators/Types/lib/point/modify/ConvertPointAttributes.cs index accda2053..219c0f628 100644 --- a/Operators/Types/lib/point/modify/ConvertPointAttributes.cs +++ b/Operators/Types/lib/point/modify/ConvertPointAttributes.cs @@ -14,6 +14,9 @@ public class ConvertPointAttributes : Instance [Input(Guid = "cace5c6d-5411-4835-97c0-b2690b4e1b26")] public readonly InputSlot Points = new InputSlot(); + [Input(Guid = "c1631db3-ba6f-4bd5-badf-30309b001d60", MappedType =typeof(Modes))] + public readonly InputSlot Mode = new InputSlot(); + [Input(Guid = "ec70d9cc-d0ed-4490-8f50-542e442f38cd", MappedType = typeof(ConvertOptions))] public readonly InputSlot ConvertFrom = new InputSlot(); @@ -27,6 +30,7 @@ public class ConvertPointAttributes : Instance public readonly InputSlot Offset = new InputSlot(); + private enum ConvertOptions { Position_X, diff --git a/Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3 b/Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3 index a56cb33a5..327cf1483 100644 --- a/Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3 +++ b/Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3 @@ -8,12 +8,16 @@ "DefaultValue": null }, { - "Id": "ec70d9cc-d0ed-4490-8f50-542e442f38cd"/*ConvertFrom*/, + "Id": "c1631db3-ba6f-4bd5-badf-30309b001d60"/*Mode*/, "DefaultValue": 0 }, + { + "Id": "ec70d9cc-d0ed-4490-8f50-542e442f38cd"/*ConvertFrom*/, + "DefaultValue": 13 + }, { "Id": "035af505-295a-4ecd-9230-8e1e22f38c4a"/*ConvertTo*/, - "DefaultValue": 0 + "DefaultValue": 12 }, { "Id": "ab049e91-c918-43f2-97b5-457c4eaffa89"/*Amount*/, @@ -106,6 +110,12 @@ "SymbolId": "17db8a36-079d-4c83-8a2a-7ea4c1aa49e6", "InputValues": [], "Outputs": [] + }, + { + "Id": "41933e73-6c89-4215-92a8-48cdfc6b743a"/*IntToFloat*/, + "SymbolId": "17db8a36-079d-4c83-8a2a-7ea4c1aa49e6", + "InputValues": [], + "Outputs": [] } ], "Connections": [ @@ -127,6 +137,12 @@ "TargetParentOrChildId": "226ce4bf-0dd2-4b94-b437-2625941fec09", "TargetSlotId": "7a13b834-21e5-4cef-ad5b-23c3770ea763" }, + { + "SourceParentOrChildId": "00000000-0000-0000-0000-000000000000", + "SourceSlotId": "c1631db3-ba6f-4bd5-badf-30309b001d60", + "TargetParentOrChildId": "41933e73-6c89-4215-92a8-48cdfc6b743a", + "TargetSlotId": "01809b63-4b4a-47be-9588-98d5998ddb0c" + }, { "SourceParentOrChildId": "0ef2108d-1bdf-4c0b-b1f5-035b2f467814", "SourceSlotId": "a6fe06e0-b6a9-463c-9e62-930c58b0a0a1", @@ -163,6 +179,12 @@ "TargetParentOrChildId": "c3dd7c91-1785-4a81-8c05-5a6164c20c69", "TargetSlotId": "49556d12-4cd1-4341-b9d8-c356668d296c" }, + { + "SourceParentOrChildId": "41933e73-6c89-4215-92a8-48cdfc6b743a", + "SourceSlotId": "db1073a1-b9d8-4d52-bc5c-7ae8c0ee1ac3", + "TargetParentOrChildId": "c3dd7c91-1785-4a81-8c05-5a6164c20c69", + "TargetSlotId": "49556d12-4cd1-4341-b9d8-c356668d296c" + }, { "SourceParentOrChildId": "00000000-0000-0000-0000-000000000000", "SourceSlotId": "035af505-295a-4ecd-9230-8e1e22f38c4a", diff --git a/Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3ui b/Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3ui index e2cf0c0f4..0d46b848d 100644 --- a/Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3ui +++ b/Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3ui @@ -1,6 +1,6 @@ { "Id": "c154b616-8aaf-4d43-ae95-035951b531c8"/*ConvertPointAttributes*/, - "Description": "", + "Description": "Takes one point attribute and converts it into another.", "InputUis": [ { "InputId": "cace5c6d-5411-4835-97c0-b2690b4e1b26"/*Points*/, @@ -10,6 +10,13 @@ "Y": 452.90167 } }, + { + "InputId": "c1631db3-ba6f-4bd5-badf-30309b001d60"/*Mode*/, + "Position": { + "X": -485.94177, + "Y": 849.4209 + } + }, { "InputId": "ec70d9cc-d0ed-4490-8f50-542e442f38cd"/*ConvertFrom*/, "Position": { @@ -27,15 +34,15 @@ { "InputId": "ab049e91-c918-43f2-97b5-457c4eaffa89"/*Amount*/, "Position": { - "X": -483.93066, - "Y": 763.4206 + "X": -484.9242, + "Y": 915.43134 } }, { "InputId": "2d55ff51-5f1b-421a-95ab-9c18d34b0efe"/*Offset*/, "Position": { - "X": -483.93066, - "Y": 808.42084 + "X": -484.9242, + "Y": 960.4316 } } ], @@ -109,6 +116,13 @@ "X": -333.93066, "Y": 729.4205 } + }, + { + "ChildId": "41933e73-6c89-4215-92a8-48cdfc6b743a"/*IntToFloat*/, + "Position": { + "X": -335.94177, + "Y": 849.4209 + } } ], "OutputUis": [ diff --git a/Resources/lib/points/modify/ConvertPointAttributes.hlsl b/Resources/lib/points/modify/ConvertPointAttributes.hlsl index c3f7d4758..73b252dfb 100644 --- a/Resources/lib/points/modify/ConvertPointAttributes.hlsl +++ b/Resources/lib/points/modify/ConvertPointAttributes.hlsl @@ -10,6 +10,8 @@ cbuffer Params : register(b0) float Amount; float Offset; + + float Mode; } StructuredBuffer SourcePoints : t0; @@ -29,101 +31,153 @@ void main(uint3 i : SV_DispatchThreadID) Point p = SourcePoints[index]; float conversionValue; - - switch (ConvertFrom) - { - case 0: - conversionValue = p.Position.x; - break; - case 1: - conversionValue = p.Position.y; - break; - case 2: - conversionValue = p.Position.z; - break; - case 3: - conversionValue = p.Rotation.x; - break; - case 4: - conversionValue = p.Rotation.y; - break; - case 5: - conversionValue = p.Rotation.z; - break; - case 6: - conversionValue = p.Stretch.x; - break; - case 7: - conversionValue = p.Stretch.y; - break; - case 8: - conversionValue = p.Stretch.z; - break; - case 9: - conversionValue = p.Color.r; - break; - case 10: - conversionValue = p.Color.g; - break; - case 11: - conversionValue = p.Color.b; - break; - case 12: - conversionValue = p.Color.a; - break; - case 13: - conversionValue = p.W; - break; - } - conversionValue *= Amount; + float pointAttributes[14]; + + // loading all point attributes into an array makes it easier to modify them + pointAttributes[0] = p.Position.x; + pointAttributes[1] = p.Position.y; + pointAttributes[2] = p.Position.z; + pointAttributes[3] = p.Rotation.x; + pointAttributes[4] = p.Rotation.y; + pointAttributes[5] = p.Rotation.z; + pointAttributes[6] = p.Stretch.x; + pointAttributes[7] = p.Stretch.y; + pointAttributes[8] = p.Stretch.z; + pointAttributes[9] = p.Color.r; + pointAttributes[10] = p.Color.g; + pointAttributes[11] = p.Color.b; + pointAttributes[12] = p.Color.a; + pointAttributes[13] = p.W; + + conversionValue = pointAttributes[ConvertFrom]; + + conversionValue *= Amount; //this works, but most other point attribute ops use lerp conversionValue += Offset; - switch (ConvertTo) + switch (Mode) { - case 0: - p.Position.x = conversionValue; - break; - case 1: - p.Position.y = conversionValue; - break; - case 2: - p.Position.z = conversionValue; - break; - case 3: - p.Rotation.x = conversionValue; - break; - case 4: - p.Rotation.y = conversionValue; - break; - case 5: - p.Rotation.z = conversionValue; - break; - case 6: - p.Stretch.x = conversionValue; - break; - case 7: - p.Stretch.y = conversionValue; + case 0: //replace + pointAttributes[ConvertTo] = conversionValue; break; - case 8: - p.Stretch.z = conversionValue; + case 1: //add + pointAttributes[ConvertTo] += conversionValue; break; - case 9: - p.Color.r = conversionValue; - break; - case 10: - p.Color.g = conversionValue; - break; - case 11: - p.Color.b = conversionValue; - break; - case 12: - p.Color.a = conversionValue; - break; - case 13: - p.W = conversionValue; + case 2: //multiply + pointAttributes[ConvertTo] *= conversionValue; break; } + + p.Position.x = pointAttributes[0]; + p.Position.y = pointAttributes[1]; + p.Position.z = pointAttributes[2]; + p.Rotation.x = pointAttributes[3]; + p.Rotation.y = pointAttributes[4]; + p.Rotation.z = pointAttributes[5]; + p.Stretch.x = pointAttributes[6]; + p.Stretch.y = pointAttributes[7]; + p.Stretch.z = pointAttributes[8]; + p.Color.r = pointAttributes[9]; + p.Color.g = pointAttributes[10]; + p.Color.b = pointAttributes[11]; + p.Color.a = pointAttributes[12]; + p.W = pointAttributes[13]; + + + //switch (ConvertFrom) + //{ + // case 0: + // conversionValue = p.Position.x; + // break; + // case 1: + // conversionValue = p.Position.y; + // break; + // case 2: + // conversionValue = p.Position.z; + // break; + // case 3: + // conversionValue = p.Rotation.x; + // break; + // case 4: + // conversionValue = p.Rotation.y; + // break; + // case 5: + // conversionValue = p.Rotation.z; + // break; + // case 6: + // conversionValue = p.Stretch.x; + // break; + // case 7: + // conversionValue = p.Stretch.y; + // break; + // case 8: + // conversionValue = p.Stretch.z; + // break; + // case 9: + // conversionValue = p.Color.r; + // break; + // case 10: + // conversionValue = p.Color.g; + // break; + // case 11: + // conversionValue = p.Color.b; + // break; + // case 12: + // conversionValue = p.Color.a; + // break; + // case 13: + // conversionValue = p.W; + // break; + //} + + //conversionValue *= Amount; + //conversionValue += Offset; + + //switch (ConvertTo) + //{ + // case 0: + // p.Position.x = conversionValue; + // break; + // case 1: + // p.Position.y = conversionValue; + // break; + // case 2: + // p.Position.z = conversionValue; + // break; + // case 3: + // p.Rotation.x = conversionValue; + // break; + // case 4: + // p.Rotation.y = conversionValue; + // break; + // case 5: + // p.Rotation.z = conversionValue; + // break; + // case 6: + // p.Stretch.x = conversionValue; + // break; + // case 7: + // p.Stretch.y = conversionValue; + // break; + // case 8: + // p.Stretch.z = conversionValue; + // break; + // case 9: + // p.Color.r = conversionValue; + // break; + // case 10: + // p.Color.g = conversionValue; + // break; + // case 11: + // p.Color.b = conversionValue; + // break; + // case 12: + // p.Color.a = conversionValue; + // break; + // case 13: + // p.W = conversionValue; + // break; + //} ResultPoints[index] = p; } From 5e40b3ae37361e4a26926ed5d977af2379650c0a Mon Sep 17 00:00:00 2001 From: Alix Carolan Date: Sat, 27 Apr 2024 17:56:32 +0100 Subject: [PATCH 3/3] Fix UI for [ConvertPointAttributes] and add documentation --- .../point/modify/ConvertPointAttributes.cs | 2 +- ..._c154b616-8aaf-4d43-ae95-035951b531c8.t3ui | 20 ++-- .../points/modify/ConvertPointAttributes.hlsl | 95 +------------------ 3 files changed, 16 insertions(+), 101 deletions(-) diff --git a/Operators/Types/lib/point/modify/ConvertPointAttributes.cs b/Operators/Types/lib/point/modify/ConvertPointAttributes.cs index 219c0f628..8f1a3a42a 100644 --- a/Operators/Types/lib/point/modify/ConvertPointAttributes.cs +++ b/Operators/Types/lib/point/modify/ConvertPointAttributes.cs @@ -52,8 +52,8 @@ private enum ConvertOptions private enum Modes { Replace, - Multiply, Add, + Multiply, } } } diff --git a/Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3ui b/Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3ui index 0d46b848d..4d58be55f 100644 --- a/Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3ui +++ b/Operators/Types/lib/point/modify/ConvertPointAttributes_c154b616-8aaf-4d43-ae95-035951b531c8.t3ui @@ -1,6 +1,6 @@ { "Id": "c154b616-8aaf-4d43-ae95-035951b531c8"/*ConvertPointAttributes*/, - "Description": "Takes one point attribute and converts it into another.", + "Description": "Takes one point attribute and converts it into another on a per-point basis, with some controls for transforming those attributes.\n\nFor finer control over point color or W, try [SpreadPointAttributes].\n", "InputUis": [ { "InputId": "cace5c6d-5411-4835-97c0-b2690b4e1b26"/*Points*/, @@ -8,42 +8,48 @@ "Position": { "X": -501.39294, "Y": 452.90167 - } + }, + "Description": "Input points to be converted." }, { "InputId": "c1631db3-ba6f-4bd5-badf-30309b001d60"/*Mode*/, "Position": { "X": -485.94177, "Y": 849.4209 - } + }, + "Description": "Replace: Sets ConvertTo to be exactly the same as ConvertFrom.\nAdd: Adds ConvertFrom onto ConvertTo.\nMultiply: Multiplies ConvertFrom by ConvertTo.\n\n" }, { "InputId": "ec70d9cc-d0ed-4490-8f50-542e442f38cd"/*ConvertFrom*/, "Position": { "X": -483.93066, "Y": 673.4205 - } + }, + "Description": "Input attribute for use in conversion." }, { "InputId": "035af505-295a-4ecd-9230-8e1e22f38c4a"/*ConvertTo*/, "Position": { "X": -483.93066, "Y": 718.4206 - } + }, + "Description": "Output attribute to be modified by this operator." }, { "InputId": "ab049e91-c918-43f2-97b5-457c4eaffa89"/*Amount*/, "Position": { "X": -484.9242, "Y": 915.43134 - } + }, + "Description": "Multiplies the input attribute before converting." }, { "InputId": "2d55ff51-5f1b-421a-95ab-9c18d34b0efe"/*Offset*/, "Position": { "X": -484.9242, "Y": 960.4316 - } + }, + "Description": "Added to the input attribute before converting." } ], "SymbolChildUis": [ diff --git a/Resources/lib/points/modify/ConvertPointAttributes.hlsl b/Resources/lib/points/modify/ConvertPointAttributes.hlsl index 73b252dfb..511629eca 100644 --- a/Resources/lib/points/modify/ConvertPointAttributes.hlsl +++ b/Resources/lib/points/modify/ConvertPointAttributes.hlsl @@ -84,101 +84,10 @@ void main(uint3 i : SV_DispatchThreadID) p.W = pointAttributes[13]; - //switch (ConvertFrom) - //{ - // case 0: - // conversionValue = p.Position.x; - // break; - // case 1: - // conversionValue = p.Position.y; - // break; - // case 2: - // conversionValue = p.Position.z; - // break; - // case 3: - // conversionValue = p.Rotation.x; - // break; - // case 4: - // conversionValue = p.Rotation.y; - // break; - // case 5: - // conversionValue = p.Rotation.z; - // break; - // case 6: - // conversionValue = p.Stretch.x; - // break; - // case 7: - // conversionValue = p.Stretch.y; - // break; - // case 8: - // conversionValue = p.Stretch.z; - // break; - // case 9: - // conversionValue = p.Color.r; - // break; - // case 10: - // conversionValue = p.Color.g; - // break; - // case 11: - // conversionValue = p.Color.b; - // break; - // case 12: - // conversionValue = p.Color.a; - // break; - // case 13: - // conversionValue = p.W; - // break; - //} + // this code is not very efficient, it loads and sets *every* point attribute regardless of whether it was changed... + // seems to have negligible performance impact, but worth mentioning. - //conversionValue *= Amount; - //conversionValue += Offset; - //switch (ConvertTo) - //{ - // case 0: - // p.Position.x = conversionValue; - // break; - // case 1: - // p.Position.y = conversionValue; - // break; - // case 2: - // p.Position.z = conversionValue; - // break; - // case 3: - // p.Rotation.x = conversionValue; - // break; - // case 4: - // p.Rotation.y = conversionValue; - // break; - // case 5: - // p.Rotation.z = conversionValue; - // break; - // case 6: - // p.Stretch.x = conversionValue; - // break; - // case 7: - // p.Stretch.y = conversionValue; - // break; - // case 8: - // p.Stretch.z = conversionValue; - // break; - // case 9: - // p.Color.r = conversionValue; - // break; - // case 10: - // p.Color.g = conversionValue; - // break; - // case 11: - // p.Color.b = conversionValue; - // break; - // case 12: - // p.Color.a = conversionValue; - // break; - // case 13: - // p.W = conversionValue; - // break; - //} - ResultPoints[index] = p; }