Announcement

Collapse
No announcement yet.

Is this possible

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

  • started a topic Is this possible

    Is this possible

    Hi,

    I'm trying to make a mesh not render past another one, here is an example of what i'm trying to avoid

    Click image for larger version

Name:	waterplane.jpg
Views:	1
Size:	481.2 KB
ID:	1142078

    I was thinking that the only way this could be possible is with some sort of sorting priority, like always having the boat drawn over the water

    Is an effect like this possible with UE4?

  • replied
    Originally posted by Arnage View Post

    The fog calculation is based on an undistorted depth buffer, which causes the artifacts you're noticing. You could fix this by also distorting the depth buffer for the fog calculation, but there is another issue going on that I would recommend fixing instead:

    The fog extends above the water plane, as the solution described earlier doesn't handle looking back up like you are doing completely correct. Often this can be ignored, but in this case it just looks wrong. To fix this you should calculated the fog based on the distance up to, but not beyond, the water plane. If your water plane is flat this can be easily calculated inside the shader. If it isn't totally flat (for example due to waves) you need a more complex solution. For example, you could render the water plane to the custom depth buffer and then take the minimum of the regular and custom depth buffers as the distance to base the fog calculation on.
    Thanks a lot for your quick reply Arnage. I was able to fix it by not calculating the fog beyond the water plane, which is indeed flat in my case. Thanks!

    Click image for larger version

Name:	Screenshot_1.jpg
Views:	1
Size:	58.4 KB
ID:	1508281
    Last edited by Onoa; 07-29-2018, 05:24 AM.

    Leave a comment:


  • replied
    Originally posted by Onoa View Post
    Using Arnage's method, has anyone tried to implement underwater refraction for the water surface? I am using an inverted plane from my water surface with refraction enabled so that I can get refraction when underwater and looking up at the world outside of my water body. But it seems that the distortion is not being applied properly and not taking the PP fog into account. I've been trying to solve this for days now but to no avail.

    Here's what I am expecting the distortion to look like when underwater (combined with the fog PP effect ideally, but it's not enabled in this screenshot):

    And here's what it looks like with the PP enabled:

    Any input or pointer would be greatly appreciated.

    Thank,
    The fog calculation is based on an undistorted depth buffer, which causes the artifacts you're noticing. You could fix this by also distorting the depth buffer for the fog calculation, but there is another issue going on that I would recommend fixing instead:

    The fog extends above the water plane, as the solution described earlier doesn't handle looking back up like you are doing completely correct. Often this can be ignored, but in this case it just looks wrong. To fix this you should calculated the fog based on the distance up to, but not beyond, the water plane. If your water plane is flat this can be easily calculated inside the shader. If it isn't totally flat (for example due to waves) you need a more complex solution. For example, you could render the water plane to the custom depth buffer and then take the minimum of the regular and custom depth buffers as the distance to base the fog calculation on.

    Leave a comment:


  • replied
    Using Arnage's method, has anyone tried to implement underwater refraction for the water surface? I am using an inverted plane from my water surface with refraction enabled so that I can get refraction when underwater and looking up at the world outside of my water body. But it seems that the distortion is not being applied properly and not taking the PP fog into account. I've been trying to solve this for days now but to no avail.

    Here's what I am expecting the distortion to look like when underwater (combined with the fog PP effect ideally, but it's not enabled in this screenshot):

    Click image for larger version

Name:	Screenshot_2.jpg
Views:	5
Size:	136.1 KB
ID:	1505784

    And here's what it looks like with the PP enabled:

    Click image for larger version

Name:	Screenshot_1.jpg
Views:	5
Size:	55.3 KB
ID:	1505785

    Any input or pointer would be greatly appreciated.

    Thank,

    Leave a comment:


  • replied
    This is relevant:
    https://en.wikipedia.org/wiki/Underw...t_diagram3.jpg

    The same article states the visibility distance in clear ocean water is 74m.
    Last edited by duke22; 01-24-2018, 02:15 AM.

    Leave a comment:


  • replied
    Originally posted by Arnage View Post
    The alpha blend tends to work good enough at an angle, but straight on you might need something more indeed. That dying light example is an interesting approach. A bit dark, but that wouldn't be a big issue in your case as your scene is quite dark anyway. I couldn't resist to prototype it a bit, here's a material function to create such a mask that you could use in the glass material of your helmet to create a similar effect:

    [ATTACH=CONFIG]23695[/ATTACH]
    How you made it waving? mine stays as a simple line

    Leave a comment:


  • replied
    Originally posted by xnihil0zer0 View Post
    RyanB covers it above, but here's a quick example of how to do it with one volume. Assuming a water plane at z=0, This projects a plane, perpendicular to the camera view, 10 world units ahead. Then it checks if the intersection of each view ray and this plane has a z value less than 0. If it is, the post process is applied, if not, it returns scene texture. If your water plane material has some z world offset then check the intersection z value against that.

    [ATTACH=CONFIG]79052[/ATTACH]
    Great Blueprint! Thank you for sharing! Can you explain the last part "If your water plane material has some z world offset then check the intersection z value against that". I was able to follow your BP but when I added an ocean world displacement the PP_splitplane material is not following the water displacement as you mentioned.

    Leave a comment:


  • replied
    Originally posted by Nsomnia View Post
    This is something I've had trouble with other than using 2 post process volumes that meet at the middle around the character/boat/etc.
    RyanB covers it above, but here's a quick example of how to do it with one volume. Assuming a water plane at z=0, This projects a plane, perpendicular to the camera view, 10 world units ahead. Then it checks if the intersection of each view ray and this plane has a z value less than 0. If it is, the post process is applied, if not, it returns scene texture. If your water plane material has some z world offset then check the intersection z value against that.

    Click image for larger version

