How to get DPI scaling in material

Is there a material node that returns the DPI scaling for the current object being drawn? This can be useful for UMG material.

Normally there’s a curve you can configure.
Scale UI for Different Devices | Unreal Engine Documentation.

Right now in my material I’m scaling something by taking the render target size and scaling by what my UI’s DPI 1 scale resoltion would be. UI Material posted by anonymous | blueprintUE | PasteBin For Unreal Engine

It’d be way more reliable if it was able to use the DPI scaling in the material expression instead so it’d use the curve. It could also work correctly when I’m not rendering the UI to the screen but instead to a 3D widget.

Oh I think I found exactly what I’m looking for in the same node I was using to return the render target size.

I just need to select the ScreenPercentage property instead. :rofl:

Oh wait, never mind, I don’t think that’s UI DPI. That’s actually the 3D rendering resolution percentage.

2 Likes

Did you ever figure this out?

No, but it could be a good node to add that to.

I figured out a really stupid workaround, assuming this is a material used in a widget.

In image settings in the widget, set “Draw As” to “Image” and “Tiling” to “Both”. “Image Size” will be locked to 32x32 - you can change the numbers in the UI, but they will not affect anything; it will still treat the size as 32x32.

Then in the material, the “9-slice UV” coordinate will be the position in a grid of 32x32 tiles. You can access DPI like so:

thanks dude, I was going crazy with this, on HLSL is View.ResolutionFractionAndInv.x my use case was multiplaying the mouse screen location, that corrects the DPI thing inside the material