Drive physical matrix with GPU Samba pattern
This commit is contained in:
parent
bb08ede33e
commit
fa8ac9aea8
8 changed files with 42 additions and 11 deletions
|
|
@ -114,6 +114,7 @@ Sublevel source notes:
|
|||
- GPU-first rule: avoid CPU voxelization for final 120^3 workflows. CPU sublevel sampling is only a temporary/editor preview path.
|
||||
- When adding a new source/animation, prefer GPU material parameters, volume textures, Niagara/render-target driven data, or compute-shader/RDG paths over per-voxel CPU loops.
|
||||
- `ELedTestPattern::SambaDancing` is the current fast GPU procedural dancer path in `M_LedVolumeRaymarch`; the imported Samba FBX sublevel remains available as a reference/source asset.
|
||||
- Final visual mode for the current demo is `GeometryMode=PhysicalMatrix`, `SourceMode=TestPattern`, `TestPattern=SambaDancing`, `bUseGpuTestPattern=true`, with wire/fixer instances visible and LED colors computed in `M_LedVoxelGpu`.
|
||||
- Source actors must have tag `LedVoxelSource`.
|
||||
- `ARotatingSnowflakeActor` creates a rotating 3D snowflake from many small static mesh crystals so the bounds-based sampler sees a volumetric shape.
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -64,14 +64,7 @@ def create_gpu_led_material():
|
|||
ensure_directory(package_path)
|
||||
|
||||
if unreal.EditorAssetLibrary.does_asset_exist(asset_path):
|
||||
material = unreal.EditorAssetLibrary.load_asset(asset_path)
|
||||
usage = getattr(unreal.MaterialUsage, "MATUSAGE_INSTANCED_STATIC_MESHES", None)
|
||||
if material and usage is not None:
|
||||
unreal.MaterialEditingLibrary.set_base_material_usage(material, usage, True)
|
||||
unreal.MaterialEditingLibrary.recompile_material(material)
|
||||
unreal.EditorAssetLibrary.save_loaded_asset(material)
|
||||
if material:
|
||||
return material
|
||||
unreal.EditorAssetLibrary.delete_asset(asset_path)
|
||||
|
||||
asset_tools = unreal.AssetToolsHelpers.get_asset_tools()
|
||||
material = asset_tools.create_asset(asset_name, package_path, unreal.Material, unreal.MaterialFactoryNew())
|
||||
|
|
@ -111,6 +104,14 @@ def create_gpu_led_material():
|
|||
solid.set_editor_property("parameter_name", "LedColor")
|
||||
solid.set_editor_property("default_value", unreal.LinearColor(1.0, 0.2, 0.05, 1.0))
|
||||
|
||||
center = mel.create_material_expression(material, unreal.MaterialExpressionVectorParameter, -920, 740)
|
||||
center.set_editor_property("parameter_name", "VolumeCenter")
|
||||
center.set_editor_property("default_value", unreal.LinearColor(0.0, 0.0, 150.0, 1.0))
|
||||
|
||||
extent = mel.create_material_expression(material, unreal.MaterialExpressionVectorParameter, -920, 860)
|
||||
extent.set_editor_property("parameter_name", "VolumeExtent")
|
||||
extent.set_editor_property("default_value", unreal.LinearColor(512.0, 512.0, 512.0, 1.0))
|
||||
|
||||
custom = mel.create_material_expression(material, unreal.MaterialExpressionCustom, -520, 120)
|
||||
custom.set_editor_property("description", "GPU LED volumetric test pattern")
|
||||
custom.set_editor_property("output_type", unreal.CustomMaterialOutputType.CMOT_FLOAT3)
|
||||
|
|
@ -131,7 +132,7 @@ else if (mode >= 1.5 && mode < 2.5)
|
|||
float phase = dot(p, float3(0.071, 0.053, 0.041)) + t;
|
||||
color = 0.5 + 0.5 * sin(float3(phase, phase + 2.0943951, phase + 4.1887902));
|
||||
}
|
||||
else if (mode >= 2.5)
|
||||
else if (mode >= 2.5 && mode < 3.5)
|
||||
{
|
||||
float wave = sin(t) * 0.5 + 0.5;
|
||||
float radius = lerp(12.0, 52.0, wave);
|
||||
|
|
@ -140,6 +141,24 @@ else if (mode >= 2.5)
|
|||
float phase = dot(p, float3(0.09, 0.04, 0.07)) + t;
|
||||
color = shell * (0.35 + 0.65 * (0.5 + 0.5 * sin(float3(phase, phase + 2.0943951, phase + 4.1887902))));
|
||||
}
|
||||
else if (mode >= 3.5)
|
||||
{
|
||||
float3 q = (WorldPos - VolumeCenter.xyz) / max(VolumeExtent.xyz, 1.0);
|
||||
q.y += 0.05 * sin(t * 2.2);
|
||||
float hip = sin(t * 2.6);
|
||||
float shoulder = sin(t * 2.6 + 1.2);
|
||||
|
||||
float torso = 1.0 - length(float3(q.x * 3.1, q.z * 2.15, q.y * 4.4));
|
||||
float head = 1.0 - length(float3(q.x * 8.0, q.z * 8.0, (q.y - 0.43) * 8.0));
|
||||
float leftArm = 1.0 - abs(q.x + 0.34 + shoulder * 0.12) * 7.5 - abs(q.y - 0.13 - shoulder * 0.08) * 5.2 - abs(q.z) * 6.0;
|
||||
float rightArm = 1.0 - abs(q.x - 0.34 + shoulder * 0.12) * 7.5 - abs(q.y - 0.12 + shoulder * 0.08) * 5.2 - abs(q.z) * 6.0;
|
||||
float leftLeg = 1.0 - abs(q.x + 0.18 - hip * 0.11) * 8.0 - abs(q.y + 0.36 + hip * 0.04) * 4.8 - abs(q.z) * 6.0;
|
||||
float rightLeg = 1.0 - abs(q.x - 0.18 - hip * 0.11) * 8.0 - abs(q.y + 0.36 - hip * 0.04) * 4.8 - abs(q.z) * 6.0;
|
||||
|
||||
float mask = saturate(max(max(torso, head), max(max(leftArm, rightArm), max(leftLeg, rightLeg))));
|
||||
float pulse = 0.68 + 0.32 * sin(t * 3.4 + q.y * 9.0);
|
||||
color = mask * pulse * lerp(float3(0.02, 0.66, 1.0), float3(1.0, 0.86, 0.08), saturate(q.y + 0.45));
|
||||
}
|
||||
|
||||
float safeGamma = max(GammaValue, 0.001);
|
||||
return pow(max(color, 0.0), safeGamma) * BrightnessValue;
|
||||
|
|
@ -159,6 +178,8 @@ return pow(max(color, 0.0), safeGamma) * BrightnessValue;
|
|||
custom_input("BrightnessValue"),
|
||||
custom_input("GammaValue"),
|
||||
custom_input("SolidColor"),
|
||||
custom_input("VolumeCenter"),
|
||||
custom_input("VolumeExtent"),
|
||||
])
|
||||
|
||||
mel.connect_material_expressions(world_pos, "", custom, "WorldPos")
|
||||
|
|
@ -169,6 +190,8 @@ return pow(max(color, 0.0), safeGamma) * BrightnessValue;
|
|||
mel.connect_material_expressions(brightness, "", custom, "BrightnessValue")
|
||||
mel.connect_material_expressions(gamma, "", custom, "GammaValue")
|
||||
mel.connect_material_expressions(solid, "", custom, "SolidColor")
|
||||
mel.connect_material_expressions(center, "", custom, "VolumeCenter")
|
||||
mel.connect_material_expressions(extent, "", custom, "VolumeExtent")
|
||||
mel.connect_material_property(custom, "", unreal.MaterialProperty.MP_EMISSIVE_COLOR)
|
||||
|
||||
mel.recompile_material(material)
|
||||
|
|
|
|||
|
|
@ -1156,13 +1156,20 @@ void ALedVolumeDisplayActor::UpdateMaterialParameters()
|
|||
}
|
||||
if (GpuVoxelMID)
|
||||
{
|
||||
const float ActiveSpacing = GeometryMode == ELedDisplayGeometryMode::PhysicalMatrix ? DotPitchMm * 0.1f : Spacing;
|
||||
const FVector VolumeExtent(
|
||||
FMath::Max(ActiveSpacing * 0.5f, Dimensions.Width * ActiveSpacing * 0.5f),
|
||||
FMath::Max(ActiveSpacing * 0.5f, Dimensions.Depth * ActiveSpacing * 0.5f),
|
||||
FMath::Max(ActiveSpacing * 0.5f, Dimensions.Height * ActiveSpacing * 0.5f));
|
||||
const FVector Center = GetActorLocation();
|
||||
GpuVoxelMID->SetScalarParameterValue(BrightnessParameterName, Brightness);
|
||||
GpuVoxelMID->SetScalarParameterValue(GammaParameterName, Gamma);
|
||||
GpuVoxelMID->SetVectorParameterValue(LedColorParameterName, SolidColor);
|
||||
GpuVoxelMID->SetScalarParameterValue(AnimationSpeedParameterName, AnimationSpeed);
|
||||
GpuVoxelMID->SetScalarParameterValue(PatternModeParameterName, static_cast<float>(static_cast<uint8>(TestPattern)));
|
||||
GpuVoxelMID->SetScalarParameterValue(VoxelSpacingParameterName,
|
||||
GeometryMode == ELedDisplayGeometryMode::PhysicalMatrix ? DotPitchMm * 0.1f : Spacing);
|
||||
GpuVoxelMID->SetScalarParameterValue(VoxelSpacingParameterName, ActiveSpacing);
|
||||
GpuVoxelMID->SetVectorParameterValue(VolumeCenterParameterName, FLinearColor(Center.X, Center.Y, Center.Z, 1.0f));
|
||||
GpuVoxelMID->SetVectorParameterValue(VolumeExtentParameterName, FLinearColor(VolumeExtent.X, VolumeExtent.Y, VolumeExtent.Z, 1.0f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue