x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

Product Version: Not Selected
Tags:
more ▼

asked Nov 04 '14 at 01:32 PM in Rendering

avatar image

devast3d
242 15 19 47

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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 :D

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

viewport1

more ▼

answered Nov 04 '14 at 01:41 PM

avatar image

eXi
6.8k 333 185 470

avatar image Luos Nov 04 '14 at 05:21 PM

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

avatar image eXi Nov 04 '14 at 05:22 PM

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

avatar image magnetomage Jan 13 '15 at 03:35 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

I think I've found the answer to my own question: to get the offset one need to use SceneTexelSize expression in the material (https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/ExpressionReference/Coordinates/index.html#scenetexelsize). No need to query resolution and invert it!

more ▼

answered Nov 04 '14 at 02:14 PM

avatar image

devast3d
242 15 19 47

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question