I am following these great Metal tutorials in Swift:. Everything works great, until I come to the 3rd part where texture Mapping is explained. Somehow, my mapping gets done very wrong for some faces. There could be many reasons for that, but I am pretty new to Metal, so I believe it's my lack of knowledge and having done something wrong. Anyhow, this is what the outcome looks like: Here I am trying to display two triangles with four vertices (A - B - C - D in counter clockwise order) and somehow the 1st triangle shows a distorted texture (A, B, C) whilst the second looks pretty fine (A, C, D). In addition to the Cube class defined in the tutorials (which shows distorted textures, too) I've made a simpler Triangle class to show a square image of a triangle.
Yet even for this very simple arrangement, the texture mapping fails. Rather than showing you the entire code I've appended a to my project folder (zip) so you can download and execute the stuff yourselves. I've commented all the code to the best of my abilities and hopefully it will make sense to you guys. Before diving into the few files, I have a rough guess in which file the issue may be:.
Natural Graphics Introduces Terrain Texture Shader For Mac Pro
For Mac, click on the blue Apple icon on the top left of your menu bar, then click on 'About this Mac'. TRS2019 Adjusting the Draw Distance on the fly with Shift + and Shift - In TRS2019, you can quickly change your draw distance at any time in Driver or Surveyor (we've nicknamed them the 'Quickdraw keys').
Shader.metal in the basicfragment function, because it interpolates the colour of the texture to display it in the fragment and the passed coordinates may not be correct. MetalTexture.swift in the loadTexture function, because my fix on how to load a CGImage from an NSImage may be faulty and distort the texture image. Node.swift in the defaultSampler class function, because it is this Metal sampler that is used for interpolation and might be faulty. Everything is correct ( which I doubt) and it's just Mac OS 10.11 still being in a beta state that causes the problem ( which would be very annoying) All in all, I apologise for this wild goose-chaise to find a mistake in my code, but I've been on this for more than a week and am still stuck. Many thanks in advance;) UPDATE # 1 After loads of experimenting and hacking at it, I managed to map the texture correctly. To do so I followed a peculiar pattern.