# Materials are broken when loaded from a pak file

**URL:** <https://forums.unrealengine.com/t/materials-are-broken-when-loaded-from-a-pak-file/399815>\
**Category:** Rendering\
**Tags:** pak, unreal-engine, Lighting, question\
**Created:** [July 7, 2017, 4:41pm UTC](https://forums.unrealengine.com/t/materials-are-broken-when-loaded-from-a-pak-file/399815 "2017-07-07T16:41:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SlimeQ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SlimeQ](https://forums.unrealengine.com/u/SlimeQ)\
**Post date:** [July 7, 2017, 4:41pm UTC](https://forums.unrealengine.com/t/materials-are-broken-when-loaded-from-a-pak-file/399815/1 "2017-07-07T16:41:56Z")

</div>

I’ve managed to set up a relatively basic custom map system using Steam Workshop and pak files. I have a template project with a custom plugin capable of cooking, packaging, and uploading the pak to steam, and then my game basically just trolls `steamapps/common/workshop/content/` for all pak files and mounts them at `Game/Content/CustomMaps/UGC` using FPakPlatformFile.

This is (mostly) working. I am able to load the map up in my game and all the geometry is there. The issue is that this scene:

 ![201995-greenscene.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/7/0/c704a69e18709a7a0ad4bd56986a9ae6395d9027.png)

ends up looking like this when actually loaded into the game:

 ![201996-darkscene.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/1/0/a10e542b0b68a18499395fb224ac5f5e4a3f4a23.png)

I know that the ‘grass’ material is found by the engine because it no longer defaults to the grey grid texture. The lens flare (?) only appeared after I turned on the forward renderer in my template project (my game uses the forward renderer). Neither the lens flare or the black material are present in the template project. I have both a skylight and a lightmass importance volume in this map.

I’ve now removed the skylight/importance volume and replaced the green texture with the blue texture which had appeared to work.

[This is the result.][3]

What’s really interesting is that this happens seemingly randomly. If I keep loading up the map through the console, it will sometimes make the drop pod purple like in the video, sometimes it will be black like the landscape, and sometimes it will be all weirdly lit like in the picture. The landscape material NEVER works, regardless of what it is.

This is the code I’m using to load my paks:

```
void UProxyWarGameInstance::MountPak(FString PakFileName) {
	UE_LOG(LogTemp, Log, TEXT("MountPak(%s)"), *PakFileName);

	// get mod UID
	FString PathPart, FilePart, ExtPart;
	FPaths::Split(PakFileName, PathPart, FilePart, ExtPart);
	FString PathPart2, ModUID, ExtPart2;
	FPaths::Split(PathPart, PathPart2, ModUID, ExtPart2);
	UE_LOG(LogTemp, Log, TEXT("ModUID=%s"), *ModUID);

	IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
	FPakPlatformFile* PakPlatform = new FPakPlatformFile();
	PakPlatform->Initialize(&PlatformFile, TEXT(""));
	FPlatformFileManager::Get().SetPlatformFile(*PakPlatform);
	
	if (PakPlatform->Mount(*PakFileName, 0, *(FPaths::GameContentDir() / FString("CustomMaps/UGC") + ModUID))) {
		UE_LOG(LogTemp, Log, TEXT("Successfully mounted %s at %s"), *PakFileName, *FPaths::GameContentDir());
	}
	else {
		UE_LOG(LogTemp, Warning, TEXT("Failed to mount %s"), *PakFileName);
	}
}

```

Any ideas what’s going on here? I’m pretty stumped.

---

<div class="post-metadata">

**Author:** ![SlimeQ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SlimeQ](https://forums.unrealengine.com/u/SlimeQ)\
**Post date:** [July 7, 2017, 6:03pm UTC](https://forums.unrealengine.com/t/materials-are-broken-when-loaded-from-a-pak-file/399815/2 "2017-07-07T18:03:03Z")

</div>

Okay i fixed this on my own. The issue was that rendering settings in the template project were not the same as in the actual game, so the cooked materials were loading wrong

---

<div class="post-metadata">

**Author:** ![Rumbleball](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rumbleball](https://forums.unrealengine.com/u/Rumbleball)\
**Post date:** [March 5, 2018, 8:34pm UTC](https://forums.unrealengine.com/t/materials-are-broken-when-loaded-from-a-pak-file/399815/3 "2018-03-05T20:34:55Z")

</div>

Thanks you very much for that. Would never have thought about the rendering settings to be the issue.

Im on the same thing for creating mods via steam workshop. You said template project, is that available for public?

---

<div class="post-metadata">

**Author:** ![SlimeQ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SlimeQ](https://forums.unrealengine.com/u/SlimeQ)\
**Post date:** [March 6, 2018, 9:08am UTC](https://forums.unrealengine.com/t/materials-are-broken-when-loaded-from-a-pak-file/399815/4 "2018-03-06T09:08:50Z")

</div>

I basically just made a blank blueprint project but added this plugin i made [https://github.com/SlimeQ/UE4-Steamworks](https://github.com/SlimeQ/UE4-Steamworks) and another plugin containing important c++ classes and asets. It makes a toolbar for you, ignore the readme. It’s technically a fork