Name:	SplitViewPP.png
Views:	1
Size:	263.6 KB
ID:	1100690

    Leave a comment:


  • replied
    Originally posted by Kheka View Post
    There is a way to "cut" the post process material too see half underwater? Like this?
    This is something I've had trouble with other than using 2 post process volumes that meet at the middle around the character/boat/etc.

    Leave a comment:


  • replied
    There is a way to "cut" the post process material too see half underwater? Like this?

    Leave a comment:


  • replied
    Actually i figured it out, here's an example



    Leave a comment:


  • replied
    The main reason why i'm trying to find a better solution to how i did it is that i had to switch to a tiled underwater terrain with world composition, initially my water surface was sitting at Z 0.0, world composition doesn't allow me to lower my terrain so i had to re-do my entire coding and raise my entire scene to match the new height, the whole absorption post process had to be re-adjusted to really high values since my surface is now around Z 55,000, being able to mask the effect would look much better too

    Leave a comment:


  • replied
    Originally posted by KhenaB View Post
    Not exactly, the method in post #71 is similar to what i use right now, when in the suit with head above the water surface i can see the underwater part without the effect, when under i can see the ship's interior with the effect, this is happening because i can see both underwater and above water when floating at the surface

    I wanted to know if it would be possible to have the effect rendered at all time (or at least slightly above the surface to cover my helmet) but mask the effect from being rendered inside my ship, so that when floating at the surface i can see both the underwater part and the ship interior like they should be

    @RyanB, i'm going to have to re-read that a couple of times, i have used masks in the past to mask out materials from being rendered in specific shapes and locations and was wondering if a similar approach could work, i'm not very good with maths so it might take me a while to understand what you're trying to explain

    Thanks
    You're right, that's why I deleted the post when I saw Ryan's and noticed that I was wrong, but I guess you had read it already

    Leave a comment:


  • replied
    Originally posted by Arnage
    Actually the implementation I posted before already handles this. If you go back to the full post process shader in post number #71 you can see I added a part that limited the influence to only affect surfaces below the water level.

    Is that what you meant?
    Not exactly, the method in post #71 is similar to what i use right now, when in the suit with head above the water surface i can see the underwater part without the effect, when under i can see the ship's interior with the effect, this is happening because i can see both underwater and above water when floating at the surface

    I wanted to know if it would be possible to have the effect rendered at all time (or at least slightly above the surface to cover my helmet) but mask the effect from being rendered inside my ship, so that when floating at the surface i can see both the underwater part and the ship interior like they should be

    @RyanB, i'm going to have to re-read that a couple of times, i have used masks in the past to mask out materials from being rendered in specific shapes and locations and was wondering if a similar approach could work, i'm not very good with maths so it might take me a while to understand what you're trying to explain

    Thanks

    Leave a comment:


  • replied
    *EDIT*, doh, I accidentally replied when looking at page1 of this thread. Somehow I missed all the other posts talking about this problem. The below approach would be for a case where the water was a real plane being masked by a box mask in the world. It would build the lip into the water material rather than on another window mesh.

    It is possible but kinda tricky since you need to "project" your plane mask forward by solving the right triangle defined by your view vector and desired water lip height.

    To solve the triangle remember that a^2 + b^2 = c^2 where c is hypotenuse. Can get hypotenuse length for a unit vector side by doing dot(cameravector,PlaneNormal). Then you get the slope by doing a/b (aka rise/run).
    Then the forward extention amount is simply lipheight * (1/Slope).

    So you keep your current mask as the Lerp alpha between top and side water. Then you use the larger projected mask to cut out beyond the water lip.

    To define the normals of the lip you could Lerp between two vectors, an upvector and the normal of the inside of your glass pane, using the distance between the original mask and extended mask.
    This will only work for when the view is above the water looking down. Solving the other case is also possible but requires a bit more work that isn't coming off the top of my head.
    Last edited by RyanB; 05-15-2015, 07:45 PM.

    Leave a comment:

Working...
X