2021 Graphics & GamesDeveloper Tools
WWDC21 · 40 min · Graphics & Games / Developer Tools
Discover Metal debugging, profiling, and asset creation tools
Explore how Xcode can help you take your Metal debugging, profiling and asset creation workflows to the next level. Discover the latest tools for ray tracing and GPU profiling, and learn about Metal Debugger workflows. We’ll also show you how to use the Texture Converter tool, which supports all modern GPU texture formats and can easily integrate into your multi-platform asset creation pipelines.
Watch at developer.apple.com ↗Code shown on screen · 4 snippets
RGBM Encoding Pseudocode
float4 EncodeRGBM(float3 in)
{
float4 rgbm;
rgbm.a = max3(in.r, in.g, in.b) / RGBM_Range;
rgbm.rgb = in / (rgbm.a * RGBM_Range);
return rgbm;
} RGBM Decoding Pseudocode
float3 DecodeRGBM(float4 sample)
{
const float RGBM_Range = 6.0f;
float scale = sample.a * RGBM_Range;
return sample.rgb * scale;
} MetalTextureSwizzles
// Remap the X and Y channels to red and green channels for normal maps
compressed with ASTC.
MTLTextureDescriptor* descriptor = [[MTLTextureDescriptor alloc] init];
MTLTextureSwizzle r = MTLTextureSwizzleRed;
MTLTextureSwizzle g = MTLTextureSwizzleAlpha;
MTLTextureSwizzle b = MTLTextureSwizzleZero;
MTLTextureSwizzle a = MTLTextureSwizzleZero;
descriptor.swizzle = MTLTextureSwizzleChannelsMake( r, g, b, a ); ReconstructNormal
// Reconstruct z-axis from normal sample in shader code.
float3 ReconstructNormal(float2 sample)
{
float3 normal;
normal.xy = sample.xy * 2.0f - 1.0f;
normal.z = sqrt( saturate( 1.0f - dot( normal.xy, normal.xy ) ) );
return normal;
} Resources
Related sessions
-
21 min -
27 min -
31 min -
38 min -
32 min -
30 min -
30 min -
25 min -
21 min -
21 min -
33 min -
21 min