public static void AreEqual(int4x4 a, int4x4 b) { AreEqual(a.c0, b.c0); AreEqual(a.c1, b.c1); AreEqual(a.c2, b.c2); AreEqual(a.c3, b.c3); }
/// <summary> /// Constructs this matrix from a int4x4. Non-overwritten fields are from an Identity matrix. /// </summary> public int2x2(int4x4 m) { this.m00 = m.m00; this.m01 = m.m01; this.m10 = m.m10; this.m11 = m.m11; }
static void TestInt4x4_Select_WorksCorrectly() { var zero = int4x4.zero; var identity = int4x4.identity; var one = (int4x4)1; var zebraLoInts = new int4x4(1, 0, 1, 0); var zebraHiInts = new int4x4(0, 1, 0, 1); var zebraLoIdentity = new int4x4(new int4(1, 0, 0, 0), 0, new int4(0, 0, 1, 0), 0); var zebraHiIdentity = new int4x4(0, new int4(0, 1, 0, 0), 0, new int4(0, 0, 0, 1)); var t = new bool4x4(true); var f = new bool4x4(false); var zebraLo = new bool4x4(true, false, true, false); var zebraHi = new bool4x4(false, true, false, true); Validate(Maths.Select(zero, one, f), zero); Validate(Maths.Select(zero, one, t), one); Validate(Maths.Select(zero, one, zebraLo), zebraLoInts); Validate(Maths.Select(zero, one, zebraHi), zebraHiInts); Validate(Maths.Select(zero, identity, f), zero); Validate(Maths.Select(zero, identity, t), identity); Validate(Maths.Select(zero, identity, zebraLo), zebraLoIdentity); Validate(Maths.Select(zero, identity, zebraHi), zebraHiIdentity); }
public half4x4(int4x4 v) { this.c0 = new half4(v.c0); this.c1 = new half4(v.c1); this.c2 = new half4(v.c2); this.c3 = new half4(v.c3); }
public fp4x4(int4x4 v) { this.c0 = (fp4)v.c0; this.c1 = (fp4)v.c1; this.c2 = (fp4)v.c2; this.c3 = (fp4)v.c3; }
public static void AreEqual(int4x4 expected, int4x4 actual) { AreEqual(expected.c0, actual.c0); AreEqual(expected.c1, actual.c1); AreEqual(expected.c2, actual.c2); AreEqual(expected.c3, actual.c3); }
public int GetTex(int4x4 guidValue, bool isNormal = false) { AssetReference guid = clusterRes.GetReference(ref guidValue); int index; if (guidToIndex.TryGetValue(guid, out index)) { usageCount[index]++; } else { if (indexPool.Length <= 0) { Debug.Log("Texture Pool out of Range!!"); return(0); } index = indexPool[indexPool.Length - 1]; indexPool.RemoveLast(); usageCount[index] = 1; guidToIndex.Add(guid, index); clusterRes.AddLoadCommand(guid, rt, index, isNormal); //TODO //Streaming Load Texture } return(index); }
public static int4x4 Select(int4x4 a, int4x4 b, bool4x4 c) { return(new int4x4( math.select(a.c0, b.c0, c.c0), math.select(a.c1, b.c1, c.c1), math.select(a.c2, b.c2, c.c2), math.select(a.c3, b.c3, c.c3))); }
/// <summary> /// Constructs this matrix from a int4x4. Non-overwritten fields are from an Identity matrix. /// </summary> public int3x2(int4x4 m) { this.m00 = m.m00; this.m01 = m.m01; this.m10 = m.m10; this.m11 = m.m11; this.m20 = m.m20; this.m21 = m.m21; }
/// <summary> /// Constructs this matrix from a int4x4. Non-overwritten fields are from an Identity matrix. /// </summary> public int2x3(int4x4 m) { this.m00 = m.m00; this.m01 = m.m01; this.m02 = m.m02; this.m10 = m.m10; this.m11 = m.m11; this.m12 = m.m12; }
/// <summary> /// Constructs this matrix from a int4x4. Non-overwritten fields are from an Identity matrix. /// </summary> public int2x4(int4x4 m) { this.m00 = m.m00; this.m01 = m.m01; this.m02 = m.m02; this.m03 = m.m03; this.m10 = m.m10; this.m11 = m.m11; this.m12 = m.m12; this.m13 = m.m13; }
/// <summary> /// Constructs this matrix from a int4x4. Non-overwritten fields are from an Identity matrix. /// </summary> public int3x3(int4x4 m) { this.m00 = m.m00; this.m01 = m.m01; this.m02 = m.m02; this.m10 = m.m10; this.m11 = m.m11; this.m12 = m.m12; this.m20 = m.m20; this.m21 = m.m21; this.m22 = m.m22; }
/// <summary> /// Constructs this matrix from a int4x4. Non-overwritten fields are from an Identity matrix. /// </summary> public int3x4(int4x4 m) { this.m00 = m.m00; this.m01 = m.m01; this.m02 = m.m02; this.m03 = m.m03; this.m10 = m.m10; this.m11 = m.m11; this.m12 = m.m12; this.m13 = m.m13; this.m20 = m.m20; this.m21 = m.m21; this.m22 = m.m22; this.m23 = m.m23; }
public void RemoveTex(int4x4 guidValue) { AssetReference guid = clusterRes.GetReference(ref guidValue); int index; if (guidToIndex.TryGetValue(guid, out index)) { usageCount[index]--; if (usageCount[index] <= 0) { indexPool.Add(index); guidToIndex.Remove(guid); } } }
private static void CustomVisit(ref int4x4 i) { LogVisit(i); GUILayout.Label(name); EditorGUI.indentLevel++; var field0 = EditorGUILayout.Vector4Field("", ConvertToVector4(i[0])); var field1 = EditorGUILayout.Vector4Field("", ConvertToVector4(i[1])); var field2 = EditorGUILayout.Vector4Field("", ConvertToVector4(i[2])); var field3 = EditorGUILayout.Vector4Field("", ConvertToVector4(i[3])); i[0] = ConvertVector4ToInt4(field0); i[1] = ConvertVector4ToInt4(field1); i[2] = ConvertVector4ToInt4(field2); i[3] = ConvertVector4ToInt4(field3); EditorGUI.indentLevel--; }
public AssetReference GetReference(ref int4x4 guid) { if (!referenceCacheDict.isCreated) { referenceCacheDict = new NativeDictionary <int4x4, int, Int4x4Equal>(100, Allocator.Persistent, new Int4x4Equal()); } int index; if (referenceCacheDict.Get(guid, out index)) { return(allReferenceCache[index]); } string guidCache = new string((char *)guid.Ptr(), 0, 32); referenceCacheDict.Add(guid, allReferenceCache.Count); AssetReference aref = new AssetReference(guidCache); allReferenceCache.Add(aref); return(aref); }
public static fp4x4 fp4x4(int4x4 v) { return(new fp4x4(v)); }
static void Validate(int4x4 test, int4x4 control) { Assert.That(test.Equals(control), $"There was an error in selecting the ints! {test} {control}"); }
public unsafe static Dictionary <Material, int> GetMaterialsData(MeshRenderer[] allRenderers, ref SceneStreamLoader loader) { float3 ColorToVector(Color c) { return(pow(float3(c.r, c.g, c.b), 2.2f)); } float2 GetVector2(float4 vec) { return(float2(vec.x, vec.y)); } var dict = new Dictionary <Material, int>(allRenderers.Length); loader.allProperties = new NativeList <MaterialProperties>(allRenderers.Length, Unity.Collections.Allocator.Persistent); var albedoTexs = new List <Texture>(allRenderers.Length); var normalTexs = new List <Texture>(allRenderers.Length); var smoTexs = new List <Texture>(allRenderers.Length); var emissionTex = new List <Texture>(allRenderers.Length); var heightTex = new List <Texture>(allRenderers.Length); var secondAlbedoTex = new List <Texture>(allRenderers.Length); var secondBumpTex = new List <Texture>(allRenderers.Length); var secondSpecTex = new List <Texture>(allRenderers.Length); var albedoDict = new Dictionary <Texture, int>(allRenderers.Length); var normalDict = new Dictionary <Texture, int>(allRenderers.Length); var smoDict = new Dictionary <Texture, int>(allRenderers.Length); var emissionDict = new Dictionary <Texture, int>(allRenderers.Length); var heightDict = new Dictionary <Texture, int>(allRenderers.Length); var secondAlbedoDict = new Dictionary <Texture, int>(allRenderers.Length); var secondBumpDict = new Dictionary <Texture, int>(allRenderers.Length); var secondSpecDict = new Dictionary <Texture, int>(allRenderers.Length); int len = 0; int GetTextureIndex(List <Texture> lst, Dictionary <Texture, int> texDict, Texture tex) { int ind = -1; if (tex) { if (!texDict.TryGetValue(tex, out ind)) { ind = lst.Count; lst.Add(tex); texDict.Add(tex, ind); } } return(ind); } foreach (var r in allRenderers) { var ms = r.sharedMaterials; foreach (var m in ms) { if (!m) { throw new System.Exception(r.name + " Has Null Mat"); } if (!dict.ContainsKey(m)) { dict.Add(m, len); Texture albedo = m.GetTexture("_MainTex"); Texture normal = m.GetTexture("_BumpMap"); Texture smo = m.GetTexture("_SpecularMap"); Texture emission = m.GetTexture("_EmissionMap"); Texture height = m.GetTexture("_HeightMap"); Texture secondBump = m.GetTexture("_SecondaryBumpMap"); Texture secondAlbedo = m.GetTexture("_SecondaryMainTex"); Texture secondSpec = m.GetTexture("_SecondarySpecularMap"); int albedoIndex = GetTextureIndex(albedoTexs, albedoDict, albedo); int normalIndex = GetTextureIndex(normalTexs, normalDict, normal); int smoIndex = GetTextureIndex(smoTexs, smoDict, smo); int emissionIndex = GetTextureIndex(emissionTex, emissionDict, emission); int heightIndex = GetTextureIndex(heightTex, heightDict, height); int secondBumpIndex = GetTextureIndex(secondBumpTex, secondBumpDict, secondBump); int secondAlbedoIndex = GetTextureIndex(secondAlbedoTex, secondAlbedoDict, secondAlbedo); int secondSpecIndex = GetTextureIndex(secondSpecTex, secondSpecDict, secondSpec); loader.allProperties.Add(new MaterialProperties { _Color = ColorToVector(m.GetColor("_Color")), _Glossiness = m.GetFloat("_Glossiness"), _DecalLayer = (uint)m.GetInt("_DecalLayer"), _EmissionColor = ColorToVector(m.GetColor("_EmissionColor") * m.GetFloat("_EmissionMultiplier")), _MetallicIntensity = m.GetFloat("_MetallicIntensity"), _SpecularIntensity = m.GetFloat("_SpecularIntensity"), _Occlusion = m.GetFloat("_Occlusion"), _NormalIntensity = GetVector2(m.GetVector("_NormalIntensity")), _TileOffset = m.GetVector("_TileOffset"), _BumpMap = normalIndex, _EmissionMap = emissionIndex, _MainTex = albedoIndex, _SpecularMap = smoIndex, _HeightMap = heightIndex, _HeightMapIntensity = m.GetFloat("_HeightmapIntensity"), _SecondaryBumpMap = secondBumpIndex, _SecondaryMainTex = secondAlbedoIndex, _SecondarySpecularMap = secondSpecIndex, _SecondaryTileOffset = m.GetVector("_SecondaryTileOffset") }); len++; } } } ComputeShader readRTDataShader = Resources.Load <ComputeShader>("ReadRTData"); void GetGUIDs(out NativeList <int4x4> strs, List <Texture> texs, int typeIndex) { strs = new NativeList <int4x4>(texs.Count, Allocator.Persistent); for (int i = 0; i < texs.Count; ++i) { string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(texs[i])); MEditorLib.SetObjectAddressable(texs[i], guid); int4x4 value = 0; fixed(char *c = guid) { UnsafeUtility.MemCpy(value.Ptr(), c, sizeof(int4x4)); } strs.Add(value); } } GetGUIDs(out loader.albedoGUIDs, albedoTexs, 0); GetGUIDs(out loader.secondAlbedoGUIDs, secondAlbedoTex, 0); GetGUIDs(out loader.normalGUIDs, normalTexs, 1); GetGUIDs(out loader.secondNormalGUIDs, secondBumpTex, 1); GetGUIDs(out loader.smoGUIDs, smoTexs, 0); GetGUIDs(out loader.secondSpecGUIDs, secondSpecTex, 0); GetGUIDs(out loader.emissionGUIDs, emissionTex, 2); GetGUIDs(out loader.heightGUIDs, heightTex, 3); EditorUtility.SetDirty(AddressableAssetSettingsDefaultObject.Settings); return(dict); }
/// <summary> /// Returns an enumerator that iterates through all fields. /// </summary> public static IEnumerator <int> GetEnumerator(int4x4 m) => m.GetEnumerator();
/// <summary> /// Creates a 1D array with all values (internal order) /// </summary> public static int[] Values1D(int4x4 m) => m.Values1D;
/// <summary> /// Creates a 2D array with all values (address: Values[x, y]) /// </summary> public static int[,] Values(int4x4 m) => m.Values;