Get screen resolution in blueprint or material

I need to get uv offset for a single pixel to sample screen texture in the postprocessing material. E.g.:

X X o X X

where o is the current pixel and X are neighbor pixels. I know UV for o, to get to X pixels I need to know screen resolution, so that I can do 1/width (or 1/height) and add that offset to the original UV coords. Is there any way to query those number inside postprocessing material or a blueprint?

Inside a normal Blueprint, you can get teh viewport size with the PlayerController:

These are the same values you get when you are in the HUD Class.

But i can’t tell you how to get this inside your Postprocessing material. I’m a big noob in materials :smiley:

Maybe you can use this as a dynamic scalar for your material or something :X (like a Healthbar does).

I think I’ve found the answer to my own question: to get the offset one need to use SceneTexelSize expression in the material (Coordinates Material Expressions in Unreal Engine | Unreal Engine Documentation). No need to query resolution and invert it!

The output of the X and Y can be put into the parameters of parameterized values in the material.

Yeah :smiley: that’s what i meant. Thanks for that, will keep in mind for my own projects.

You may want to be careful when getting the resolution this way…
I can’t say if it works the same, but in UDK, if you got the Viewport size and say the game was windowed… it returned the size the resolution was last set to(via unrealscript or the set rez command), regardless of how large the window actually is.

this (unexpected) behaviour lead to a mess of problems in my UDK projects. so you might want to be aware… Just a heads up.