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"

Setting SamplerType crashes when creating new material from code

I'd like to make custom material from editor, everything works perfectly fine except the one thing - Setting SamplerType crashes editor with assertion:

 Assertion failed: TextureReferenceIndex != INDEX_NONE [File:D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\Materials/HLSLMaterialTranslator.h] [Line: 3992] Material expression called Compiler->TextureParameter() without implementing UMaterialExpression::GetReferencedTexture properly

Full stacktrace: https://pastebin.com/WnhYK34P

Short reproduced code:

 void ABugCoder::CreateMaterial()
     UPackage* Package = CreatePackage(NULL, TEXT("/Game/SomeFolder/M_MyMaterial"));
     UPackage* OutermostPkg = Package->GetOutermost();
     UMaterialFactoryNew* Factory = NewObject<UMaterialFactoryNew>();
     UMaterial* Mat = Cast<UMaterial>(Factory->FactoryCreateNew(UMaterial::StaticClass(), OutermostPkg, TEXT("M_MyMaterial"), RF_Standalone | RF_Public, NULL, GWarn));
     UMaterialExpressionTextureSampleParameter2D* NormalTexture = NewObject<UMaterialExpressionTextureSampleParameter2D>(Mat);
     NormalTexture->Texture = LoadObject<UTexture2D>(NULL, TEXT("/Engine/EngineMaterials/FlatNormal"), NULL, LOAD_None, NULL);
     NormalTexture->SamplerType = EMaterialSamplerType::SAMPLERTYPE_Normal; // Line that will affect in crash in PostEditChange(); 
     // it works without this line, but need to set SamplerType manually (from material editor) in created material
     Mat->Normal.Connect(0, NormalTexture);
Product Version: UE 4.21
more ▼

asked Jan 05 '19 at 09:21 AM in Bug Reports

avatar image

13 2 2 6

avatar image Jeff A ♦♦ STAFF Jan 07 '19 at 01:27 PM


We've recently made a switch to a new bug reporting method using a more structured form. Please visit the link below for more details and report the issue using the new Bug Submission Form. Feel free to continue to use this thread for community discussion around the issue.



avatar image Testerro Jan 16 '19 at 12:45 PM

I;ve submited it. Got an reply "it's not a bug", but no further answer. It's still an issue and I've completely no idea how to solve it

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

0 answers: sort voted first
Be the first one to answer this question
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