[Request] Make materials more like blueprint classes

Hello,

I think material editor workflow is outdated for unreal 4. What I would like to see is complete redesign of material editor to make it look more like blueprint class workflow.

Actually a material workflow is like a function with return node in blueprint class that is called every tick or?
What about to create own flow control, compare variables with conditions, add local variables, access to owner actor variables, access to owner particle etc like in blueprint class? That would make materials much more flexible, dynamic and easier to use and make things like dynamic material instances and dynamic parameters redundant.

I do not know if you already think about it or I am just stupid with this suggestion than sorry if yes.

From what I understand Materials are just node editors for creating shaders. Shaders are programs that are run on the GPU instead of the CPU, and only work with vertex/pixel data. The GPU doesn’t understand code the same way as the CPU does, and doesn’t have access to the same memory that the CPU does so pointers to Actors will never work.

Materials do have flow control, the way I see it is that it just evaluates right-to-left instead of left-to-right. You can use the “If” node to do comparisons between variables, and the shader will take a different path depending on the result (< or >=).

Constant Materials are compiled before runtime to save performance, so they can’t ever take variables/values as parameters at runtime. If you need to have complete control of parameters, you have to use a Dynamic Material. However, they are quite expensive, so if you have only 1-10 states or so, I would recommend making 1-10 instances of Constant Materials with overloaded parameters instead. Constant Materials are a lot faster.

Constant materials do not need really need to be updated (Unless you’re using the Time function maybe?) because nothing will ever change. A Dynamic Material can be different for every object that uses it every frame, so I would guess that it would be updated per-object, per-render call. One update per object every 1/60 seconds could be very expensive, as you could well imagine.

So the thing about Constant vs. Dynamic is basically speed vs. memory usage. Just like anything else in programming, it’s all about finding a balance.

If materials do not have same possibilities like actors do, how do they access such dynamic informations like camera position, object position, word position, vertex position, rotation etc. Even panning materials need update ticks or?

I do not say that materials should work exactly like actors. They may be converted to the shaders by the engine later. I just think the workflow is too different from blueprint workflow while there is similar functionality. Maybe set if function should be called once or some amount of frames to save performance.

Objects like cameras are common in rendering, as to take a world and project it into screen space you need to know things such as camera position/rotation for building a WVP matrix. But the camera would not be passed through as an actor, its members would be passed through as parameters. You can already use your own parameters, those parameters just cannot be actors; a GPU cannot evaluate a pointer like the CPU does.

Materials and shaders are very expensive by nature, and you should be using dynamic materials as little as possible. At most, the calculations done by a dynamic material could be processed once for each and every pixel on the screen every frame. I don’t think blueprint is nearly optimized enough to be handling that much work.

The GPU is not faster than the CPU, it is actually much slower. The only reason the GPU can calculate vertices/pixels/particles faster than a CPU is because a CPU typically has 1-16 threads whereas the GPU can have hundreds. This makes the GPU very good at doing small operations over a large number of elements in parallel, but also very poor at evaluating conditional statements. Conditional statements deteriorate GPU performance very quickly.