| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using DCL.Helpers; |
| | 5 | | using UnityEngine; |
| | 6 | |
|
| | 7 | | [System.Serializable] |
| | 8 | | public class MaterialModel |
| | 9 | | { |
| | 10 | | public enum TransparencyMode |
| | 11 | | { |
| | 12 | | OPAQUE, |
| | 13 | | ALPHA_TEST, |
| | 14 | | ALPHA_BLEND, |
| | 15 | | ALPHA_TEST_AND_BLEND, |
| | 16 | | AUTO |
| | 17 | | } |
| | 18 | |
|
| | 19 | | [Range(0f, 1f)] |
| 17 | 20 | | public float alphaTest = 0.5f; |
| | 21 | |
|
| 17 | 22 | | public Color albedoColor = Color.white; |
| | 23 | |
|
| 17 | 24 | | public float metallic = 0.5f; |
| 17 | 25 | | public float roughness = 0.5f; |
| 17 | 26 | | public float microSurface = 1f; // Glossiness |
| 17 | 27 | | public float specularIntensity = 1f; |
| | 28 | |
|
| 17 | 29 | | public Color emissiveColor = Color.black; |
| 17 | 30 | | public float emissiveIntensity = 2f; |
| 17 | 31 | | public Color reflectivityColor = Color.white; |
| 17 | 32 | | public float directIntensity = 1f; |
| | 33 | |
|
| 17 | 34 | | public bool castShadows = true; |
| | 35 | |
|
| | 36 | | [Range(0, 4)] |
| 17 | 37 | | public int transparencyMode = 4; // 0: OPAQUE; 1: ALPHATEST; 2: ALPHBLEND; 3: ALPHATESTANDBLEND; 4: AUTO (Engine dec |
| | 38 | |
|
| | 39 | | public TextureModel albedoTexture; |
| | 40 | | public TextureModel alphaTexture; |
| | 41 | | public TextureModel emissiveTexture; |
| | 42 | | public TextureModel bumpTexture; |
| | 43 | |
|
| | 44 | | public override int GetHashCode() |
| | 45 | | { |
| | 46 | | unchecked |
| | 47 | | { |
| 216 | 48 | | int hashCode = alphaTest.GetHashCode(); |
| 216 | 49 | | hashCode = (hashCode * 397) ^ albedoColor.GetHashCode(); |
| 216 | 50 | | hashCode = (hashCode * 397) ^ metallic.GetHashCode(); |
| 216 | 51 | | hashCode = (hashCode * 397) ^ roughness.GetHashCode(); |
| 216 | 52 | | hashCode = (hashCode * 397) ^ microSurface.GetHashCode(); |
| 216 | 53 | | hashCode = (hashCode * 397) ^ specularIntensity.GetHashCode(); |
| 216 | 54 | | hashCode = (hashCode * 397) ^ emissiveColor.GetHashCode(); |
| 216 | 55 | | hashCode = (hashCode * 397) ^ emissiveIntensity.GetHashCode(); |
| 216 | 56 | | hashCode = (hashCode * 397) ^ reflectivityColor.GetHashCode(); |
| 216 | 57 | | hashCode = (hashCode * 397) ^ directIntensity.GetHashCode(); |
| 216 | 58 | | hashCode = (hashCode * 397) ^ castShadows.GetHashCode(); |
| 216 | 59 | | hashCode = (hashCode * 397) ^ transparencyMode; |
| 216 | 60 | | hashCode = (hashCode * 397) ^ (albedoTexture != null ? albedoTexture.GetHashCode() : 0); |
| 216 | 61 | | hashCode = (hashCode * 397) ^ (alphaTexture != null ? alphaTexture.GetHashCode() : 0); |
| 216 | 62 | | hashCode = (hashCode * 397) ^ (emissiveTexture != null ? emissiveTexture.GetHashCode() : 0); |
| 216 | 63 | | hashCode = (hashCode * 397) ^ (bumpTexture != null ? bumpTexture.GetHashCode() : 0); |
| 216 | 64 | | return hashCode; |
| | 65 | | } |
| | 66 | | } |
| | 67 | |
|
| | 68 | | protected bool Equals(MaterialModel other) |
| | 69 | | { |
| 44 | 70 | | return alphaTest.Equals(other.alphaTest) && albedoColor.Equals(other.albedoColor) && metallic.Equals(other.metal |
| | 71 | | } |
| | 72 | |
|
| | 73 | | public override bool Equals(object obj) |
| | 74 | | { |
| 113 | 75 | | if (ReferenceEquals(null, obj)) |
| 0 | 76 | | return false; |
| 113 | 77 | | if (ReferenceEquals(this, obj)) |
| 69 | 78 | | return true; |
| 44 | 79 | | if (obj.GetType() != this.GetType()) |
| 0 | 80 | | return false; |
| 44 | 81 | | return Equals((MaterialModel) obj); |
| | 82 | | } |
| | 83 | | } |