Announcement

Collapse
No announcement yet.

Is this possible

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

  • replied
    I'm not exactly sure where the distance factor should be added, as an alpha for the Turbidity Diffusion's lerp, correct?

    Leave a comment:


  • replied
    Setting my material to before tonemapping solved it

    Thanks Arnage and MissStabby

    Leave a comment:


  • replied
    For the banding, do you also get this same effect if you make a long object and give it a zheight based gradient that lerps between 2 color values?

    It might be some floatingpoint inaccuracies, how big is the scene actually, 1:1 scale or is it actually scaled down a lot compared to 1unit = 1cm?
    Another thing to check is any display/gpu settings, are you rendering 32bit or 16bit color to your monitor?

    Leave a comment:


  • replied
    Originally posted by KhenaB View Post
    However i still get heavy banding and strange outlines caused by fringe, the banding could be caused by something in my global post process

    About the outlines, should i just avoid fringe or is this something that can be solved?

    Did you experience any of that?
    Sound to me like you are blending at the wrong time. In your post process material make sure that blendable location is set to "Before Tonemapping". This should solve both the fringe issue and the banding.

    Originally posted by KhenaB View Post
    I have made an observation

    Objects in the scene are tinted by the turbidity diffusion depending on the camera angle (lerp A to B)

    Shouldn't distance from them also affect this, for example from really close up objects are still heavily tinted

    Although i don't fully understand the whole mechanic behind this, I think distance from camera to objects should also be a factor

    What do you think?
    That is indeed correct. That's what I get for trying to finish the shader and post late at night... As my temp geometry was overly bright this error wasn't really visible, but you should indeed add a distance factor to the additive part of the effect to prevent over-brightening objects close to the camera.

    Leave a comment:


  • replied
    I have made an observation

    Objects in the scene are tinted by the turbidity diffusion depending on the camera angle (lerp A to B)

    Shouldn't distance from them also affect this, for example from really close up objects are still heavily tinted

    Although i don't fully understand the whole mechanic behind this, I think distance from camera to objects should also be a factor

    What do you think?

    Leave a comment:


  • replied
    It works wonderfully, this is beyond my expectations, you did it again

    However i still get heavy banding and strange outlines caused by fringe, the banding could be caused by something in my global post process

    About the outlines, should i just avoid fringe or is this something that can be solved?

    Did you experience any of that?
    Last edited by KhenaB; 03-31-2017, 06:12 PM.

    Leave a comment:


  • replied
    That effect looks great Arnage, I'm bookmarking this page just in case I ever decide to do something underwater.

    Leave a comment:


  • replied
    Arnage, this is incredible, i have to try this right now

    I almost feel like i'm cheating, this is way beyond my level of skills, but i'm going to study the materials and try to understand what you did

    I will be back with my results

    Thanks again

    Leave a comment:


  • replied
    Actually MissStabby is right, adding the effect to the materials themselves can have the same effect as using a post process material. As long you make sure the empty space has some kind of geometry (such as a skybox) to calculate the effect for those pixels. I doubt there will be a significant difference in performance though.

    I couldn't resist prototyping a new method (at least for me, not claiming no one else came up with this before me :P) to more accurately (yet cheaply) simulate the underwater light interaction. Here's the result compared to exponential height fog:

    Click image for larger version

Name:	WaterFoggingcomparison.jpg
Views:	1
Size:	39.2 KB
ID:	1072105

    (The scene itself is just an ugly noise landscape with a white material)

    Here is a breakdown of the main steps:

    Click image for larger version

Name:	WaterFogging.jpg
Views:	1
Size:	58.2 KB
ID:	1072106

    As you can see there are two absorption parts. The first is from the sun to the object, and is implemented with a light function. The object to camera absorption and turbidity diffusion are both done in a post process material.

    Finally the turbidity diffusion correctly responds to the depth and camera orientation:



    I ended up using the Beer-Lambert law a lot so the first step was to create an absorption material function:

    Click image for larger version

