In this week’s live stream Ryan Brucks and Sam Deiter will cover the various uses of the Custom Material node. Ryan Brucks also explains how he used Custom Material nodes to achieve the liquid “metaball” from the beginning of the ProtoStar demo.
Tuesday, March 29th @ 2:00PM-3:00PM ET - Countdown
What’s all this talk about C++ materials? ‘Ask your engineer to turn the custom HLSL into C++, it’s more efficient’ etc etc. I can’t find anything on google for ‘C++ materials’ in UE4.
What are you talking about here? Can you write materials without HLSL, just C++? Is it more efficient then HLSL??? And if so why was the metaballs phone demo written in Custom Expressions material nodes?
(PS: That was really interesting, I’m glad to see some walkthroughs on the custom GPU stuff.)
The Custom node can not use any of the behind the scenes optimizations that the UE4 Material Editor performs to make Materials run faster or more efficiently. Because of this, you run the risk of the HLSL code you wrote not running as performant as it could. To get around this and make sure that your Material Expression nodes run as fast as possible, you should have an engineer turn what you created with the Custom Expression node into a Material Expression node that can then be placed in your Material Graph. To do this you will need to have an engineer write the framework of the new Material Expression in C++ and then use HLSL as the code to power it. This way your new Material Expression can make sure of all the behind the scenes optimizations that it can.
The reason that this was not done to the Metaballs was due to time constraints and performance. After doing a lot of performance testing on the Metaballs, it turned out that they were running fast enough so in this case there would be no immediate advantage to taking the time to write them as a new Expression as the manner in which they were done with the Custom node worked and did not take that much performance away from the project.
As we stated in the stream this is not something that you need to do all the time but rather should be something that you do if you find that you are having performance issues. You can by all means use the Custom Expression to do things like ATAN without seeing any performance spikes. But if you do you need to make sure that you are constantly checking performace to make sure that your FPS will not suffer because of this.