How do i get the base color parameter of a cube and set it to a Print String Text Color?
the simple answer is Material Properties
to save runtime computation steps shaders
(what Unreal will often refer to as “Materials”) are pre-compiled, and maintained in such a way to be directly handed to the GPU to live in VRAM as long as the bound object is needed. and to minimize data duplication the shader is only “supposed to” live on the GPU and only the GPU once the hand off happens, but…
sometimes we want to know things about the material/shader, or maybe modify them at runtime and this is done with material property
s Unreal Engine Material Properties | Unreal Engine 5.3 Documentation these allow for the value of the material/shader to be stored in both VRAM and system RAM and to effectively reach into the material/shader on the VRAM to access or modify the value almost in real time (the render step is the last part of the game-loop so a read into a write might have a frame delay), and this could add a burden on the GPU to modify the value.
Nice, how do you read them in a blueprint?
Your link is a documentation about the different material properties, but it doesn’t say how to read them from an actor blueprint.
There are material parameters. They will be changed by the user with material instances from the material instance editor or within a blueprint with set X parameter node, but they can’t be modified in the material graph to get read in a blueprint, so material parameters doesn’t work for this.
after making the Thing a Parameter/Property in the material
then How To Change A Material Instance Parameter On A Blueprint Object? - #7 by Jacky
then you can modify whatever the parameter is, just be aware that this does increase overhead by technically duplicating the data for the given Parameter/Property to live in both VRAM and RAM, this can be mitigated a bit by Resizable-BAR, but you should still do this with moderation, or with a low number of materials being instanced (The GPU is optimized to reuse Geometry and Texture assets if they appear multiple times in the rendered frame.
Thanks for your answer
Actually I don’t want to modify the property in blueprint, I just want to read it
But material graph can’t change a material parameter. You can only change the default value in a material instance
For example, I try to read the result given to Emissive Color, or in other words, this node with the comment:
maybe something like this Is there any way to find output value of a material node in ue4 material graph? - #6 by Marcis
after doing a bit of looking setting the value into the Material is worlds easier then reading the current value especially if it is derived somehow.
realistically outside of some very clunky methods of reading the frame-buffer at a super specific render view, or overwriting the Rendering Engine in C++ to expose shader data to the C++ or Blueprints…
-you can probably just have that Property be controlled by some specific blueprint, and have the state of that value be maintained in that blueprint along with controlling it (state bools/integers/enums, floats from timelines, and so on).
If you really must get the resultant without clunky workarounds, or blowing away the rendering pipeline; just remember that there are some differences between how CPUs and GPUs optimize math. and shaders work a LOT in matrices if you need to calculate things similar to the shader working in blueprints might not be great as the Editor/Engine tries to hide matrices away as much as possible.