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"

Compile Unreal 4.17 Shader

Hi,

I am writing a Shader Plugin for my project. Currently, I am following this tutorial on Github: **https://github.com/hausfrau87/UE4ShaderPluginDemo**

And I think I place the shader files in the right place, the path looks like this:

C:\Users\Admin\Documents\AnimatedAvatar\Plugins\DXPixelShader\Shaders\Private

And here is how I compile the code in c++:

IMPLEMENT_SHADER_TYPE(, FVertexShaderExample, TEXT("/Plugins/DXPixelShader/Private/PixelShader.usf"), TEXT("MainVertexShader"), SF_Vertex);

However, I got errors that are listed in the following:

[2017.10.24-04.09.24:368][ 0]LogShaders: Error: Can't map virtual shader source path "/Plugins/DXPixelShader/Private/PixelShader.usf". Directory mappings are: /Engine -> ../../../Engine/Shaders /Project -> ../../../../../../Users/Admin/Documents/AnimatedAvatar/Shaders /Plugin/ComputeShader -> ../../../../../../Users/Admin/Documents/AnimatedAvatar/Plugins/DXComputeShader/Shaders /Plugin/PixelShader -> ../../../../../../Users/Admin/Documents/AnimatedAvatar/Plugins/DXPixelShader/Shaders Fatal error: [File:D:\Build++UE4+Release-4.17+Compile\Sync\Engine\Source\Runtime\ShaderCore\Private\ShaderCore.cpp] [Line: 476] Couldn't find source file of virtual shader path '/Plugins/DXPixelShader/Private/PixelShader.usf'

I searched on Google for hours but can not figure this out.

Thanks, Z

Product Version: UE 4.17
Tags:
more ▼

asked Oct 24 '17 at 04:16 AM in C++ Programming

avatar image

HolyKaisar
6 2 3 5

avatar image darkgaze Feb 16 '18 at 09:38 AM

4.17 Release notes say to add the shader under /Source folder (with the wrong path, by the way). Then, official tutorials after its release say put it under the plugin folder, under Shader/ and add the complete path. But the path they give is also wrong. A clarification here would be great

avatar image darkgaze Feb 16 '18 at 09:41 AM

Any news about this @HolyKaisar ? TEXT("/Plugins/DXPixelShader/Private/PixelShader.usf") <-- Shouldn't it be /Plugins/DXPixelShader/Shaders/Private/PixelShader.usf? This path doesn't work in my case either

avatar image HellDunkelkeit Feb 16 '18 at 12:20 PM

I think it did not put it within plugins but one level above. Will check tomorrow if you like.

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

3 answers: sort voted first

This is a bit late, but had a similar problem. Had to add a new shader source directory mapping during StartupModule().

Since we were using it in our game, we had to extend FDefaultGameModeImpl and override StartupModule, then add

 AddShaderSourceDirectoryMapping(TEXT("/Project"), FPaths::Combine(*(FPaths::GameDir()), TEXT("Shaders")));

to StartupModule().

Caused by 4.21 change: Fix: Replaced automatic virtual shader directory mapping with manual approach in StartupModule(). It should reduce the amount of directory exists queries at Editor startup.

more ▼

answered Nov 10 '18 at 05:00 PM

avatar image

mastercoms
16 3

avatar image MetricZero Apr 15 '19 at 07:49 PM

Can you explain this? What's StartupModule? How do I override that?

avatar image rbeck Apr 16 '19 at 01:10 AM
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Just ran into the same problem. I failed to properly name MyShader.USF (Windows was hiding the file extension). In VS under Shader/Private it was called MyShader.USF.txt. Renameing to "MyShader.USF" fixed the problem.

more ▼

answered Feb 11 '18 at 10:01 PM

avatar image

helldunkel
11 3

avatar image darkgaze Feb 16 '18 at 09:41 AM

What was the full path, please? Did you include Plugins/ as said (wrong) in the release notes?

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

Hey not sure if you managed to figure this out, but I ran into this problem today.

In your plugins folder, you need to create a "Shaders" directory, and add your .USF/H files in there.

Once you start to load the shader files, you'll notice in the output that the engine is virtually mapping this folder to have an alternate name, in your case it's /Plugin/PixelShader as seen from this line of the output you pasted:

/Plugin/PixelShader -> ../../../../../../Users/Admin/Documents/AnimatedAvatar/Plugins/DXPixelShader/Shaders

Now in your shader declaration macro you want to reference that virtual directory as the base for the shader file you wish to load in your case it would look like this:

   IMPLEMENT_SHADER_TYPE(, FVertexShaderExample, TEXT("/Plugin/PixelShader/Private/PixelShader.usf"), TEXT("MainVertexShader"), SF_Vertex);
more ▼

answered Feb 20 '18 at 05:02 AM

avatar image

liamisbest
36 11 7

(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