@@ -9,6 +9,8 @@ namespace EngineKit.Graphics;
99
1010public record Material ( string Name ) : IDisposable
1111{
12+ public const string MaterialNotFoundName = "M_NotFound" ;
13+
1214 private float _metallicFactor ;
1315 private float _roughnessFactor ;
1416 private Vector3 _specularFactor ;
@@ -238,19 +240,60 @@ public void LoadTextures(
238240 //TODO(deccer) TextureLoader should be called and pass in material, to set its Texture objects perhaps
239241 //TODO(deccer) this needs to be inverted, ie someone else needs to load the stuff per material, not the material itself
240242
241- BaseColorTexture = CreateTextureFromImage ( BaseColorImage , Format . R8G8B8A8Srgb , BaseColorTextureSamplerInformation , logger ,
242- graphicsContext , samplerLibrary , textures , makeResident ) ;
243- NormalTexture = CreateTextureFromImage ( NormalImage , Format . R8G8B8A8UNorm , NormalTextureSamplerInformation , logger , graphicsContext ,
244- samplerLibrary , textures , makeResident ) ;
245- MetalnessRoughnessTexture = CreateTextureFromImage ( MetalnessRoughnessImage , Format . R8G8B8A8UNorm ,
246- MetalnessRoughnessTextureSamplerInformation , logger , graphicsContext , samplerLibrary , textures ,
243+ BaseColorTexture = CreateTextureFromImage (
244+ BaseColorImage ,
245+ Format . R8G8B8A8Srgb ,
246+ BaseColorTextureSamplerInformation ,
247+ logger ,
248+ graphicsContext ,
249+ samplerLibrary ,
250+ textures ,
251+ makeResident ) ;
252+ NormalTexture = CreateTextureFromImage (
253+ NormalImage ,
254+ Format . R8G8B8A8UNorm ,
255+ NormalTextureSamplerInformation ,
256+ logger ,
257+ graphicsContext ,
258+ samplerLibrary ,
259+ textures ,
260+ makeResident ) ;
261+ MetalnessRoughnessTexture = CreateTextureFromImage (
262+ MetalnessRoughnessImage ,
263+ Format . R8G8B8A8UNorm ,
264+ MetalnessRoughnessTextureSamplerInformation ,
265+ logger ,
266+ graphicsContext ,
267+ samplerLibrary ,
268+ textures ,
269+ makeResident ) ;
270+ SpecularTexture = CreateTextureFromImage (
271+ SpecularImage ,
272+ Format . R8G8B8A8UNorm ,
273+ SpecularTextureSamplerInformation ,
274+ logger ,
275+ graphicsContext ,
276+ samplerLibrary ,
277+ textures ,
278+ makeResident ) ;
279+ OcclusionTexture = CreateTextureFromImage (
280+ OcclusionImage ,
281+ Format . R8G8B8A8UNorm ,
282+ OcclusionTextureSamplerInformation ,
283+ logger ,
284+ graphicsContext ,
285+ samplerLibrary ,
286+ textures ,
287+ makeResident ) ;
288+ EmissiveTexture = CreateTextureFromImage (
289+ EmissiveImage ,
290+ Format . R8G8B8A8Srgb ,
291+ EmissiveTextureSamplerInformation ,
292+ logger ,
293+ graphicsContext ,
294+ samplerLibrary ,
295+ textures ,
247296 makeResident ) ;
248- SpecularTexture = CreateTextureFromImage ( SpecularImage , Format . R8G8B8A8UNorm , SpecularTextureSamplerInformation , logger ,
249- graphicsContext , samplerLibrary , textures , makeResident ) ;
250- OcclusionTexture = CreateTextureFromImage ( OcclusionImage , Format . R8G8B8A8UNorm , OcclusionTextureSamplerInformation , logger ,
251- graphicsContext , samplerLibrary , textures , makeResident ) ;
252- EmissiveTexture = CreateTextureFromImage ( EmissiveImage , Format . R8G8B8A8Srgb , EmissiveTextureSamplerInformation , logger ,
253- graphicsContext , samplerLibrary , textures , makeResident ) ;
254297
255298 TexturesLoaded = true ;
256299 }
@@ -265,7 +308,8 @@ public void LoadTextures(
265308 IDictionary < string , ITexture > textures ,
266309 bool makeResident )
267310 {
268- if ( image == null || string . IsNullOrEmpty ( image . Name ) ||
311+ if ( image == null ||
312+ string . IsNullOrEmpty ( image . Name ) ||
269313 textures . TryGetValue ( image . Name , out var texture ) )
270314 {
271315 return null ;
0 commit comments