Please or Register to create posts and topics.

Swimming in normal water

Page 1 of 4Next

Hey,

I would like to create normal water in hammer. The player has to be able to swim and cubes must not swim so they can be placed on the ground.

I tried several "liquid-type" textures. The water looks nice from above with "liquids/water_swamp_m2_beneath" but the cube is swimming on top and the player is moved by a current/steam although I have just a pool. Also, if the player dives everything gets brown like under toxic water, although the water looks very clear and clean from above.

Do you have any idea how to fix one or all of these problems?

Thanks for reading!
Leon

Hey Leon!

That is not difficult to achieve. But I'd suggest you to create a custom water material since all stock ones are too much goo like. You could take one of the stock ones (located into portal2/portal2/pak01_dir.vpk file that you can open with GTFScape and into the folder /liquids or /nature)

The key to make the water look like "normal water" is to add into its .vmt material file the following line:

$traslucent 1

You can set its "translucency" with this parameter:

$waterblendfactor 0.30

(go changing the value being a value of 1 = not translucent at all)

Make the brush as usual: all textured nodraw except top side of it.

If you can't make it don't hesitate to send me a pm so I can help you :thumbup:

EDIT

You must know that a water material with the suffix "_beneath" is used as a bottom material, not really on the surface (top of the water brush), ok? if you look into its vmt file you'll see it is different than the rest in several lines, one of the most important oes is this:

$abovewater 1 (for top maaterial)
$abovewater 0 (for bottom maaterial)

ImageImageImageImageImageuseful tools and stuff here on TWP :thumbup:
[spoiler]ImageImageImageImageImage[/spoiler]

Hi Josepezdj,
I have read your post regarding the water several times the last months and also started to map again. But I could not make it yet. In between I had to do other stuff so thats why i write to you so late now.

I exported all the water vmt-files from the nature folder and tried to understand them. They didnt see so much different to me, so I took water_bts_01 and extracted it into my portal2/portal2/materials folder. I edited it as you said but when I rendered the map it was still yellow/brown and goo like.

There are the lines:

$abovewater 1
$bottommaterial "nature/toxicslime002a_beneath"

so although above water is "1" an bottommaterial is given? I tried to change it to $bottommaterial "liquids/water_river_normal_sharp" but no effect.

I also tried to adjust the fog values, which were default:

$fogenable 1
$fogstart 0
$fogend 60
$lightmapwaterfog 1

$fogcolor "{ 90 70 20 }"
$flashlighttint 1
"%compilewater" 1
"%tooltexture" "nature/water_frame01_normal"
$surfaceprop slime

I changed color, fogstart, and even disabled fog but somehow I could not see any effect ingame.

Could you post the content of a vmt-file that would work?

And what is also bothering me with the nodrow texture on the sides: I want to fill an aquarium, so it should not look from side the same as empty :/

Thanks in advance. :thumbup:

Hi Leon:

Sorry, I missed your post! :D Let me explain the parameters you should consider to make the translucent water:

- First of all, I made a stupid mistake and said $translucent 1 where I should have said $pseudotranslucent 1... sorry for this! THis parameter is the most important to make your water translucent.

- Now you can modulate that translucency by changing the value of $waterblendfactor as I already told you in previous post, where 0 is totally transparent and 1 opaque. Usually 0.5 is a good value.

Leon wrote:
I edited it as you said but when I rendered the map it was still yellow/brown and goo like.

This is because of the following line:

$basetexture "liquids/toxicslime_color"

Just delete it, it is not required for the water to work, and it is what gives the water the goo look. However, if you don't want to erase it BUT you introduced the $pseudotranslucent 1 param, you can still have translucent water with values of $waterblendfactor closer to "0".

Leon wrote:
There are the lines:
$abovewater 1
$bottommaterial "nature/toxicslime002a_beneath"
so although above water is "1" an bottommaterial is given? I tried to change it to $bottommaterial "liquids/water_river_normal_sharp" but no effect.

Listen, I think you have all concepts a bit mixed up altogether :) There are a few required parameters for the water to work properly:

1. the above material: this is the main one and is declaredd by $abovewater 1. It's the water you see from above the surface.

2. the bottom or beneath material: this one must be declared in the main material, and that's done by $bottommaterial "[path to the bottom texture material name here]". This is the water you'll see if you jump into the water, from below the surface (when you die into Portal you see this dirty goo, that is the "nature/toxicslime002a_beneath" that many of the materials use)

3. fog: the water shader is a fogged material, you just can't disable fog. It's declared by the $fogenable 1 parameter into the main material.

4. the normal map: this is how the water surface shape looks like. The water_river_normal_sharp.vtf is one example of these, there is also another into /nature folder in the .VPK called water_frame01_normal... you can open them to check, they are all blueish because the engine uses this colours-code to understand the information about a given surface. So these only affects the shape of your water surface, ok? You declare it by $normalmap "[path to the normal texture name here]"

