Passing vector and texture parameters to UE materials
Posted: 17 Mar 2023, 16:52
Hey guys,
I'm working with UE5.1 and Noesis 3.2 and I want to implement a health bar using an UE material. In my material, I want to process three parameters:
- A health ratio value passed as a scalar parameter
- A texture atlas containing the health bar image as a texture2D parameter
- The uv coords for the texture within the atlas as a vector parameter
In my xaml resource dictionary, the texture is defined as a bitmap and the uv coords are defined as a color.
The health value is taken from a data context binding.
Here's the relevant snippet:
And the resources used:
When importing all of this, I get the following warnings:
The warnings for the color parameter will go away, if I use the RGBA properties instead of ScA, ScR and so on, but I need floats of course.
Needless to say, the texture won't show up in the game and the vector parameter values are also incorrect. The health ratio value is the only thing that works.
I searched the forums and the web but couldn't find any related solution. The documentation doesn't seem to mention anything about parameters (correct me if I'm wrong) and I couldn't find anything in the samples either.
I'm aware there are other ways to implement a progress bar, but this is really not about progress bars. We are going to make plenty of use of materials so this is a general issue we would need to solve.
Thanks in advance.
I'm working with UE5.1 and Noesis 3.2 and I want to implement a health bar using an UE material. In my material, I want to process three parameters:
- A health ratio value passed as a scalar parameter
- A texture atlas containing the health bar image as a texture2D parameter
- The uv coords for the texture within the atlas as a vector parameter
In my xaml resource dictionary, the texture is defined as a bitmap and the uv coords are defined as a color.
The health value is taken from a data context binding.
Here's the relevant snippet:
Code: Select all
<noesis:Brush.Shader>
<mat:M_TexturedProgressBar Ratio="{Binding HealthRatio}" RectForeground="{StaticResource R_HealthBar}" Texture="{StaticResource T_SpriteSheet_HUD}" />
</noesis:Brush.Shader>
Code: Select all
<BitmapImage x:Key="T_SpriteSheet_HUD" UriSource="T_SpriteSheet_HUD.png"/>
<Color x:Key="R_HealthBar" ScA="0" ScR="0.1123046875" ScG="0.9765625" ScB="0.1123046875" />
Code: Select all
Cannot assign property to abstract class 'Color'
Cannot set value for 'Materials.UI.M_TexturedProgressBar.RectForeground', invalid value 'null' for property type 'Color'
Unknown property 'Materials.UI.M_TexturedProgressBar.Texture', or object to assign is incompatible
Needless to say, the texture won't show up in the game and the vector parameter values are also incorrect. The health ratio value is the only thing that works.
I searched the forums and the web but couldn't find any related solution. The documentation doesn't seem to mention anything about parameters (correct me if I'm wrong) and I couldn't find anything in the samples either.
I'm aware there are other ways to implement a progress bar, but this is really not about progress bars. We are going to make plenty of use of materials so this is a general issue we would need to solve.
Thanks in advance.