Fix physical Samba preview scale

This commit is contained in:
krustophski 2026-08-07 06:50:53 +03:00
parent fa8ac9aea8
commit e38d539197
7 changed files with 37 additions and 26 deletions

View file

@ -144,20 +144,20 @@ else if (mode >= 2.5 && mode < 3.5)
else if (mode >= 3.5)
{
float3 q = (WorldPos - VolumeCenter.xyz) / max(VolumeExtent.xyz, 1.0);
q.y += 0.05 * sin(t * 2.2);
q.z += 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 torso = 1.0 - length(float3(q.x * 2.05, q.y * 3.2, q.z * 1.75));
float head = 1.0 - length(float3(q.x * 5.6, q.y * 5.6, (q.z - 0.42) * 5.6));
float leftArm = 1.0 - abs(q.x + 0.35 + shoulder * 0.18) * 5.0 - abs(q.z - 0.14 - shoulder * 0.12) * 4.0 - abs(q.y) * 4.8;
float rightArm = 1.0 - abs(q.x - 0.35 + shoulder * 0.18) * 5.0 - abs(q.z - 0.10 + shoulder * 0.12) * 4.0 - abs(q.y) * 4.8;
float leftLeg = 1.0 - abs(q.x + 0.18 - hip * 0.16) * 5.6 - abs(q.z + 0.38 + hip * 0.06) * 3.7 - abs(q.y) * 4.8;
float rightLeg = 1.0 - abs(q.x - 0.18 - hip * 0.16) * 5.6 - abs(q.z + 0.38 - hip * 0.06) * 3.7 - abs(q.y) * 4.8;
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 pulse = 0.72 + 0.28 * sin(t * 3.4 + q.z * 9.0);
color = mask * pulse * lerp(float3(0.0, 0.85, 1.0), float3(1.0, 0.92, 0.02), saturate(q.z + 0.45));
}
float safeGamma = max(GammaValue, 0.001);
@ -321,22 +321,22 @@ for (int i = 0; i < Steps; ++i)
else if (PatternMode >= 3.5)
{
float3 q = (p - center) / max(extent, 1.0);
q.y += 0.05 * sin(t * 2.2);
q.z += 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.y * 2.15, q.z * 4.4));
float head = 1.0 - length(float3(q.x * 8.0, (q.y - 0.43) * 8.0, q.z * 8.0));
float torso = 1.0 - length(float3(q.x * 2.05, q.y * 3.2, q.z * 1.75));
float head = 1.0 - length(float3(q.x * 5.6, q.y * 5.6, (q.z - 0.42) * 5.6));
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 leftArm = 1.0 - abs(q.x + 0.35 + shoulder * 0.18) * 5.0 - abs(q.z - 0.14 - shoulder * 0.12) * 4.0 - abs(q.y) * 4.8;
float rightArm = 1.0 - abs(q.x - 0.35 + shoulder * 0.18) * 5.0 - abs(q.z - 0.10 + shoulder * 0.12) * 4.0 - abs(q.y) * 4.8;
float leftLeg = 1.0 - abs(q.x + 0.18 - hip * 0.16) * 5.6 - abs(q.z + 0.38 + hip * 0.06) * 3.7 - abs(q.y) * 4.8;
float rightLeg = 1.0 - abs(q.x - 0.18 - hip * 0.16) * 5.6 - abs(q.z + 0.38 - hip * 0.06) * 3.7 - abs(q.y) * 4.8;
sourceMask = saturate(max(max(torso, head), max(max(leftArm, rightArm), max(leftLeg, rightLeg))));
float rim = saturate(1.0 - abs(q.z) * 3.0);
float pulse = 0.65 + 0.35 * sin(t * 3.4 + q.y * 9.0);
color = sourceMask * pulse * lerp(float3(0.02, 0.65, 1.0), float3(1.0, 0.85, 0.08), saturate(q.y + 0.45)) * rim;
float pulse = 0.72 + 0.28 * sin(t * 3.4 + q.z * 9.0);
color = sourceMask * pulse * lerp(float3(0.0, 0.85, 1.0), float3(1.0, 0.92, 0.02), saturate(q.z + 0.45)) * rim;
}
float sampleWeight = led * sourceMask * 0.18;

