iOS Metal precompile shaders

How do you precompile shaders on a mac for metal? I’m looking at this link:

“If you cook with Windows, the shaders will not be precompiled because there is no shader compiler program for Windows. It will compile the shaders at runtime if this is the case (it uses the offline/online flag for looking up the shader in the DerivedDataCache, so both modes live together correctly).”

I’m on a mac now with a blueprint only project. And will this fix the the materials having to compile the first time they are shown on an iOS game? This video shows what I’m referring to:

Hey rckt26,

The shaders are already precompiled after you packaged and launch the project onto your device. Be sure you have set up your project correctly for your metallic materials to render as expected. One way to make sure you are using the correct shader model is to use the ‘Feature Level Switch’ node within your Material Graph.

I just tested this on an iPad Air we have here and the project loaded up fine without the need to compile shaders for the Metal material I had applied to objects in my scene.

If you have further questions please let me know.

Cheers,

Andrew Hurley

I’m not sure what I’m doing wrong. I’ve packaged it with shipping configuration and added the ‘Feature Level Switch’ to most of the materials but it still does the same thing. Pretty much all of my materials are unlit and just a simple texture.

I had deleted the previous video so here is another:

After watching your video, I am not seeing any compile shaders issues. It seems to just need to load the textures into memory which is that popping that you are seeing.

How do I load all the textures into memory before they are used because everytime a new material is applied the game stutters.

In what context are you changing or applying materials at runtime, and how are you doing so?

You can use the never stream option, but your mobile device has a texture pool limit and some of those textures will be blurry, Keep in mind mobile devices have texture size limits that need to be adhered to in order for your mobile project to load correctly.

Texture Guidelines for Mobile

Materials for Mobile

Both of the above links can also provide some more insight on how to optimize your textures and materials for your mobile projects.

Thanks,

Andrew Hurley

Thanks, the never stream option seems to work. I haven’t seen any blurry textures yet but I still have some stuttering issues that seem to be related to textures but I’m not sure. Could you take a look at the video and take a guess?

As you can see the first time the camera moves over the fps drops and then any time after it doesn’t have a problem.

It seems to just be a load time issue like it just needed to be loaded for the first time. The stuttering didn’t seem to occur on your second return to the game and back to the menu.

Let me know if I need to start a new question since it seems like it may not be related to my original question.

I don’t think it is a load time issue because I can leave it on the menu for a few min and then press New Puzzle and it still will stutter the first time.

And here is a little more info: The frame rate drop occurs only the first time the new puzzle is pressed if the app has been closed and hasn’t been in the background for a while or if the iphone/ipad has been restarted. I can close the app completely and then reopen it and it doesn’t occur again. The draw count goes from ~100 to over 300 and triangle count goes from 26000 to 62000. It’s like something hasn’t been allocated or initialized until it comes into view that first time but I don’t know how to narrow it down or fix it even if I did narrow it down.

Yeah, if you don’t mind could you create a new answerhub post and provide the details of the specific issue you are explaining?

I appreciate your patience and if you would like, you can provide me with the link to your new issue in your response to this comment, and I can continue to help you investigate.

Cheers,

Andrew Hurley

Thanks, I’ve reposted it here: