C++ is not shader. The graph you make in material editor, generates HLSL code which is used by DX or converted for different library shader language if you something else then DX, which later driver compile for your GPU. C++ is run by CPU where shaders are run (more like placed in rendering pipe) by GPU and can’t be mixed, thats why the property you trying to modify seem to be related to shader compiler rether then modify something in real time.
CPU and GPU code can communicate to each other via uniform varables, which in UE4 are implamented via material parameters and materiual instances allowing to change properties of material on the go.
In C++ (and in blueprint in similar way) you operate them in component instead of material it self, first you create and set instance dynamic using this function (or else you gonna create static instance in editor)
And from generated material instance you call function that set those parameters like SetVectorParameterValue or what gonna interest you the most SetTextureParameterValue. I can’t find them in API reference but they are there in UMaterialInstanceDynamic.
Also way you refrenceing texture seems odd, asset are refrence a little diffrent, you can get asset refrence by right clicking it and clicking “Copy Refrence”. Also referencing assets direclyin C++ are little unsafe, after cook if there no asset used in level refrence your asset it won’t be cook, im not sure how to fix that, but you can make code a lot safer if you making UTexture* editable in editor property, where you can set texture and blueprint or level which use C++ object will refrence that asset and you be 100% sure it will be cooked
Thank you! will check through those links. I am actually planning to put this in a plugin, I want it to run in the editor as part of a batch import, NOT at runtime.
Is it possible to edit the materials in editor via c++, without creating a dynamic instance?
I think the question is related to editor-time manipulation of the material asset itself (in the state it is in before being compiled to HLSL), not adjusting a material on-the-fly. Since you can modify a material asset by manipulating the material graph, and the graph editor is coded in C++, it stands to reason you should be able to alter the material asset procedurally.
As for how, I’m afraid I have no idea. It’s conceivable the necessary functionality is buried way down and not exposed through the public interface of UMaterial. I guess the way to find out would be to look through the engine source code of the material graph editor.