Skip to content

Commit a120833

Browse files
Thomas IchépeeweekPaulDemeulenaerejulienf-unity
authored andcommitted
Harmonize Composition in Position / Velocity Blocks (#44)
* Base refactor + Attempt to get position from AABox (not working for thickness ATM) * Fixed cone syntax issues + correct computation of AABox direction * Added Variant providers + Composition in Sequential * Updated Variants for Shape Sequential Blocks * Harmonized Namings + added composition to Position Depth * Updated Changelog * Fixes for PR * Fixed Blend Composition in Sequential * Added Direction to PositionSequential * Fixes in Position Circle / Set Blend factor in shapes to 1.0 by default * Used Absolute Box size as expression * Propal for https://github.cds.internal.unity3d.com/unity/vfx-graphics/pull/44/files/e029bb9ec37555e70af21a97399774667030c031#r61533 Use case by case approach for direction of AABox * *Temp add test data for graphicTest * Fix ApplyAddressingMode : clamp & mirror was overflowing, mirror has also a wrong pattern * Edit graphicTest * Move 014 to common package * Add 014_PositionBlock in editor test listing * Precompute line_direction in PositionLine Fix issue https://github.cds.internal.unity3d.com/unity/vfx-graphics/pull/44/files#r67908 * *Add reference images * Fix editor test (wrong reference data) * Fix issue introduced at 9c54056 : Looping correctly the circle See also : https://unity.slack.com/archives/G1BTWN88Z/p1598508170069200?thread_ts=1598429838.039200&cid=G1BTWN88Z * Probably uploaded the wrong image reference for standalone * *Update reference images (I think I mess up twice, I should double check the change in motionVector) * Fix build (VFXExpressionCondition now supports uint) * *Temp* Delete motion vector reference image, should regenerate them from yamato. * Readd reference image using yamato result at b9a04b7 * *Update changelog Fix issue : https://github.cds.internal.unity3d.com/unity/vfx-graphics/pull/44#discussion_r70582 * Fix PositionTorus when used in vertex shader * Fix multiple definition of UNITY_PI * Fix changelog bad automatic merge * Fix incorrect volume Base radius while computing volume factor on sphere & circle : use fix approach from https://github.cds.internal.unity3d.com/unity/vfx-graphics/pull/89 using name instead of index See : https://github.cds.internal.unity3d.com/unity/vfx-graphics/pull/44#issuecomment-28990 & https://docs.google.com/document/d/1RAVkfmMQA9D_hKkJyt6PKOgRs8JHkjlYRhcfBtIU1Ag/edit?disco=AAAAJ7Z4S18 Co-authored-by: Thomas ICHÉ <peeweek@gmail.com> Co-authored-by: Paul Demeulenaere <pauld@unity3d.com> Co-authored-by: Julien Fryer <julienf@unity3d.com>
1 parent bba06b6 commit a120833

File tree

48 files changed

+33133
-170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+33133
-170
lines changed

TestProjects/VisualEffectGraph_HDRP/Assets/AllTests/Editor/Tests/VFXOperatorUtilityTests.cs

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,119 @@ public void CheckBuiltinExpressionListed([ValueSource("CheckAllBuiltinExpression
637637
var operation = (UnityEngine.VFX.VFXExpressionOperation)Enum.Parse(typeof(UnityEngine.VFX.VFXExpressionOperation), expressionName);
638638
var referenceExpression = VFXBuiltInExpression.Find(operation);
639639
Assert.IsTrue(VFXDynamicBuiltInParameter.s_BuiltInInfo.Values.Any(o => o.expression == referenceExpression));
640+
}
640641

642+
public struct ApplyAddressingModeTestCase
643+
{
644+
public ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode _mode, uint _count)
645+
{
646+
mode = _mode;
647+
count = _count;
648+
expectedSequence = new uint[Mathf.Max(50, 7 * (int)_count)];
649+
650+
//Naive implementation for reference
651+
if (mode == VFXOperatorUtility.SequentialAddressingMode.Clamp)
652+
{
653+
for (uint i = 0; i < expectedSequence.Length; ++i)
654+
{
655+
expectedSequence[i] = i < count ? i : count - 1;
656+
}
657+
}
658+
else if (mode == VFXOperatorUtility.SequentialAddressingMode.Wrap)
659+
{
660+
uint current = 0u;
661+
for (uint i = 0; i < expectedSequence.Length; ++i)
662+
{
663+
expectedSequence[i] = current;
664+
current++;
665+
if (current >= count)
666+
current = 0u;
667+
}
668+
}
669+
else if (mode == VFXOperatorUtility.SequentialAddressingMode.Mirror)
670+
{
671+
uint current = 0u;
672+
bool increment = true;
673+
for (uint i = 0; i < expectedSequence.Length; ++i)
674+
{
675+
expectedSequence[i] = current;
676+
if (increment)
677+
{
678+
current++;
679+
if (current >= count)
680+
{
681+
increment = false;
682+
current = count > 2u ? count - 2u : 0u;
683+
}
684+
}
685+
else
686+
{
687+
if (current == 0u)
688+
{
689+
increment = true;
690+
current = count == 1u ? 0u : 1u;
691+
}
692+
else
693+
{
694+
current--;
695+
}
696+
}
697+
}
698+
}
699+
}
700+
701+
public VFXOperatorUtility.SequentialAddressingMode mode;
702+
public uint count;
703+
public uint[] expectedSequence;
704+
705+
public override string ToString()
706+
{
707+
return string.Format("{0}_{1}_{2}", mode.ToString(), count, expectedSequence.Length);
708+
}
709+
}
710+
711+
712+
static readonly ApplyAddressingModeTestCase[] ApplyAddressingModeTestCase_ValueSource =
713+
{
714+
//The 0 case is always undefined
715+
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Wrap, 1u),
716+
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Wrap, 4u),
717+
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Clamp, 1u),
718+
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Clamp, 4u),
719+
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 1u),
720+
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 2u),
721+
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 3u),
722+
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 4u),
723+
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 7u),
724+
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 8u),
725+
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 9u),
726+
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 13u),
727+
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 15u),
728+
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 27u),
729+
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 32u),
730+
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 33u),
731+
};
732+
733+
[Test]
734+
public void CheckExpectedSequence_ApplyAddressingMode([ValueSource("ApplyAddressingModeTestCase_ValueSource")] ApplyAddressingModeTestCase addressingMode)
735+
{
736+
var computedSequence = new uint[addressingMode.expectedSequence.Length];
737+
for (uint index = 0u; index < computedSequence.Length; ++index)
738+
{
739+
var indexExpr = VFXValue.Constant(index);
740+
var countExpr = VFXValue.Constant(addressingMode.count);
741+
var computed = VFXOperatorUtility.ApplyAddressingMode(indexExpr, countExpr, addressingMode.mode);
742+
743+
var context = new VFXExpression.Context(VFXExpressionContextOption.CPUEvaluation);
744+
var result = context.Compile(computed);
745+
746+
computedSequence[index] = result.Get<uint>();
747+
}
748+
749+
for (uint index = 0u; index < computedSequence.Length; ++index)
750+
{
751+
Assert.AreEqual(addressingMode.expectedSequence[index], computedSequence[index]);
752+
}
641753
}
642754
}
643755
}
Loading
Loading

TestProjects/VisualEffectGraph_HDRP/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/014_PositionBlock.png.meta

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Loading
Loading
Loading

TestProjects/VisualEffectGraph_HDRP/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/None/014_PositionBlock.png.meta

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Loading

TestProjects/VisualEffectGraph_HDRP/ProjectSettings/EditorBuildSettings.asset

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ EditorBuildSettings:
5050
- enabled: 1
5151
path: Packages/com.unity.testing.visualeffectgraph/Scenes/014_ScreenSpaceSize.unity
5252
guid: 61def4e00f202154a972b59fa6fb735e
53+
- enabled: 1
54+
path: Packages/com.unity.testing.visualeffectgraph/Scenes/014_PositionBlock.unity
55+
guid: 42a36d7781122534f9ce00fa769bdd5c
5356
- enabled: 1
5457
path: Assets/AllTests/VFXTests/GraphicsTests/101_Exposure.unity
5558
guid: 4125f3630764c6a43a752a73908fa0ee

0 commit comments

Comments
 (0)