Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion com.unity.visualeffectgraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [7.5.3] - 2021-01-11
### Fixed
- Unexpected shaderGraph reference lost while upgrading package [Case 1297186](https://issuetracker.unity3d.com/product/unity/issues/guid/1297186/)
Version Updated
- Exclude Operator, Context, Block and Subgraph from Preset [Case 1232309](https://issuetracker.unity3d.com/product/unity/issues/guid/1232309/)
- Incorrect path on Linux while targetting Android, IOS or WebGL [Case 1279750](https://issuetracker.unity3d.com/product/unity/issues/guid/1279750/)
- Fix [Case 1223747](https://fogbugz.unity3d.com/f/cases/1223747/)
- Prevent pasting context within operator/block subgraph [Case 1235269](https://issuetracker.unity3d.com/product/unity/issues/guid/1235269/)
- VFXEventBinderBase throwing a null reference exception in runtime

## [7.5.2] - 2020-11-16
### Fixed
Expand Down
4 changes: 4 additions & 0 deletions com.unity.visualeffectgraph/Documentation~/PointCaches.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Point cache Assets follow the Open Source [Point Cache](https://github.com/peewe

![](Images/PointCacheImporter.png)

### Limitations and Caveats

Currently, only the `float` and `uchar` property types are supported by the Importer. Any property of other types will return an error.

## Point Cache Operator

Point cache Assets can be referenced in a Point Cache Operator so it displays its point count and the list of Attribute Maps contained in the Point Cache Asset. The Number and the Name of the Outputs will dynamically change depending on the Asset set in the settings field.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static private string FormatPath(string path)
{
return Path.GetFullPath(path)
.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)
#if !UNITY_STANDALONE_LINUX
#if !UNITY_EDITOR_LINUX
.ToLowerInvariant()
#endif
;
Expand Down
2 changes: 1 addition & 1 deletion com.unity.visualeffectgraph/Editor/Core/VFXLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public virtual IEnumerable<IEnumerable<KeyValuePair<string, object>>> ComputeVar

// Attribute used to register VFX type to library
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
class VFXInfoAttribute : Attribute
class VFXInfoAttribute : ExcludeFromPresetAttribute
{
public VFXInfoAttribute()
{
Expand Down
19 changes: 16 additions & 3 deletions com.unity.visualeffectgraph/Editor/GraphView/Views/VFXPaste.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,21 @@ void PasteAll(VFXViewController viewController, Vector2 center, ref Serializable
pasteOffset = (serializableGraph.bounds.width > 0 && serializableGraph.bounds.height > 0) ? center - serializableGraph.bounds.center : Vector2.zero;
MakePasteOffsetUnique(viewController, serializableGraph);

// Paste all nodes
PasteContexts(viewController, ref serializableGraph);
// Can't paste context within subgraph block/operator
if (viewController.model.visualEffectObject is VisualEffectSubgraphOperator || viewController.model.visualEffectObject is VisualEffectSubgraphBlock)
{
if (serializableGraph.contexts != null)
{
var count = serializableGraph.contexts.Count();
if (count != 0)
Debug.LogWarningFormat("{0} context{1} been skipped during the paste operation. Contexts aren't available in this kind of subgraph.", count, count > 1 ? "s have" : " has");
}
}
else
{
PasteContexts(viewController, ref serializableGraph);
}

PasteOperators(viewController, ref serializableGraph);
PasteParameters(viewController, ref serializableGraph);

Expand Down Expand Up @@ -617,7 +630,7 @@ private void RegisterContexts(VFXViewController viewController)
var block = newContexts[i].Value[j];
if (block != null)
{
VFXBlockController blockController = controller.blockControllers.First(t => t.model == block);
VFXBlockController blockController = controller.blockControllers.FirstOrDefault(t => t.model == block);
if (blockController != null)
newControllers[GetBlockID((uint)i, (uint)j)] = blockController;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace UnityEditor.VFX
{
[ExcludeFromPreset]
class VFXSubgraphContext : VFXContext
{
[VFXSetting, SerializeField]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ public override void OnImportAsset(AssetImportContext ctx)
TextureFormat surfaceFormat = TextureFormat.Alpha8;
switch (kvp.Value.PropertyType)
{
case "byte":
case "uchar":
if (kvp.Value.Size == 1) surfaceFormat = TextureFormat.Alpha8;
else surfaceFormat = TextureFormat.RGBA32;
break;
case "float":
if (kvp.Value.Size == 1) surfaceFormat = TextureFormat.RHalf;
else surfaceFormat = TextureFormat.RGBAHalf;
break;
default: throw new NotImplementedException("Types other than byte/float are not supported yet");
default: throw new NotImplementedException("Types other than uchar/float are not supported yet");
}

Texture2D surface = new Texture2D(width, height, surfaceFormat, false);
Expand All @@ -150,13 +150,13 @@ public override void OnImportAsset(AssetImportContext ctx)
float val = 0.0f;
switch (prop.PropertyType)
{
case "byte":
case "uchar":
val = Mathf.Clamp01(((byte)pcache.buckets[idx][i]) / 255.0f);
break;
case "float":
val = ((float)pcache.buckets[idx][i]);
break;
default: throw new NotImplementedException("Types other than byte/float are not supported yet");
default: throw new NotImplementedException("Types other than uchar/float are not supported yet");
}

SetPropValue(prop.Index, outValues, prop.OutProperty, val);
Expand Down
29 changes: 18 additions & 11 deletions com.unity.visualeffectgraph/Editor/Utilities/pCache/PCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ public void SaveToFile(string filePath, Format format = Format.Binary)
var prop = properties[j];
switch (prop.Type)
{
case "byte":
case "char":
binaryWriter.Write((sbyte)buckets[j][i]); break;
case "uchar":
binaryWriter.Write((byte)buckets[j][i]); break;
case "short":
binaryWriter.Write((short)buckets[j][i]); break;
Expand Down Expand Up @@ -321,7 +323,9 @@ public void SaveToFile(string filePath, Format format = Format.Binary)
var prop = properties[j];
switch (prop.Type)
{
case "byte":
case "char":
sb.Append(((sbyte)buckets[j][i]).ToString(CultureInfo.InvariantCulture)); break;
case "uchar":
sb.Append(((byte)buckets[j][i]).ToString(CultureInfo.InvariantCulture)); break;
case "short":
sb.Append(((short)buckets[j][i]).ToString(CultureInfo.InvariantCulture)); break;
Expand Down Expand Up @@ -448,13 +452,14 @@ public static PCache FromFile(string filename)
var prop = data.properties[j];
switch (prop.Type)
{
case "short": data.buckets[j].Add(binaryReader.ReadInt16()); break;
case "ushort": data.buckets[j].Add(binaryReader.ReadUInt16()); break;
case "int": data.buckets[j].Add(binaryReader.ReadInt32()); break;
case "uint": data.buckets[j].Add(binaryReader.ReadUInt32()); break;
case "byte": data.buckets[j].Add(binaryReader.ReadChar()); break;
case "float": data.buckets[j].Add(binaryReader.ReadSingle()); break;
case "double": data.buckets[j].Add(binaryReader.ReadDouble()); break;
case "short": data.buckets[j].Add(binaryReader.ReadInt16()); break;
case "ushort": data.buckets[j].Add(binaryReader.ReadUInt16()); break;
case "int": data.buckets[j].Add(binaryReader.ReadInt32()); break;
case "uint": data.buckets[j].Add(binaryReader.ReadUInt32()); break;
case "char": data.buckets[j].Add(binaryReader.ReadSByte()); break;
case "uchar": data.buckets[j].Add(binaryReader.ReadByte()); break;
case "float": data.buckets[j].Add(binaryReader.ReadSingle()); break;
case "double": data.buckets[j].Add(binaryReader.ReadDouble()); break;
}
}
}
Expand Down Expand Up @@ -486,7 +491,8 @@ public static PCache FromFile(string filename)
case "ushort": data.buckets[j].Add(ushort.Parse(elements[j], CultureInfo.InvariantCulture)); break;
case "int": data.buckets[j].Add(int.Parse(elements[j], CultureInfo.InvariantCulture)); break;
case "uint": data.buckets[j].Add(uint.Parse(elements[j], CultureInfo.InvariantCulture)); break;
case "byte": data.buckets[j].Add(byte.Parse(elements[j], CultureInfo.InvariantCulture)); break;
case "char": data.buckets[j].Add(sbyte.Parse(elements[j], CultureInfo.InvariantCulture)); break;
case "uchar": data.buckets[j].Add(byte.Parse(elements[j], CultureInfo.InvariantCulture)); break;
case "float": data.buckets[j].Add(float.Parse(elements[j], CultureInfo.InvariantCulture)); break;
case "double": data.buckets[j].Add(double.Parse(elements[j], CultureInfo.InvariantCulture)); break;
}
Expand Down Expand Up @@ -580,7 +586,8 @@ private static int GetPropertySize(string type)

private static Dictionary<string, int> TypeSize = new Dictionary<string, int>()
{
{ "byte", 1 },
{ "char", 1 },
{ "uchar", 1 },
{ "short", 2 },
{ "ushort", 2 },
{ "int", 4 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ abstract class VFXEventBinderBase : MonoBehaviour
[SerializeField, HideInInspector]
protected VFXEventAttribute eventAttribute;

protected void OnEnable()
{
UpdateCacheEventAttribute();
}

private void OnValidate()
{
UpdateCacheEventAttribute();
}

private void UpdateCacheEventAttribute()
{
if (target != null)
eventAttribute = target.CreateVFXEventAttribute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ float3 tangentWS = i.VFX_VARYING_TANGENT;
float3 bitangentWS = cross(i.VFX_VARYING_TANGENT,i.VFX_VARYING_NORMAL);

#if defined(VFX_VARYING_BENTFACTORS) && USE_NORMAL_BENDING
float3 bentFactors = float3(i.VFX_VARYING_BENTFACTORS.xy,sqrt(1.0f - dot(i.VFX_VARYING_BENTFACTORS,i.VFX_VARYING_BENTFACTORS)));
float3 bentFactors = float3(i.VFX_VARYING_BENTFACTORS.xy,sqrt(max(0.0f,1.0f - dot(i.VFX_VARYING_BENTFACTORS,i.VFX_VARYING_BENTFACTORS))));
normalWS = tangentWS * bentFactors.x + bitangentWS * bentFactors.y + normalWS * bentFactors.z;
tangentWS = normalize(cross(normalWS,bitangentWS));
bitangentWS = cross(tangentWS,normalWS);
Expand Down