# Compile shaders on game launch?

**URL:** <https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035>\
**Category:** Rendering\
**Tags:** unreal-engine, UE5-0, UE4, Shaders, question\
**Created:** [May 26, 2022, 1:31pm UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035 "2022-05-26T13:31:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![BuyMyMojo](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/buymymojo/32/872427_2.png) [@BuyMyMojo](https://forums.unrealengine.com/u/BuyMyMojo)\
**Post date:** [May 26, 2022, 1:31pm UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/1 "2022-05-26T13:31:49Z")

</div>

A lot of modern unreal engine games have has the issue of stuttering in game the first time a shader appears, if there an easy way to add a loading screen on first boot that compiles all the shaders for the player?  
I’m pretty sure call of duty modern warfare/warzone has this feature for an example.

Most results on google when I try to find information on this relate to compile issues in the engine but no information on how to compile shaders in the full exported game.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [May 26, 2022, 5:52pm UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/2 "2022-05-26T17:52:17Z")

</div>

When you package the game for distribution, it cooks everything first. So this doesn’t happen for end users.

---

<div class="post-metadata">

**Author:** ![BuyMyMojo](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/buymymojo/32/872427_2.png) [@BuyMyMojo](https://forums.unrealengine.com/u/BuyMyMojo)\
**Post date:** [May 28, 2022, 5:28pm UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/3 "2022-05-28T17:28:09Z")

</div>

That’s only for consoles since they have unchanging hardware, clients still need to compile some shaders if they are on PC i’m pretty sure.

You can see what I mean [here](https://youtu.be/FbFMafKzJyY?t=585)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [May 28, 2022, 5:36pm UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/4 "2022-05-28T17:36:07Z")

</div>

Have you ever had to wait while a game you got from Steam compiled shaders? 🙂

---

<div class="post-metadata">

**Author:** ![BuyMyMojo](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/buymymojo/32/872427_2.png) [@BuyMyMojo](https://forums.unrealengine.com/u/BuyMyMojo)\
**Post date:** [May 28, 2022, 5:54pm UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/5 "2022-05-28T17:54:03Z")

</div>

Yeah I just did, back 4 blood

---

<div class="post-metadata">

**Author:** ![BuyMyMojo](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/buymymojo/32/872427_2.png) [@BuyMyMojo](https://forums.unrealengine.com/u/BuyMyMojo)\
**Post date:** [May 28, 2022, 6:10pm UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/6 "2022-05-28T18:10:16Z")

</div>

also The Ascent and Psychonauts 2

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [May 28, 2022, 6:34pm UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/7 "2022-05-28T18:34:39Z")

</div>

Sounds like bad packaging…

---

<div class="post-metadata">

**Author:** ![BuyMyMojo](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/buymymojo/32/872427_2.png) [@BuyMyMojo](https://forums.unrealengine.com/u/BuyMyMojo)\
**Post date:** [May 28, 2022, 7:09pm UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/8 "2022-05-28T19:09:09Z")

</div>

You’re confusing what steam does. it doesn’t compile all the gpu shaders because it can’t access them all, especially with UE games where we use .pak files to store the files.

UE can’t compile all the shaders for PC either since there are so many different GPUs it would be impssible to compile for them all, If UE compiles for all current ones then that would just take up extra useless space for users that don’t run… literally every GPU in their system at once and it would also be useless for future hardware.

A lot of modern UE games(And PC games in general) have had shader stuttering recent for this exact reason. That’s why I’m asking for a way to achieve this since it is obviously needed.

Examples:  
[Chernobylite](https://youtu.be/Bo9Q48RiuaU?t=835)  
[Elden Ring](https://youtu.be/5EtcrUrsl38?t=361)

This issue is not just prevalent in UE games but in modern PC gaming and without any actual knowledge on how to precompile shaders so they are compiled “Just in time” it will stay that way.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [May 28, 2022, 7:35pm UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/9 "2022-05-28T19:35:18Z")

</div>

See this reddit post

> **[r/GraphicsProgramming - Why do some games have shader compilation stutters?](https://www.reddit.com/r/GraphicsProgramming/comments/t22etj/why_do_some_games_have_shader_compilation_stutters/)**
>
> 22 votes and 23 comments so far on Reddit

Pipeline updates are not the same thing as the shaders you compile when cooking a project.

---

<div class="post-metadata">

**Author:** ![BuyMyMojo](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/buymymojo/32/872427_2.png) [@BuyMyMojo](https://forums.unrealengine.com/u/BuyMyMojo)\
**Post date:** [May 28, 2022, 7:39pm UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/10 "2022-05-28T19:39:29Z")

</div>

These comments on that post directly confirm what I’m talking about:

> **[r/GraphicsProgramming - Why do some games have shader compilation stutters?](https://www.reddit.com/r/GraphicsProgramming/comments/t22etj/comment/hyknk0x/?utm_source=share&utm_medium=web2x&context=3)**
>
> 22 votes and 23 comments so far on Reddit

> **[r/GraphicsProgramming - Why do some games have shader compilation stutters?](https://www.reddit.com/r/GraphicsProgramming/comments/t22etj/comment/hyjilv0/?utm_source=share&utm_medium=web2x&context=3)**
>
> 22 votes and 23 comments so far on Reddit

> **[r/GraphicsProgramming - Comment by u/lgroeni on ”Why do some games have...](https://www.reddit.com/r/GraphicsProgramming/comments/t22etj/comment/hyle34c/?utm_source=share&utm_medium=web2x&context=3)**
>
> 21 votes and 23 comments so far on Reddit

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [May 28, 2022, 7:42pm UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/11 "2022-05-28T19:42:18Z")

</div>

Yes, and this is a low level translation at the last moment on the GPU, not the same thing that Unreal is doing, at all.

If a game actually had to compile engine level shaders when you first ran it, you would have to wait hours before you could play the game 🙂

---

<div class="post-metadata">

**Author:** ![BuyMyMojo](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/buymymojo/32/872427_2.png) [@BuyMyMojo](https://forums.unrealengine.com/u/BuyMyMojo)\
**Post date:** [May 29, 2022, 8:08am UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/12 "2022-05-29T08:08:36Z")

</div>

UE4 **and** 5 games already have pre game compilers for shaders, It’s already obviously a thing that can be done and is done in AAA and indie games alike.

I’m asking how to do last moment GPU shader comp on first launch which again is something people already do.

I’m not asking what is causing stuttering or how to have the game live compile from source like a game engine, I’m asking how to solve this specific problem with a solution that is already out there but just doesn’t have any documentation.

---

<div class="post-metadata">

**Author:** ![LNaej](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LNaej](https://forums.unrealengine.com/u/LNaej)\
**Post date:** [May 29, 2022, 1:46pm UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/13 "2022-05-29T13:46:43Z")

</div>

You may already know this, but PSO Caching seems to at least partially try to solve this issue.  
The documentation homepage is [here](https://docs.unrealengine.com/4.27/en-US/SharingAndReleasing/PSOCaching/), and the part of the doc explaining how to use the data in order to do the computation when you want (ie. loading screen) is [here](https://docs.unrealengine.com/4.27/en-US/SharingAndReleasing/PSOCaching/CompilingUsingPSOCachingData/).  
Hope it will help.

---

<div class="post-metadata">

**Author:** ![BuyMyMojo](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/buymymojo/32/872427_2.png) [@BuyMyMojo](https://forums.unrealengine.com/u/BuyMyMojo)\
**Post date:** [May 29, 2022, 2:03pm UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/14 "2022-05-29T14:03:03Z")

</div>

thank you! 💖  
Hopefully this will help lower the impact of the issue, I’m still very interested in any other solutions people have.

---

<div class="post-metadata">

**Author:** ![LNaej](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LNaej](https://forums.unrealengine.com/u/LNaej)\
**Post date:** [May 29, 2022, 2:10pm UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/15 "2022-05-29T14:10:38Z")

</div>

Honestly, from my understanding, it seems to do what you are looking for: compiling the shaders on the target machine when you (the developer) want it. So, for instance, at first launch.  
However, as I never used it myself, I cannot 100% confirm this.  
Very interested by the question too 🙂

PS: another way to do this manually could be to fire up all the shaders you want to preload on an offscreen camera (render to texture) with very low resolution when in your loading screen.

---

<div class="post-metadata">

**Author:** ![BuyMyMojo](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/buymymojo/32/872427_2.png) [@BuyMyMojo](https://forums.unrealengine.com/u/BuyMyMojo)\
**Post date:** [May 29, 2022, 2:19pm UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/16 "2022-05-29T14:19:23Z")

</div>

> [@LNaej](#):
>
> another way to do this manually could be to fire up all the shaders you want to preload on an offscreen camera (render to texture) with very low resolution when in your loading screen.

Someone suggested something simmalar to this on reddit:

> [@TeamFalldog on reddit](#):
>
> Load a level or levels at startup with all the game’s assets, fly a camera through it quickly, and hide it behind a loading screen the first time the game is launched?

Which would be a very good method too, I’ll look into these two things!

---

<div class="post-metadata">

**Author:** ![mixer76](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mixer76](https://forums.unrealengine.com/u/mixer76)\
**Post date:** [January 11, 2023, 10:58am UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/17 "2023-01-11T10:58:09Z")

</div>

Hello, have you tested PSO and pre loading? I’m also exploring the options. I know “Detroit: Become Human” would compile a lot of shaders when it first runs on my PC. I’m also looking for ways to do this in Unreal. Currently, PSO seems to be it but it seems the process to enable PSO is quite complicated and seems to be another cook process on PC. This is just first impression. I will get my hands dirty on the process and actually carry it out. Just hoping to hear your experience on this since your last replay was half a year before and you may now have some practical opinions on this.

---

<div class="post-metadata">

**Author:** ![BuyMyMojo](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/buymymojo/32/872427_2.png) [@BuyMyMojo](https://forums.unrealengine.com/u/BuyMyMojo)\
**Post date:** [July 14, 2023, 1:14am UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/18 "2023-07-14T01:14:45Z")

</div>

I haven’t done anything eith PSO myself but from the leatest video on DigitalFoundy it seems it is the way to go for now but it is a pretty manual process for devs to first run through the game and grab the required shaders to pre-cache them

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/9/5/7953d15e5e415b95714d916423adf6f70b4e593c.jpeg "Unreal Engine 5.2 - Next-Gen Evolves - New Features + Tech Tested - And A 'Cure' For Stutter?") ](https://www.youtube.com/watch?v=XnhCt9SQ2Y0)

---

<div class="post-metadata">

**Author:** ![BitKovin](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bitkovin/32/942179_2.png) [@BitKovin](https://forums.unrealengine.com/u/BitKovin)\
**Post date:** [August 12, 2023, 11:02pm UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/19 "2023-08-12T23:02:55Z")

</div>

I’ve created plugin that adds shader compilation. It should also remove particle systems spawn delay. Yes, I’m advertising my own product, but it could help somebody.

[Shader Compilation Screen - remove shader stutters in Code Plugins - UE Marketplace (unrealengine.com)](https://www.unrealengine.com/marketplace/en-US/product/shader-compilation-screen-remove-shader-stutters)

---

<div class="post-metadata">

**Author:** ![Antongrekov69](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Antongrekov69](https://forums.unrealengine.com/u/Antongrekov69)\
**Post date:** [October 9, 2023, 1:14pm UTC](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035/20 "2023-10-09T13:14:16Z")

</div>

perfect, thanks

[Next page](https://forums.unrealengine.com/t/compile-shaders-on-game-launch/567035.md?page=2)
