Question about input coordinates in fragment shader

Looks like I took the easy way out :woman_facepalming:.

x2 is the scale factor of the screen, and the Pro Max has a scale factor of 3.

This is the fixed final sample. The changes are:

Common.h - add this to Params:

uint scaleFactor;

Add this to Renderer.init(metalView:options:):

#if os(macOS)
  params.scaleFactor = uint(NSScreen.main?.backingScaleFactor ?? 1)
#elseif os(iOS)
  params.scaleFactor = uint(UIScreen.main.scale)
#else
   params.scaleFactor = 1
#endif

In PBR.metal, change coord:

uint2 coord = uint2(params.touchX * params.scaleFactor,
                       params.touchY * params.scaleFactor);

final.zip (142.6 KB)

Resolution by iOS device:

1 Like