Why is Compiling Shaders taking a long time?

From Tin.Le:

I’m not sure if you guys have the same problem but it usually takes nearly 15-20 seconds just to compile a very simple material with diffuse and normal. My PC is very powerful (I7, 32gb RAM), so it must be something to do with the engine itself.

From MonsOlympus:

Yeah I have experienced this myself even on a system with significantly lesser specs (i5, 8gb ram) it takes a similar amount of time.

From Froyok:

Well, simple materials compile in less that 5 seconds for me, however SubSurface materials or any materials with a time node can really start to increase in time. My most complex material (subsurface with a lot of textures lerped = 200 instructions) can go up to a full minute.

Maybe it’s a GPU driver issue ?

From fragfest2012:

Could it be because the physical shading model takes longer to compile? I wouldn’t mind the wait so much if the old material didn’t get replaced by the checkers when you compile, so that you can see the changes better. But I think that is already in the UDN.

I noticed the shader compiling seems to speed up dramatically if I immediately save the material after changing it.

other wise it will taking sometimes 300% longer

My impression is that if you make several different changes to a material, it is incrementally compiling your various changes, moving toward your most recent changes

but if you save the material


it jumps through its list of your changes to your final state and just compiles that


my reason for believing this is that I"ve cycled through color values rapidly, typing them in, and then stopped and watched as each number I had entered was set, material compiled, and then my next number was entered, material compiled, resulting in the appearance of a lag of my changes being applied


Possible Solutions

if this feature of constantly recompiling my incremental changes did not occur

or if the code would notice when I was entering changes rapidly and just wait, instead of recompiling in the background

I do think the process would go a lot faster


My Main Observation

and again if I save the material file immediately, it seems to skip all those incremental change compiles and just goes to the final state and compiles that, taking reasonable amount of time.

There is actually a request already in for materials to wait to compile in this manner. Our rendering specialist has looked into it and it has been prioritized.

nice to hear from you Alexander!

:slight_smile:

Rama

my reason for believing this is that I"ve cycled through color values rapidly, typing them in, and then stopped and watched as each number I had entered was set, material compiled, and then my next number was entered, material compiled, resulting in the appearance of a lag of my changes being applied

Confirmed, using the sliders to set a color value (so the value continuously keeps changing) instead of setting a value by typing it in multiplies the compiling time to a ridiculous amount. Right now the best solution seems to be to pick a color (and its values) in some other application and just copy-paste them over. Immediate shader compilation vs. waiting 1-2 minutes just for changing a hue.

Hi Otto,

I am investigating this issue and trying to get a reproduction for our developers. I am having some difficulties getting the lag that you are seeing based off of the information given in this thread. Could you provide a screenshot of your Material’s setup so that I can recreate it? Any additional information may help with this investigation.

Thank you,

Alexander

Thanks for all the info. There are probably multiple problems here, but at least one of them is that on 4 or fewer core machines we were only using 1 core for shader compiling, which means it will take forever. I’ve changed it to use 3 cores for shader compiling on a 4 core machine, which will be 3x faster.

Do you guys know how many cores your machines have (with hyperthreading)?

congrats on the fix Daniel, sounds like it will really help!

(im running at least 8 core I think, judging from task manager, but I was having the multiple-previous-edits shader compile issue)

In my case : 4 physical core (i7) with hyperthreading enabled, so 8 cores.

Mines i5 so 4 cores, no HT.

Just a quick note, that default material checker is actually quite expensive with all the operations performed on it.

Indeed, although no one should be using the default material so it shouldn’t matter =)

4 cores, no HT. I wouldn’t mind if shader compiling would take all 4 cores. I can’t do anything in the editor while that happen anyway (;.

Or maybe there is possible solution of more agressive caching of precompiled shaders ?

I have 4 cores, but no HT. I know this is late, but I’m still having an issue. Is HT needed to properly run the engine?

so… how do you enable that option?? I want to try it too, I am suffering a lot with shader compiling times

Hi , this is a post from our beta that has been archived for reference purposes only. Please repost in AnswerHub as a new question. Thank you!

Hello,

This is a question from the beta version of the engine. We are marking this answered for tracking purposes. If you are experiencing an issue similar to this please post a new question.

Thank you.