@@ -14,6 +14,26 @@ void meshImportNotifyUsedFiles(const MeshImportResult &result);
1414
1515namespace
1616{
17+ wgpu::FilterMode convertFilter (const String &f)
18+ {
19+ if (f == " nearest" )
20+ return wgpu::FilterMode::Nearest;
21+ if (f == " linear" )
22+ return wgpu::FilterMode::Linear;
23+ return wgpu::FilterMode::Undefined;
24+ }
25+
26+ wgpu::AddressMode convertWrap (const String &f)
27+ {
28+ if (f == " clamp" )
29+ return wgpu::AddressMode::ClampToEdge;
30+ if (f == " repeat" )
31+ return wgpu::AddressMode::Repeat;
32+ if (f == " mirror" )
33+ return wgpu::AddressMode::MirrorRepeat;
34+ return wgpu::AddressMode::Undefined;
35+ }
36+
1737 TextureFlags convertTarget ()
1838 {
1939 TextureFlags result = TextureFlags::None;
@@ -269,6 +289,7 @@ namespace
269289 }
270290 }
271291 images.parts = std::move (parts);
292+ images.sort ();
272293 }
273294
274295 void checkConsistency (const TextureFlags target)
@@ -311,6 +332,9 @@ namespace
311332 {
312333 CAGE_LOG (SeverityEnum::Info, " assetProcessor" , " using bcn encoding" );
313334
335+ if ((data.resolution [0 ] % 4 ) != 0 || (data.resolution [1 ] % 4 ) != 0 )
336+ CAGE_THROW_ERROR (Exception, " base image resolution for bcn encoding must be divisible by 4" );
337+
314338 data.usage = (uint64)wgpu::TextureUsage::CopyDst | (uint64)wgpu::TextureUsage::TextureBinding;
315339 data.format = (uint32)findInternalFormatForBcn (data);
316340
@@ -378,6 +402,14 @@ namespace
378402 header.resolution = Vec3i (images.parts [0 ].image ->width (), images.parts [0 ].image ->height (), numeric_cast<uint32>(images.parts .size ()));
379403 header.channels = images.parts [0 ].image ->channels ();
380404 header.mipLevels = toBool (processor->property (" mipmaps" )) ? min (findContainedMipmapLevels (header.resolution , any (target & TextureFlags::Volume3D), any (target & TextureFlags::Compressed)), 8u ) : 1 ;
405+ header.sampleFilter = (uint32)convertFilter (processor->property (" sampleFilter" ));
406+ header.mipmapFilter = (uint32)(header.mipLevels > 1 ? wgpu::MipmapFilterMode::Linear : wgpu::MipmapFilterMode::Nearest);
407+ header.anisoFilter = toUint32 (processor->property (" anisoFilter" ));
408+ if (header.sampleFilter != (uint32)wgpu::FilterMode::Linear || header.mipmapFilter != (uint32)wgpu::MipmapFilterMode::Linear)
409+ header.anisoFilter = 1 ;
410+ header.wrapX = (uint32)convertWrap (processor->property (" wrapX" ));
411+ header.wrapY = (uint32)convertWrap (processor->property (" wrapY" ));
412+ header.wrapZ = (uint32)convertWrap (processor->property (" wrapZ" ));
381413
382414 // todo
383415 if (images.parts [0 ].image ->format () != ImageFormatEnum::U8)
0 commit comments