Home Unreal Engine

SceneDepth-based material problem.

polycounter lvl 13
Offline / Send Message
adinolfi polycounter lvl 13
Hey guys. I usually lurk, but I'm having some trouble with a postprocess material I've been working on. I'm trying to selectively mask zdepth in relation to the current location of the pixel being drawn, or pixeldepth/destdepth if that makes sense.

The problem is, I've done a lot of research and tried a few methods but I can't get the material to dynamically update in realtime. It's driving me nuts. I've isolated the area in the shader network here:

3wexP.png

And here's an image of the scene with the material applied:

loG4Q.png

It's hard to show/explain(this really isn't my strong suit), but moving around and pointing at objects at different depths doesn't change the offset of the SceneDepth mask, and I'm not sure why?

Any advice is super appreciated, and if I'm not being clear I'll try explaining further.

Replies

  • ImSlightlyBored
    Options
    Offline / Send Message
    ImSlightlyBored polycounter lvl 13
    what do you want to do? have the depth at the center of the screen be the focal distance?
  • adinolfi
    Options
    Offline / Send Message
    adinolfi polycounter lvl 13
    Blah my first post was really wordy.

    Kind of, I'd like the distance to the object under the crosshair be the starting point for the depth mask. Which is pretty similar to what you said.
  • Harbinger
    Options
    Offline / Send Message
    Harbinger polycounter lvl 8
    If I understand what you're trying to do correctly, that isn't possible by default. Scene depth and dest depth have nothing to do with where your crosshair is pointed, and the only way they are "dynamically updated" is by moving the camera. What visual effect are you trying to achieve? There may be a different approach.
  • adinolfi
    Options
    Offline / Send Message
    adinolfi polycounter lvl 13
    My goal is a basic depth of field shader. I already have the blur portion working so this is what I'm stuck on now.

    As I understand it, DestDepth is the distance of the pixel being drawn under the crosshair, so I figured plugging that into a Distance node with a Camera World Pos would update that distance as the crosshair moved, in turn changing the offset of the depth mask I had. I'm doing something wrong clearly though. Is there a better way to get a "selective" depth of field style mask?

    My goal is to do this purely with the nodes available in the material editor, so no custom nodes.
  • Harbinger
    Options
    Offline / Send Message
    Harbinger polycounter lvl 8
    Ahh ok I see. The crosshair doesn't work like that. The DestDepth node works on all pixels in the base render pass, not the crosshair, which is just a UI element. The most classic use of DestDepth is for water, in which you can sample the depth of the next pixel behind the water surface and in return make the water more or less opaque.

    If you want your DOF to dynamically adjust it's focal point depending on where you aim, I can't think of any way to do that with the default material editor nodes. You would probably have to do some Unreal Scripting to get that type of feature.
  • adinolfi
    Options
    Offline / Send Message
    adinolfi polycounter lvl 13
    Man, I can't even imagine where to start with that. I've never heard of anyone doing it through uscript.
Sign In or Register to comment.