View file

@ -948,6 +948,15 @@ void ALedVolumeDisplayActor::RebuildPhysicalMatrixInstances()
const FVector LedInstanceScale = VoxelShape == ELedVoxelShape::Lens
? FVector(LedScale, LedScale, LedScale * 0.45f)
: FVector(LedScale);
int32 PhysicalStride = 1;
if (const UWorld* World = GetWorld(); World && !World->IsGameWorld())
{
PhysicalStride = GetClampedPreviewStride();
}
const int32 CountX = FMath::DivideAndRoundUp(Dimensions.Width, PhysicalStride);
const int32 CountY = FMath::DivideAndRoundUp(Dimensions.Height, PhysicalStride);
const int32 CountZ = FMath::DivideAndRoundUp(Dimensions.Depth, PhysicalStride);
const int32 PhysicalLedCount = CountX * CountY * CountZ;
GpuVoxelInstances->SetStaticMesh(ResolveVoxelMesh());
if (LedMaterial)
@ -956,16 +965,16 @@ void ALedVolumeDisplayActor::RebuildPhysicalMatrixInstances()
GpuVoxelMID = nullptr;
}
GpuVoxelInstances->ClearInstances();
GpuVoxelInstances->PreAllocateInstancesMemory(static_cast<int32>(RequestedCount));
GpuVoxelInstances->PreAllocateInstancesMemory(PhysicalLedCount);
constexpr int32 LedBatchSize = 32768;
TArray<FTransform> LedBatch;
LedBatch.Reserve(LedBatchSize);
for (int32 Z = 0; Z < Dimensions.Depth; ++Z)
for (int32 Z = 0; Z < Dimensions.Depth; Z += PhysicalStride)
{
for (int32 Y = 0; Y < Dimensions.Height; ++Y)
for (int32 Y = 0; Y < Dimensions.Height; Y += PhysicalStride)
{
for (int32 X = 0; X < Dimensions.Width; ++X)
for (int32 X = 0; X < Dimensions.Width; X += PhysicalStride)
{
LedBatch.Emplace(FRotator::ZeroRotator, PhysicalLedLocalPosition(X, Y, Z), LedInstanceScale);
if (LedBatch.Num() == LedBatchSize)
@ -992,11 +1001,11 @@ void ALedVolumeDisplayActor::RebuildPhysicalMatrixInstances()
WireMID = nullptr;
}
const int32 SegmentCount = FMath::Clamp(WireSegmentsPerString, 1, 32);
PhysicalWireInstances->PreAllocateInstancesMemory(Dimensions.Width * Dimensions.Depth * SegmentCount);
PhysicalWireInstances->PreAllocateInstancesMemory(CountX * CountZ * SegmentCount);
const float WireRadiusScale = (WireThicknessMm * 0.1f) / 100.0f;
for (int32 Z = 0; Z < Dimensions.Depth; ++Z)
for (int32 Z = 0; Z < Dimensions.Depth; Z += PhysicalStride)
{
for (int32 X = 0; X < Dimensions.Width; ++X)
for (int32 X = 0; X < Dimensions.Width; X += PhysicalStride)
{
for (int32 SegmentIndex = 0; SegmentIndex < SegmentCount; ++SegmentIndex)
{
@ -1161,7 +1170,9 @@ void ALedVolumeDisplayActor::UpdateMaterialParameters()
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();
const FVector Center = GeometryMode == ELedDisplayGeometryMode::PhysicalMatrix
? GetActorLocation() + FVector(0.0f, 0.0f, -(Dimensions.Height - 1) * ActiveSpacing * 0.5f)
: GetActorLocation();
GpuVoxelMID->SetScalarParameterValue(BrightnessParameterName, Brightness);
GpuVoxelMID->SetScalarParameterValue(GammaParameterName, Gamma);
GpuVoxelMID->SetVectorParameterValue(LedColorParameterName, SolidColor);