Skip to content

Commit

Permalink
Harmonize Composition in Position / Velocity Blocks (#44)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
4 people authored and GitHub Enterprise committed Oct 24, 2020
1 parent bba06b6 commit a120833
Show file tree
Hide file tree
Showing 48 changed files with 33,133 additions and 170 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,119 @@ public void CheckBuiltinExpressionListed([ValueSource("CheckAllBuiltinExpression
var operation = (UnityEngine.VFX.VFXExpressionOperation)Enum.Parse(typeof(UnityEngine.VFX.VFXExpressionOperation), expressionName);
var referenceExpression = VFXBuiltInExpression.Find(operation);
Assert.IsTrue(VFXDynamicBuiltInParameter.s_BuiltInInfo.Values.Any(o => o.expression == referenceExpression));
}

public struct ApplyAddressingModeTestCase
{
public ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode _mode, uint _count)
{
mode = _mode;
count = _count;
expectedSequence = new uint[Mathf.Max(50, 7 * (int)_count)];

//Naive implementation for reference
if (mode == VFXOperatorUtility.SequentialAddressingMode.Clamp)
{
for (uint i = 0; i < expectedSequence.Length; ++i)
{
expectedSequence[i] = i < count ? i : count - 1;
}
}
else if (mode == VFXOperatorUtility.SequentialAddressingMode.Wrap)
{
uint current = 0u;
for (uint i = 0; i < expectedSequence.Length; ++i)
{
expectedSequence[i] = current;
current++;
if (current >= count)
current = 0u;
}
}
else if (mode == VFXOperatorUtility.SequentialAddressingMode.Mirror)
{
uint current = 0u;
bool increment = true;
for (uint i = 0; i < expectedSequence.Length; ++i)
{
expectedSequence[i] = current;
if (increment)
{
current++;
if (current >= count)
{
increment = false;
current = count > 2u ? count - 2u : 0u;
}
}
else
{
if (current == 0u)
{
increment = true;
current = count == 1u ? 0u : 1u;
}
else
{
current--;
}
}
}
}
}

public VFXOperatorUtility.SequentialAddressingMode mode;
public uint count;
public uint[] expectedSequence;

public override string ToString()
{
return string.Format("{0}_{1}_{2}", mode.ToString(), count, expectedSequence.Length);
}
}


static readonly ApplyAddressingModeTestCase[] ApplyAddressingModeTestCase_ValueSource =
{
//The 0 case is always undefined
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Wrap, 1u),
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Wrap, 4u),
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Clamp, 1u),
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Clamp, 4u),
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 1u),
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 2u),
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 3u),
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 4u),
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 7u),
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 8u),
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 9u),
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 13u),
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 15u),
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 27u),
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 32u),
new ApplyAddressingModeTestCase(VFXOperatorUtility.SequentialAddressingMode.Mirror, 33u),
};

[Test]
public void CheckExpectedSequence_ApplyAddressingMode([ValueSource("ApplyAddressingModeTestCase_ValueSource")] ApplyAddressingModeTestCase addressingMode)
{
var computedSequence = new uint[addressingMode.expectedSequence.Length];
for (uint index = 0u; index < computedSequence.Length; ++index)
{
var indexExpr = VFXValue.Constant(index);
var countExpr = VFXValue.Constant(addressingMode.count);
var computed = VFXOperatorUtility.ApplyAddressingMode(indexExpr, countExpr, addressingMode.mode);

var context = new VFXExpression.Context(VFXExpressionContextOption.CPUEvaluation);
var result = context.Compile(computed);

computedSequence[index] = result.Get<uint>();
}

for (uint index = 0u; index < computedSequence.Length; ++index)
{
Assert.AreEqual(addressingMode.expectedSequence[index], computedSequence[index]);
}
}
}
}
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ EditorBuildSettings:
- enabled: 1
path: Packages/com.unity.testing.visualeffectgraph/Scenes/014_ScreenSpaceSize.unity
guid: 61def4e00f202154a972b59fa6fb735e
- enabled: 1
path: Packages/com.unity.testing.visualeffectgraph/Scenes/014_PositionBlock.unity
guid: 42a36d7781122534f9ce00fa769bdd5c
- enabled: 1
path: Assets/AllTests/VFXTests/GraphicsTests/101_Exposure.unity
guid: 4125f3630764c6a43a752a73908fa0ee
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a120833

Please sign in to comment.