x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Debugging "failed to compile material"

I'm tinkering with landscapes and I've found that, with a specific combination of landscape materials, I get the error "failed to compile material". Now, I actually know why this is happening - it's because I have too many landscape materials at once, and this produces a shader that is too complicated to run, in some manner. But I'd really like to have better diagnostic results so I can see what, precisely, is causing the issue. Multiple questions along those lines:

  • Is there any way to preview a specific set of layer blends within the material editor itself? It seems to just default to "first layer is 100% intense" which makes it hard to see what I'm doing.

  • Is there any way to find out, in detail, why a shader failed to compile?

  • Alternatively, is there any way to retrieve the shader code of the shader that failed to compile, so I can diagnose it by hand?

Product Version: Not Selected
Tags:
more ▼

asked Oct 29 '14 at 09:47 AM in Rendering

avatar image

ZorbaTHut
220 13 20 159

avatar image Lovecraft_K ♦♦ STAFF Nov 17 '14 at 08:51 PM

Hey ZorbaTHut -

Thank You for the clarification. I understand your issue much more clearly now. Any material can only use a total of 16 Texture Samplers but 3 of those are reserved for lighting information (depending on your shader model you are using). With the picture you have above I am seeing 11 individual samplers which should be within the realm of doable.

What I would do to really test this and see as you go exactly what the errors are, open the Output log in the editor then slowly paint each layer on the landscape and allow each to compile or not. You can see the compile error in detail in the output log (which you can scroll back through as well). Once you get a compile error look at that particular branch of the material and see if anything is amiss in the material setup (most likely a height blend issue, if there is one) In the past, simply painting the landscape with each layer one time allowed the whole shader to compile and removed compilation issues.

Thank You

Eric Ketchum

avatar image ZorbaTHut Nov 19 '14 at 12:09 AM

Each individual layer renders fine. Painting Grass, Soil, Cobblestone, and RockyCliffs on together causes an error:

LogShaderCompilers:Warning: Failed to compile Material /Game/Landscapes/Materials/M_LandscapeMaterial.M_LandscapeMaterial for platform PCD3D_SM5, Default Material will be used in game. LogShaders:Warning: warning X3206: implicit truncation of vector type LogShaders:Warning: error X4510: maximum ps_5_0 sampler register index (16) exceeded

(That's all the layers except for the middle layer in the screenshot.)

Removing any of those component layers brings it back to functionality again.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Hey ZorbaTHut -

I checked with my colleagues and need to correct myself, with landscapes in the engine before v 4.6 Preview you are allowed a maximum of 13 texture samplers (3 of which are reserved for lighting models so really only 10 unique textures). This means your material with all the different layers painted at one spot exceed the shaders computation capacity.

Assuming you set up your materials correctly you should be able to use this setup in 4.6 Preview or later with no problems.

Thank You

Eric Ketchum

more ▼

answered Nov 19 '14 at 03:58 PM

avatar image

Lovecraft_K ♦♦ STAFF
36.7k 702 260 735

avatar image vinz243 May 08 '15 at 10:00 AM

Hi, I have the same problem with 4.8 preview. Can you help me please?

avatar image Lovecraft_K ♦♦ STAFF May 08 '15 at 02:36 PM

Hi vinz243 -

Since this particular issue was dealing with pre-4.6 builds of the engine, can you post a new question and include screenshots of the errors you are receiving and the complete material setup.

Thank You

Eric Ketchum

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hey ZorbaTHut -

Currently there is no way to preview as you are requesting but that functionality is coming down the pipeline as I write to you. If the shader fails to compile (assuming that you have not added any Custom HLSL scripting) you should get a notice in the Material Editor's Output log window, let me know if you are in fact not getting this notices.

Thank You

Eric Ketchum

more ▼

answered Oct 31 '14 at 03:37 PM

avatar image

Lovecraft_K ♦♦ STAFF
36.7k 702 260 735

avatar image ZorbaTHut Nov 07 '14 at 09:03 PM

I get a message, but only the first time a material fails to compile (which isn't very handy in the case of terrain), and it's not a useful message. It's just "failed to compile lol sux to be you", paraphrased.

avatar image Lovecraft_K ♦♦ STAFF Nov 07 '14 at 10:08 PM

I might be a little confused as to what you are seeing, but in scripting it is common practice to stop compiling at the first error and return that and the next time you compile assuming that error has been fixed and there re more errors you will get the next one in the pipeline.

Eric Ketchum

avatar image ZorbaTHut Nov 08 '14 at 04:21 AM

Keep in mind I'm not writing a shader when this happens. I edit the landscape shader and that "compiles" fine. The error occurs when I paint a set of elements on the land that it doesn't like. It attempts to compile the shader, fails, and then apparently caches the failure - if I don't see the failure the first time it happens, I'm never given a chance to see it again.

And even with that failure I don't get any kind of a useful diagnostic message, it just says, and I quote, "LogShaderCompilers:Warning: Failed to compile Material /Game/Landscapes/Materials/M_LandscapeMaterial.M_LandscapeMaterial for platform PCD3D_SM5, Default Material will be used in game." I got this by painting a tiny patch of rock in an area in my level - no material editor involved.

I won't get that error again unless I modify the shader or unless I clear the entire shader cache. The only way I knew where to look for it was that I spent half an hour trying to figure out why it was refusing to render a chunk of my terrain properly.

avatar image Lovecraft_K ♦♦ STAFF Nov 10 '14 at 02:23 PM

Hey ZorbaTHut -

This may be an edge case that we have not come across before, is there anyway you can screenshot your entire landscape material (including functions) for us to test this.

Thank You

Eric Ketchum

avatar image ZorbaTHut Nov 15 '14 at 05:57 PM

Here ya go!

It's based directly off the Landscape example, just with another two textures, one of which has a real roughness and split-apart height texture. (Which I should probably merge into the base and normal just to save on texture lookups, but haven't yet.)

I was able to retrieve the actual build errors and it was complaining about more than 16 texture samplers. By my count this is doable with 12, which is within limits, but I'm assuming the engine is doing some magic stuff in the background that require a few more.

That said, "stats" tells me it's using five texture samplers, which is completely impossible for any interesting mixing - I'm assuming that it is assuming the "soil" layer is at full opacity, which lets it optimize away essentially the entire shader. In this one case.

untitled.png (673.2 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question