Hi, I’m trying to create a tool for my Archviz project to allow me to drop in a blueprint to magically cut holes in flat surfaces so I don’t have to manually prepare meshes like sinks in counters and lights in ceilings.
I’ve seen the way to do this with BoxMask-3D and material parameter collections, but until there’s someway to dynamically insert and remove indices, as well as a way to have a scalable master material where I don’t need to manually hook up Location, Rotation, and Scale parameters to every single finite BoxMask-3D that’s been hardcoded into the material, I might as well just manually edit all the meshes I need.
I’ve been looking into the Custom Node because it can use for loops, and I managed to create a system where the Level blueprint will create a render target texture that records the locations of every blueprint and then send it to a dynamic instance of a master material which has a Custom Node that can read each pixel and output the location accurately as a 3Vector.
I’ve also been able to reconstruct the BoxMask-3D in the Custom Node by peeking into the compiled HLSL Code. When you want to have multiple BoxMask-3Ds, I’ve always just used the regular add node and outputted the sum of the two masks, which works perfectly to have two completely separate box masks in world space.
The problem I’m left with is that I can’t output a FLWCVector3 with a custom node, so I can’t just use that as is, and I am unsure of how I might combine the outputs of the HLSL box mask otherwise and output as a regular float3.
Maybe there’s some way to add the masks in world space and then convert those into a UV mapped texture?
Here is the HLSL code so far:
FLWCVector3 mask = LWCPromote(((MaterialFloat3)0.00000000));
float3 output = float3(0,0,0);
for (int i = 0; i < x; i++)
{
uint3 sampleCoord = uint3(i, 0, 0);
FLWCVector3 sample = LWCPromote(Tex.Load(sampleCoord).xyz);
sample = LWCMultiply(sample, LWCPromote(((MaterialFloat3)255)));
FLWCVector3 Step1 = GetWorldPosition(Parameters);
FLWCVector3 Step2 = LWCSubtract(DERIV_BASE_VALUE(Step1), LWCPromote(sample));
FLWCVector3 Step3 = LWCAbs(DERIV_BASE_VALUE(Step2));
FLWCVector3 Step4 = LWCSubtract(DERIV_BASE_VALUE(Step3), LWCPromote(Size * 0.5));
FLWCVector3 Step5 = LWCMax(DERIV_BASE_VALUE(Step4),LWCPromote(((MaterialFloat3)0.00000000)));
FLWCVector3 Step6 = LWCSubtract(LWCPromote(((MaterialFloat3)0.00000000)), DERIV_BASE_VALUE(Step5));
FLWCScalar Step7 = LWCLength(DERIV_BASE_VALUE(Step6));
FLWCScalar Step8 = LWCDivide(DERIV_BASE_VALUE(Step7), LWCPromote(EdgeFalloff));
MaterialFloat Step9 = LWCSaturate(DERIV_BASE_VALUE(Step8));
mask = LWCAdd(mask, Step9);
output += LWCToFloat(mask);
}
return output;
Here is the Material: