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"

HLSL(.fx) to UE4 Material - porting advice?

I have a great many HLSL.fx shaders that I have written collected and purchased over the last 5 years.
I would like to make use of them as much as possible, but there doesn't seem to be any porting advice as yet.

So far, I am aware that use of Custom Expressions are discouraged for performance and portability reasons.
I am also aware that multi-pass shaders are not an option, which is ok as most of my shaders are single-pass.
As such, I am wondering how I can reuse some of my 3rd party shaders within UE4.

For example,
Consider this NVidia Perlin Noise shader:
[http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter26.html] ..and imagine you already have it working (in some other graphics engine) as a compilable .fx file.

How would one go about porting that PerlinNoise.fx code to UE4 for use as a material effect?

(a) Use UE4 material nodes & functions to replicate the .fx code?
(b) Use Custom Expressions? (come with caveats!)
(c) Use FVertexFactory? (no idea if they are appropriate let alone how to use them!)
(d) Custom Plugin? (if possible, a basic tutorial example would be helpful)
(e) USF shader approach?

I am not looking for a 'perlin noise shader'. I am purely interested in the possible workflow for
[PixelShader.fx] --> [Unreal Engine 4 material] so the generic process can be adapted for any shader.

Product Version: Not Selected
Tags:
more ▼

asked Jul 12 '14 at 03:26 PM in Rendering

avatar image

ash22
486 70 62 96

(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first

In most cases it would be (a). If you are finding it impossible to achieve it with (a), an example would be a multi pass pixel shader then you might have to write your own usf shader file.

more ▼

answered Jul 13 '14 at 10:02 AM

avatar image

HypnoticShark
612 23 29 47

avatar image ash22 Jul 13 '14 at 05:20 PM

Thanks. Do you know if usf shaders come with the same caveats as custom (hlsl) expressions?

avatar image Ehamloptiran Jul 14 '14 at 04:34 AM

No they dont, USF are the native shader formats for UE4. Everything shader based are in USF's. ie the Material template is a USF (Which is just HLSL)

avatar image ash22 Jul 14 '14 at 07:15 AM

Excellent. That's good to know!

Time to start hunting down USF documents.

(comments are locked)
10|2000 characters needed characters left

The easiest way is probably to convert your HLSL into a function format (instead of a main entrypoint), paste it into MaterialTemplate.usf. Then use a Custom expression to call your function, and hook up the output however you want into the material system. Any inputs your code needs will have to be function parameters.

more ▼

answered Jul 14 '14 at 05:07 PM

avatar image

DanielW STAFF
1.9k 31 11 71

avatar image ash22 Jul 17 '14 at 12:51 PM

"Then use a Custom expression to call your function"

That sounds like an interesting idea, but I am again concerned about the Custom expression caveats: https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/ExpressionReference/Custom/index.html

Also, can I assume there is no documentation on the MaterialTemplate.usf that can help me with this scenario?
(or am I the only madman attempting it?!)

(comments are locked)
10|2000 characters needed characters left
more ▼

answered Sep 21 '16 at 05:44 AM

avatar image

PowerDesign
176 14 21 32

(comments are locked)
10|2000 characters needed characters left
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