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"

UE4 crashes when using dynamic cascaded shadows on instanced static meshes that use materials with world position offset in mobile

UE4 crashes with the error "Couldn't find Shader TShadowDepthPSPixelShadowDepth_NonPerspectiveCorrectfalse for Material Resource".

Reproduction steps:

  1. Set the preview rendering level to default mobile/html 5

  2. Create a default lit material with a constant (or anything) attached to the world position offset slot, and check the box for use with instanced static meshes

  3. Create an actor blueprint with an instanced static mesh component

  4. In the details panel for the instanced static mesh component, select a static mesh and the material just created

  5. Add some instances

  6. Enable the instanced static mesh component to receive combined static and csm shadows (under mobile in the details panel)

  7. Create a stationary directional light with the setting "dynamic shadow distance stationary light" set to a non-zero value (such as 2000)

  8. Try to drag the blueprint into the level and the editor should crash

This only occurs when the preview rendering level is set to mobile. It doesn't occur when set to Shader Model 5. Nor does it occur with normal static mesh components. Is this a bug?

(edit: I've updated to the latest release, and it's occurring even without cascaded shadows, seems like the issue is with the world position offset and instanced static meshes)

Product Version: UE 4.13
more ▼

asked Oct 13 '16 at 06:03 AM in Bug Reports

avatar image

105 12 13 19

avatar image vle07 Oct 17 '16 at 07:43 AM

After more testing, it looks like casting any type of dynamic shadow (cascade or modular) with an instanced static mesh that uses a material with world position offset does not work in the mobile preview nor with launching to a mobile device. Static meshes do work though, so is the engine just forgetting to compile a shader permutation? The full error message I get is:

 [2016.10.17-07.29.28:388][926]LogWindows:Error: Couldn't find Shader TShadowDepthPSPixelShadowDepth_NonPerspectiveCorrectfalse for Material Resource M_Hex1!
 [2016.10.17-07.29.28:388][926]LogWindows:Error:         With VF=FInstancedStaticMeshVertexFactory, Platform=PCD3D_ES2
 [2016.10.17-07.29.28:388][926]LogWindows:Error:         ShouldCache: Mat=1, VF=1, Shader=0 
 [2016.10.17-07.29.28:388][926]LogWindows:Error:         MaterialUsageDesc: LightingModel=MSM_DefaultLit, BlendMode=BLEND_Opaque, SpecialEngine=0, TwoSided=0, TSNormal=1, Masked=0, Distorted=0, WritesEveryPixel=1, ModifiesMeshPosition=1, Usage={bUsedWithInstancedStaticMeshes}

This feature is very important for my project. Any help with resolving this issue would be greatly appreciated!

avatar image Kenomica Dec 03 '16 at 05:01 PM

I am having this exact same issue with 4.14 - same error, and only when using mobile preview. Using Instanced Static Meshes with World Position Offset (no cascades)

avatar image vle07 Dec 03 '16 at 05:19 PM

Have you tried Allan Bentham's solution posted below? I haven't tried it in 4.14 yet, but I assume it should work. You will need access to the source code, though. Since it does seem like a bug, I thought Epic Games would've included this fix in an official release by now.

avatar image Kenomica Dec 03 '16 at 05:35 PM

Hey, thanks for the reply.

I'm using the binary engine, from the launcher - no source code.

avatar image vle07 Dec 03 '16 at 06:08 PM

I guess you'll have to wait until they patch the fix. I'd recommend looking into getting a source build running, though. There are some things you just can't do with the official released build.

avatar image Kenomica Dec 10 '16 at 07:36 PM

Thanks - I'll do some research in to building from source and give it a go.

Hopefully this will get fixed in a later update, though..but I'm unsure if Epic are aware of the issue or not / have logged it.

avatar image vle07 Dec 10 '16 at 07:48 PM

Yeah, I'm not sure if they've logged it either. The fix just requires adding a couple lines of code, and it doesn't look like it should break anything either. I'll try asking Allan Bentham if they're going to include the fix in any upcoming releases.

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

1 answer: sort voted first


Yeah, it looks like TShadowDepthPS::ShouldCache is missing a test for this.

Can you try changing the content of TShadowDepthPS::ShouldCache() 'if (!IsFeatureLevelSupported(Platform, ERHIFeatureLevel::SM4))' branch to be:

         if (!IsFeatureLevelSupported(Platform, ERHIFeatureLevel::SM4))
             return (Material->IsSpecialEngineMaterial()
                     // Only compile for masked or lit translucent materials
                     || !Material->WritesEveryPixel(true)
                     || (Material->MaterialMayModifyMeshPosition() && Material->IsUsedWithInstancedStaticMeshes())
                 && ShaderMode == PixelShadowDepth_NonPerspectiveCorrect
                 // Don't render ShadowDepth for translucent unlit materials
                 && (!IsTranslucentBlendMode(Material->GetBlendMode()) && Material->GetShadingModel() != MSM_Unlit)
                 && !bRenderReflectiveShadowMap;

and let me know if that fixes it for you.

more ▼

answered Oct 17 '16 at 11:07 AM

avatar image

AllanBentham STAFF
61 4 3 3

avatar image vle07 Oct 17 '16 at 01:30 PM

Awesome! The code above fixes the issue. I can confirm it works for the mobile previewer in 4.13.1. I'm not 100% sure if it works when packaging/launching to a mobile device in 4.13, since I can rarely get my projects to package and launch without an error (most likely due to a buggy automation tool in 4.13).

Instead, I went ahead and tested it on 4.12.5, and everything works perfectly so far. Thank you so much!

avatar image AllanBentham STAFF Oct 17 '16 at 02:18 PM

Great stuff, thanks for the report.

avatar image vle07 Dec 10 '16 at 07:50 PM

Hi Allan, will this fix be included in any upcoming official release of the engine? Some users who don't have access to the source code are having the same issue. Thanks!

avatar image Piranhi Apr 24 '18 at 12:09 PM

Did this ever get fixed in the branch?

avatar image tremor_al Jun 14 '18 at 07:32 AM

no, this problem still persists in 4.19.2

(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