Name:	AbsorptionFunction.png
Views:	1
Size:	111.0 KB
ID:	1072110

    The lightfunction on the sun then simply applied this function based on the depth along the Z axis. (for simplicity's sake I placed my water plane at Z = 0)

    Click image for larger version

Name:	LightFunction.png
Views:	1
Size:	64.0 KB
ID:	1072112

    Finally we have the post process material:

    Click image for larger version

Name:	PostProcessMaterial.png
Views:	1
Size:	270.4 KB
ID:	1072113

    The direct light part handles the absorption between the camera and object. Finally getting a nice approximation for the turbidity diffusion turned out to be simpler then I thought. The orientation part of the effect is handled by simply taking the camera vector Z axis to fade out the further down you look. (As stated in the comment box this could also be oriented toward a sun actor, but in your overcast scene a vertical orientation probably works best) Finally the depth effect was achieved by using the absorption function again, but this time taking the depth of the camera itself as an input.

    Thanks for providing another nice challenge I hope I described my process well enough so the results can also help you out.

    PS. I noticed while making this post that I used a different Distance Factor in the lightfunction compared to the post process material. It is more physically accurate to keep those the same, but as this is art there is nothing stopping you from tweaking the value for each part of the effect.

    Leave a comment:


  • replied
    Hi MissStabby and thank you for chiming in

    From what i understand with your solution only the objects would be affected (their material)

    I also need to consider the empty space in which i'm swimming as an "object" to simulate a water density, this is what my height fog does, even if it isn't really accurate it's the simplest method i know of, without the fog it would look as if i'm swimming in thin air

    Therefore to really get the effect i'm after, the water (fog) also has to be affected by this effect

    Again thank you for chiming in, any help is really appreciated, i hope i understood your suggestion properly

    Leave a comment:


  • replied
    Would it be feasable to use worldspace Z coordinates mixed with the distance from the camera to create a fog like overlay material that all underwater objects use?
    As long as all objects in the underwater scene use the material it should look "correct"

    here i did a quick mockup:
    Click image for larger version

Name:	ajt6Jv2.jpg
Views:	1
Size:	165.8 KB
ID:	1072085

    Currently it just uses a lerp to switch between two colors, however i can imagine you could use a much more detailed lookup table to determine how colors change with distance and height.

    EDIT:
    Another way is to use the z height to suck the colors out of your objects using special materials and then use a fog to take care of the the depth effect
    Last edited by MissStabby; 04-07-2015, 11:27 AM.

    Leave a comment:


  • replied
    Thank you for the in-depth explanation Arnage, doing it accurately sounds really complicated, are we talking about changing how my directional light is behaving underwater, or faking this effect somehow, the fog was my way of faking a water body and adding the brightness diminishing effect to the fog was the only way i could think of to fake the light absorption

    Leave a comment:


  • replied
    Sorry for not replying sooner, I wasn't around a computer over Easter.

    It is indeed mathematically a bit more complex to do it properly.

    The first step to making it more accurate would be separating the light absorption from the light diffusion. Those are the main effects you are dealing with and replacing them with a single fog factor is not particularly accurate. Absorption is the effect that less light reaches you the further the ray has to travel through the water, while the turbidity of the water causes the light from above the surface to be scattered to create the diffuse colored haze in the water.

    The absorption is only dependent on the distance the light has traveled through the water and can be easily modeled with the Beer-Lambert law.

    The diffusion due to turbidity is more complex as it technically not linear and dependent on both depth and orientation. To do it properly you would probably have to use something like raymarching. However, you can probably get quite close with a linear approximation.

    If it would help I can see if I can find the time to create another prototype.

    Leave a comment:


  • replied
    Glad you like it, i'm getting there slowly

    Leave a comment:


  • replied
    Love the progress KhenaB!

    Leave a comment:

Working...
X