I was wondering how to do this, I have a idea on how to create a easy water prefab, but not sure on a few parts. I want to create a empty gameobject with a plane and cube attached to it. The plane is used for the waters surface and shader, attached with scripts and shaders I know that it will appear as water, this is all understanding to me. Now for the cube, underneith the plane there is a cube that is unrendered. I know for scripting it would have to be like a OnTriggerEnter, or something to tell the game the player is entering the water, and after a certain point, change the screen to give it a underwater look. Is there any information on how to do the underwater look with the scripting, or either? I have tried search and it only brings up pre-made assets (which I do not want to use) and people bashing others for asking this question.
One way Of doing an underwater look is to change the fog settings. Make it so the fog is very close to the player. Make it blue or whatever color you want.
Yeah, fog is the easiest. Make it closer, more dense, and more of a blue color when the player is in the water. Other popular techniques are to turn on a warpy, post FX shader. PS - Pre-existing assets are not just for using, they can be a great way to learn, too. It's not wrong to pay other people for their knowledge!
You can use a method like this: Using the formula that is given around 18:16 in the video, you can calculate how much of the screen is submerged and draw a blue and partially transparent texture on that part of the screen.
Hello Giano if I follow them may be km going to trouble . This formula is not shown proper way, and km is a beginner and I am also so please post best formula.
I did not notice that. The formula gives the proportion of the camera that is above the water. The correct formula is Proportion of camera underwater = 1 - (h1 - h0)/(h1 - h2) h1 is the height of a GameObject placed just above the cameras viewport. h2 is the height of a GameObject placed just below the cameras viewport. h0 is the height of the water plane. In this image the values are h1 = 2.8 h2 = 1.7 h0 = 2.0 And the result will be Proportion of camera underwater = 1 - (2.8 - 2.0)/(2.8 - 1.7) = 0.273 You will use this number to calculate the amount of pixels the blue texture has to take up. So if your screen height is 1080 pixels the result will be Blue texture height = Screen.height * 0.273 = 1080 * 0.273 = 295 pixels. You will then need to draw the texture from the bottom of the screen and 295 pixels up. If the result is <= 0 then the entire screen is underwater. I hope this helps.