Announcement

Collapse
No announcement yet.

GrabPass equivalent

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    GrabPass equivalent

    When writing shaders in CG, there is a function called GrabPass that lets you get the rendered scene behind an object as an input to your fragment shader. This lets you do, for example, post processing effects on only the part of the scene behind a given object, as well as doing things like computationally cheap (fake) mobile glass displacement.

    I'm still fairly new to UE (about three months in) and haven't fully wrapped my head around the PBR stuff, and mostly, I haven't needed to. The past few days, I've been trying to understand the material system better and have been trying to figure out how you'd get access to this same data in a material or material instance.

    I've had zero luck finding anything. The various material nodes like SceneTexture, that look like they might work be what I was looking for have all turned out to be available only in post processing materials.

    Any pointers in the right direction would be much appreciated. Thanks!

    #2
    SceneColor node should do what you want, and you can use that in a translucent material on a mesh in the world, or as a PP material.

    Comment


      #3
      Thank you. This does give what I need.

      I think I'm starting to understand the way materials work. So, if I manipulate UVs and feed the manipulated values directly into SceneColor, those calculations will happen in the fragment shader. If, instead, I add a UV pin to the material and pass the manipulated UVs into the pin, then I'm doing the calculations in the vertex shader and they are getting interpolated linearly into the fragment shader.

      Comment


        #4
        Okay, a little more help please.

        If I hook up the Scene Color node to diffuse:

        Click image for larger version

Name:	Screen Shot 2014-09-09 at 10.34.47 AM.png
Views:	1
Size:	57.9 KB
ID:	1056457

        I get pretty much what I expect:

        Click image for larger version

Name:	Screen Shot 2014-09-09 at 10.35.20 AM.png
Views:	1
Size:	624.7 KB
ID:	1056459

        However, I hit problems the second I want to mess with the UVs. If I hook up a TextureCoord node (with no UV pins turned on):

        Click image for larger version

Name:	Screen Shot 2014-09-09 at 10.34.13 AM.png
Views:	1
Size:	74.7 KB
ID:	1056460

        My expectation is that I'll get the same exact result as before, since I'm just passing the UVs in. But, that's not what I get (same result, whether I mask the TexCoords or not):

        Click image for larger version

Name:	Screen Shot 2014-09-09 at 10.34.36 AM.png
Views:	1
Size:	574.6 KB
ID:	1056462

        So, either I'm misunderstanding something about the way this works, or there's a bug. I'm guessing it's the former, but I don't know what I don't know, so to speak.

        Thanks!

        Jeff
        Attached Files

        Comment


          #5
          Hey Jeff -

          I answered you also on AnswerHub, but plugging the Texture Coordinate into the Customized UV0 input instead of the UV input of the Scene Color should correct the error that you are seeing.

          Comment


            #6
            Unfortunately, it doesn't seem to fix it, regardless of which UV index I use.

            Comment

            Working...
            X