5. the flow map: this is the movement of the surface of your water; these are also "maps", like the nromal map, and have a certain colours-code that the engine uses to understand where to move what part. There are a bunch of them into the /liquids folder inside your .VPK file. You declare it by $flowmap "[path to the flow texture name here]"

Additionally, for the translucent water, the fog color, and where your fog starts and ends is important:

- The color because it will make your water lighter (clear) or darker (dirty). Bookmark this page in order to know the RGB colours used in mapping. Find the lightest colours for your transparent water.

- $fogstart: it's the distance from the "eye" to where the fog must start in inches. This use to be "0", and the VDC indeed says that it "Must be 0 for edge fading to work properly"

- $fogsend: distance from the eye where the fog should end in inches. To be honest, I can't really see any significative difference in the above material when your water is pseudotranslucent, but it does make a difference in the bottom one: you want to give it values above 200-300 in order to see clearly underneath the water.

I'm attaching 2 materaials, above (josepezdj_water_transparent.vmt) and bottom (josepezdj_water_transparent_beneath.vmt), for you. Check and test them. You must place the bottom one into a /josepezd/water folder, or change the path to the correct location into the "above" material, ok?

Regarding your aquarium, I'm afradi you should find a workaround for that. Your water brush must be always textured nodraw except the topmost face, no exceptions; you can't either texture a vertical face, only one that's horizontally oriented, ok? This is a limitation of the shader "Water".

However, there are workarounds. You could fake the sides of that aquarium by creating another material with the "Refract" shader instead of the "Water" shader. There is a good tuto at Interlopers about this if you need more help :wink:

I look forward to see what you do with transparent water!

ImageImageImageImageImageuseful tools and stuff here on TWP :thumbup:
[spoiler]ImageImageImageImageImage[/spoiler]

Thank you so much josepezdj. I probably have to read your post 5 more times to understand all of it. :lol:

I created a new folder "my materials" inside the folder "portal 2/portal2/materials", copied your files in it and changed the path for the beneath material inside the main material accordingly.

But the water is white from above and black from below. Do you have an idea?

And do I have to compile the map again or just reload the map, after I change the material text file?

Just typing mat_reloadmaterials into the console should be enough. See if that helps.

What did you set as the bottom texture? And remember, water won't work on vertical surfaces. Only horizontal rectangles.

Falsi sumus crusto!
Leon wrote:
But the water is white from above and black from below. Do you have an idea?

If what I'm seeing around your pool is a glass texture, that's the problem. Try testing it without glass, but whatever other texture instead, it should work good. Glass has special properties and the engine compile those materials giving them these properties. I told you that for the sides you should use different materials making use of the refract shader, not the water shader...

ImageImageImageImageImageuseful tools and stuff here on TWP :thumbup:
[spoiler]ImageImageImageImageImage[/spoiler]

Sure, I did not apply a water shader on the side. It is one brush with all sides "no draw" except the surface. The glass box is made of extra brushes. Is that still a problem? I mean... how can I fake a empty glass box and a partly filled glassbox without using glass?

Thanks.
And also for the reload command! :thumbup:

Leon, the shader is at the beginning of the texture material, the .vmt file. If you check into the 2 files I posted, both start with "Water", right? THAT is the shader the material "is calling to", or "is using", understand?

You textured the water brush properly: only the top face must be texture with the (above) water material, rest with no-draw. BUT you must not use glass material for the brushes that contain the water, ok? Please change those glass textures surrounding the water brush and you'll see that the water appears correctly, not white.

Then, my suggestion is to create different materials to use them apart to fake the side walls of your pools, but for this you should use separate brushes, not those that contain the water, ok? (for example 1 unit thick brushes at each of the 4 sides of your pool). This time, since they must appear on vertical side of a brush, you should use "Refract" shader instead of "Water" one inside the material, ok? ("Water" shader can only be used on horizontal faces)...

I'm really busy lately, but I'll try to prepare some refract material to be used there. :thumbup:

ImageImageImageImageImageuseful tools and stuff here on TWP :thumbup:
[spoiler]ImageImageImageImageImage[/spoiler]

hey... i tried to get it work for 3 hours now. But there is so much more I dont understand :/

I have two maps with the water, one for testing (naked room with water) and the real map "H2O" imported from the PETI editor.

I removed the glass in my test map, as you said, and yes the black stuff was gone and the water looked nice from beneath! But it was still white on top. I think I know the reason:

Somehow my hammer does not render the light maps correctly or at least my portal does not load them. I started portal via hammer and all was bright, no shadows. Then I restartet portal again via steam and tested a custom map where i had shadows again. When I loaded the map "H2O" via console without rendering it again suddenly I had correct light maps. From above settings are fine now. Although I still dont know why it worked this time and not before (and now my shadows are gone again). When I dive into the water in the "H2O" map, the surface from beneath is not working properly as you can see in the screenshot (ignore the black, there is just no wall there). The color is changing rapidly to all diferent kind when the player moves through the water.

And is there a way that the player is not pushed by the water? It's like in a river as default.

This is tough :notwant:

PS: My console is spamming this message
***** Trying to set a pixel shader that failed loading!*

Page 1 of 4Next