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"

Cool inverse image effect with material?

alt text

Hi, I am wondering if it's possible to achieve this effect with a material applied to an object? Does anyone know how this might be done?

Thanks!

Product Version: UE 4.21
Tags:
more ▼

asked Jan 07 '19 at 07:49 PM in Using UE4

avatar image

Daphnis26
22 2 2 4

avatar image Daphnis26 Jan 07 '19 at 07:50 PM

PS, Just wanted to clarify; the idea is that it reflects the entire environment and not just an hdri map.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

You can use "scene color" node to sample pixels behind the material (and from entire screen too) like a texture. You can get ScreenPosition node, break it, invert (1-x) Y axis (green chanell) and then plug it to UV of SceneColor (sample position map). It will make SceneColor sample Y axis in invert

alt text

alt text

Note that SceneColor require material to be in translucent mode, as sampling behind pixels how translucency work. Also remember that this can only sample pixels that are visible on screen, same as screen space reflection, you might hear about this limitation if you following NVidia's ray tracing talks. Also remember to use emissive color pin, so what you material outputting is not altered by lightning

If you at it, you can also alter color of sampled pixels so you can play around that too if you want.

more ▼

answered Jan 07 '19 at 08:12 PM

avatar image

Shadowriver
33.2k 915 164 1087

avatar image Daphnis26 Jan 07 '19 at 08:24 PM

That looks great, thank you!

Is there a way I can control the position of the image to align the horizon?

avatar image Shadowriver Jan 07 '19 at 08:40 PM

Yes as long it not goes over the screen, all you need is to modify UV map as i did in way you want.

UV is like a texture (but it not really a texture, you can not freely sample it) which contains X coordinate on red color and Y coordinate on green color to sample, between 0 (start of texture) and 1 (end of texture), and you can sample between pixels, GPU will interpolate the color values (this makes shader work independently from screen and texture resolution or filtering settings).

Normally mesh contains that data of it's vertices to sample texture on right point of the mesh. What we getting here is UV map of entire screen as scene Color sample by screen position. You can see how it looks like by directly plug in to emissive color, you will se red green gradient mixed together. As for shader UV map is like a 2 color data you can alter it same way as you do pixels in material and change sampling position, so for example if you divide Y (green) axis by 2 it will be stretched Y axis by twice. You can also for example do somehting more complex take normal map which has angle data to displace UV map by adding normal map (probably will require some corrections to) to make engraved glass refraction effect, you can do anything as long if it's on bound of the screen and it possible with math and data that shaders have.

(comments are locked)
10|2000 characters needed characters left
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