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"

[Feature Request] Material editor loops

I've seen this discussed a lot but I'm surprised I couldn't find a formal request. It'd be extremely useful to have while and for loops in the form of native material editor nodes. It would eliminate the need for custom code node usage in a huge variety of effects.

Product Version: Not Selected
Tags:
more ▼

asked Aug 09 '16 at 08:49 PM in Rendering

avatar image

SFtheWolf
384 34 39 45

avatar image Luos May 02 '17 at 05:01 PM

bump for justice.

avatar image Hyperloop May 02 '17 at 08:24 PM

I think the reasoning behind not having them is that you have to be verrry careful with these in shaders or you'll kill performance. Seems like the thought is, if you are writing your own node you know enough to use loops wisely.

avatar image Seraph Fawkes May 02 '17 at 08:35 PM

Though additional math and certain flow control would be great to have in materials, whenever you have some kind of switch, engine actually should precomile shaders for each material possibility. However there's indeed ticket for better flow control, I believe.

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

2 answers: sort voted first

Yep. It is actually quite strange that this was not requested before. Upvoted. These two feature requests are also somewhat relevant.

more ▼

answered Aug 10 '16 at 01:53 PM

avatar image

Deathrey
7.8k 130 30 292

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

Well... 4.20.2 version has been released, and UnrealEngine still does not have this functionality...Why? How to raise the importance of this serious problem?

P.S.: I need loops (for/while) functionality to implement RayMarching on signed distance function in post processing stage... At the moment we have to make plug-ins, but it's very inconvenient and you can lose compatibility because of use private functions... UE developers, save us! Add for/while loops into Material graphics editor please...

more ▼

answered Sep 18 '18 at 02:40 PM

avatar image

MASTER_OF_ORION
1 2 2

avatar image Hyperloop Sep 18 '18 at 02:53 PM

You can use the custom expression node, no need for plugins. https://docs.unrealengine.com/en-us/Engine/Rendering/Materials/ExpressionReference/Custom

avatar image MASTER_OF_ORION Sep 18 '18 at 04:52 PM

In this expression node I can't use functions in code, but they are very necessary, especially for reusable code in shader... Also, I can't use external functions, which are declared in the graphic editor of materials. For this reason, the only way out - use of plugins or some dirty hacks like this code in Custom Expression Node:

 #include "/Engine/Private/iacopoHlslStructures.ush"
 return iacopoHlslFunctions.OrangeBright();

found here: https://forums.unrealengine.com/development-discussion/rendering/113855-extending-custom-hlsl-custom-expressions

avatar image Deathrey Oct 22 '18 at 11:30 PM

Use functions declared within a struct for that.

avatar image NoobsDeSroobs Oct 22 '18 at 04:14 PM

I made a ray traces in UE4 and I used both custom nodes, shader code that I added to the loaded shader files in the engine, and recursive functions in the material editor. I am unable to see why using functions in a shader is not doable. If you are thinking of calling a CPU function from a shader, then that is not possible. The closest thing would be a GPGPU style issue where the result determines the next action on the cpu.

You can implement a raymarcher using UE4, I did it.

avatar image MASTER_OF_ORION Oct 22 '18 at 04:28 PM

ray marching != ray tracing in general terms, loops and functions in shaders are needed in many techniques and effects and it is this that is not implemented in UE4... RayMarching already implemented in UE4 by me through dirty hack in CustomExpression node (see link above) Result: https://www.youtube.com/watch?v=DUl6aAIcghI

avatar image NoobsDeSroobs Oct 22 '18 at 04:40 PM

It uses the same techniques and concept to a large degree. The math is a bit different, but you need loops for raymarching as well. Functions you can also make and call as you see fit. The way you did it is indeed not too beautiful, but it also not required. You could just write the loops yourself inside a custom node, if you dont want to import the script through a hack, as you put it.

I have made a SDF renderer in OenGL before, and I have done raytracing and raymarching in UE4. The editor sucks, but it is workable. I just made changes in another editor and copied the result in.

Good work, btw. Really nice and smooth results.

avatar image MASTER_OF_ORION Oct 22 '18 at 04:54 PM

"I have made a SDF renderer in OenGL before" Can you show results? Thanks, btw.

(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