66
77using NUnit . Framework ;
88
9+ using SharpGLTF . Scenes ;
910using SharpGLTF . Schema2 ;
1011using SharpGLTF . Validation ;
1112
@@ -23,8 +24,8 @@ public void TestMaterialEquality()
2324 // ... And we could use it for general equality checks, but then, since
2425 // MaterialBuilder is NOT inmutable, it can mean that two materials can be equal
2526 // at a given time, and non equal at another. Furthermore, it would imply having
26- // a hash code that changes over time. As a consequence, it could be impossible
27- // to use MaterialBuilder as a dictionary Key .
27+ // a hash code that changes over time. As a consequence, using MaterialBuilder as
28+ // a dictionary key is possible, but dangerous if not carefully handled .
2829
2930 var srcMaterial = _CreateUnlitMaterial ( ) ;
3031
@@ -100,6 +101,18 @@ public void CreateSpecularGlossinessWithFallback()
100101 Assert . That ( MaterialBuilder . AreEqualByContent ( material , material . Clone ( ) ) , Is . True ) ;
101102 }
102103
104+ [ Test ]
105+ public void CreateIORWithFallback ( )
106+ {
107+ // https://github.com/vpenades/SharpGLTF/issues/246
108+
109+ var material = new MaterialBuilder ( "MaterialWithIOR" ) ;
110+ material . IndexOfRefraction = 7 ;
111+
112+ Assert . That ( MaterialBuilder . AreEqualByContent ( material , material . Clone ( ) ) , Is . True ) ;
113+ Assert . That ( MaterialBuilder . AreEqualByContent ( material , _Schema2Roundtrip ( material ) ) , Is . True ) ;
114+ }
115+
103116 private static MaterialBuilder _CreateUnlitMaterial ( )
104117 {
105118 var tex1 = ResourceInfo . From ( "shannon.png" ) . FilePath ;
@@ -192,7 +205,7 @@ private static MaterialBuilder _CreateClearCoatMaterial()
192205 . WithClearCoatRoughness ( tex1 , 1 ) ;
193206
194207 return material ;
195- }
208+ }
196209
197210 [ Obsolete ( "SpecularGlossiness has been deprecated by Khronos" ) ]
198211 private static MaterialBuilder _CreateSpecularGlossinessMaterialWithFallback ( )
0 commit comments