Water texture that isn't actually water?

Avatar
ChickenMobile
2,460 Posts
Posted Jul 26, 2014
I've been trying to create a texture that looks and has all the compiled water shaders but isn't actually water. The whole point of this is I want to remove/hide the water at some point in the map.
Just disabling the drawing of water won't cut it as the player needs to walk through this area.

Removing the $compilewater or changing it from Water to LightMappedGeneric inside the .vmt does some nasty ass rendering.

Any ideas?

LightMappedGeneric
{
$forceexpensive 1
$normalmap "liquids/water_river_normal_sharp"
$flowmap "liquids/c3m2_hflowmap_a"
$flow_normaluvscale 155.0
$flow_worlduvscale 0.5
$flow_timeintervalinseconds 0.2 
$flow_uvscrolldistance 0.075 
$flow_bumpstrength 0.4
$flow_timescale 0.35
$flow_noise_texture "liquids/water_noise"
$flow_noise_scale 0.0005
$flow_debug 0
$reflecttexture _rt_WaterReflection
$reflectamount "0.4"
$reflecttint "{ 190 190 190 }"
$reflectskyboxonly 1
$reflectonlymarkedentities 1
//$abovewater 1
$bottommaterial "nature/toxicslime002a_beneath"
$fogenable 1
$fogstart 0
$fogend 60
$lightmapwaterfog 1

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

$pseudotranslucent 1
$waterblendfactor 0.75
}

Edit: Perhaps I could make two areas that look the same through world portals, but much obliged if this could be avoided.

Advertisement
Registered users don't see ads! Register now!
Avatar
FelixGriffin
2,680 Posts
Posted Jul 26, 2014
Replied 19 minutes later
Put a world portal over the surface of the water; when it's off the water is there, when it's on it's not. That's the best I can think of at the moment.
Avatar
ChickenMobile
2,460 Posts
Posted Jul 26, 2014
Replied 2 minutes later

FelixGriffin wrote:
Put a world portal over the surface of the water; when it's off the water is there, when it's on it's not. That's the best I can think of at the moment.

That is a worse solution than my edit solution... :S.
Suppose josepezdj might know some things?

Avatar
CamBen
973 Posts
Posted Jul 26, 2014
Replied 2 hours later
I guess you could try looking at the texture on those weird orange tubes of liquid in kleiner's office, if you have hl2. They aren't real liquid textures, but they're pretty convincing.
Avatar
FelixGriffin
2,680 Posts
Posted Jul 26, 2014
Replied 1 hour later
Other than world portals, I don't think there's a way to get "expensive" (real-time reflecting) water to appear and disappear. Depending on your layout you could move the floor up a little bit to make the water go away, but that's even worse.
Avatar
TeamSpen210
608 Posts
Posted Jul 26, 2014
Replied 49 minutes later
This is pretty much what you want. You'd have to port the special water textures from another game, and I'm not sure if Portal 2 even has the func_water_analog entity. It works basically like func_movelinear.
Avatar
RustyDios
154 Posts
Posted Jul 26, 2014
Replied 1 hour later
Can you not just turn the water brush into a func_brush and disable it when needed ?.. (and also disable the kill triggers ?) ....
Avatar
User
630 Posts
Posted Jul 26, 2014
Replied 15 minutes later

RustyDios wrote:
Can you not just turn the water brush into a func_brush and disable it when needed ?.. (and also disable the kill triggers ?) ....

This will not work.

Avatar
Another Bad Pun
516 Posts
Posted Jul 26, 2014
Replied 53 minutes later
Portal 2 doesn't support func_water_analog; I'm almost positive. If you feel insane enough, you could fake the effect by moving the whole room and not the water. Honestly, that sounds awful, so I would either fake it with world-portals or use a 3D skybox trick. I'm not entirely sure about this, but you could create the actual water in a 3d skybox and position it so it shows up inside the level. It would be a "mirage", and when you needed to you could disable the 3D skybox camera (I'm pretty sure you can do that) to make the water disappear.

Things that might make this method impossible:
-Water not showing up due to actual world geometry overlapping it
-Gross reflections
-You would have to pair it with invisible water

Might take some time, but who knows what could happen?

Avatar
FelixGriffin
2,680 Posts
Posted Jul 27, 2014
Replied 4 hours later
Func_water_analog does work in Portal 2 (or at least it did last year...it might have broken in an update), but you need to use the P1 goo texture with it.
Avatar
ChickenMobile
2,460 Posts
Posted Jul 27, 2014
Replied 1 hour later

Another Bad Pun wrote:
Portal 2 doesn't support func_water_analog; I'm almost positive.

Confirmed does, was playing around with this previously

Problem is that dx70 textures only really support cubemap reflections and they look utterly horrible - the fog you see while in water cannot be rendered and it relies on scrolling/animated textures instead of the cool blending water effects compiled with water.

Probably the best effect on moving water is to make the water completely opaque and rely on cheap reflections from cubemaps - like Dr Keleiner's orange tubes.

I however did have a dream last night with dx90 proxies... is this a sign?
Although the image from cs_militia looks promising - may steal this.

Avatar
HMW
806 Posts
Posted Jul 28, 2014
Replied 1 day later
I've had a reflecting and refracting water-like material in Portal 1 at one point. I vaguely remember using a "refract" shader with some special keywords for the $envmap and $refracttexture parameters, "_rt_reflection" and "_rt_refraction" respectively. However performance was horrible so I trashed it. Tried to reproduce it in Portal 2 but those keywords don't work anymore. (Or I remembered them wrong.) Would pursue this further but my GFX card is feeling very crashy today

I think your alternative idea is not so bad: to have a room with water and one without, and teleport between them. That's what I did in "A beam too far", to turn the lights on after the power-up. You may be able to avoid world portals by using a "relative" trigger_teleport. (One with a landmark set.)

If you want to try the 3D skybox method, you'll need to name your sky_cameras (add a "targetname" attribute outside of SmartEdit) and send them "activateskybox" inputs to switch between them. But the reflection is probably still going to be off unless you build a miniature version of the whole map inside the 3D skybox.

Avatar
josepezdj
2,386 Posts
Posted Jul 29, 2014
Replied 10 hours later

ChickenMobile wrote:
Suppose josepezdj might know some things?

Well, first of all, you already know many of those parameters you used into your material are specific for the Water shader, so they're not doing much there

To me there are 2 possible shaders to use here, LightmappedGeneric and Refract to have water without the Water shader and therefore to be able to apply the material to brush entities. However the idea behind both is the same, you've already got 2 interesting animated textures (from the HL years) inside the pak01_dir.VPK:

- dev/water_dudv.VTF
- dev/water_normal.VTF

If you 'play' them into VTFEdit you'll see all frames in motion doing a cool water surface movement. So basicly you need to add the corresponding proxies into your material files in order to animate them at a certain same rate. Like so:

Proxies
{
   animatedtexture
   {
      animatedtexturevar $dudvmap
      animatedtextureframenumvar $dudvframe
      animatedtextureframerate 30.00
   }
   animatedtexture
   {
      animatedtexturevar $normalmap
      animatedtextureframenumvar $bumpframe
      animatedtextureframerate 30.00
   }
   texturescroll
   {
      texturescrollvar $bumptransform
      texturescrollrate .05
      texturescrollangle 45.00
   }
}

This is the full content for that material I made for Oxygen Station's human capsules glass, using the Refract shader:

Refract
{
$model 1
$refractamount ".2"
$forcerefract 1
$bluramount 1
$refracttint "{164 210 219}"
$scale "[0.5 0.5]"

$dudvmap "dev/water_dudv"
$normalmap "dev/water_normal"
$dudvframe 0
$bumpframe 0

$surfaceprop water

%toolstexture "josepezdj/water/jose_vertical_wall_of_water"

$refracttinttexture "josepezdj/water/jose_vertical_wall_of_water"

Proxies
{
   animatedtexture
   {
      animatedtexturevar $dudvmap
      animatedtextureframenumvar $dudvframe
      animatedtextureframerate 30.00
   }
   animatedtexture
   {
      animatedtexturevar $normalmap
      animatedtextureframenumvar $bumpframe
      animatedtextureframerate 30.00
   }
   texturescroll
   {
      texturescrollvar $bumptransform
      texturescrollrate .05
      texturescrollangle 45.00
   }
}

}

NOTES:

  1. I added the param '$model 1' because I turned the capsules into models, just erase that line in order to be able to locate the material into your texture browser and to actually use it on a func_brush or whatever brush entity.

  2. The Refract shader could seem a bit annoying and difficult to implement without seeing purple checkerboards or a lot of console messages about a bad rendering; in order to avoid that, you need to use the param '$refracttinttexture' with a path to an actual texture (I made a soft smokey blueish one for my capsules, which I'm attaching to this post as example).

[EDIT] 3. If you need to see the refracting movement from underneath the water, just add "$nocull 1" to the VMT material.

[EDIT] 4. I guess that you could use a fog_volume entity right in the hollow of the water pool to complement the water beneath...

If you want to try out the LightmappedGeneric shader, the idea is the same, but you need to do it differently. I posted some working materials for the func_water_analog (that does work in P2) some time ago here.

Here the idea is to animate the $basetexture texture with proxies, while you also play with its offset and scale. Check:

"Lightmappedgeneric"
{
   "$abovewater" 0   
   "%compilewater" 1
   "$basetexture" "josepezdj/water/jose_turquoise_water_animated"
   "$scale" "[1 1]"
   "$translucent" "1"
   "$nocull" "1"
   "$surfaceprop" "water"
   "$envmap" "env_cubemap"
   "$envmaptint" "[1 .9 .8]"
   "$envmapcontrast" "1"
   "$texoffset" "[0 0]"
   "$texscale" "0.5"
   "$bottommaterial" "josepezdj/water/water_movingplane_beneath"

   "Proxies"
   {
      "AnimatedTexture"
      {
         "animatedtexturevar" "$basetexture"
         "animatedtextureframenumvar" "$frame"
         "animatedtextureframerate" 20.00
      }

      "TextureScroll"
      {
         "texturescrollvar" "$texoffset"
         "texturescrollrate" .005
         "texturescrollangle" 45.00
      }

      "TextureTransform"
      {
         "translateVar" "$texoffset"
         "scaleVar" "$texscale"
         "resultVar" "$basetexturetransform"
      }
   }
}

If you don't really like my edited (turquoise) animated texture, let me know, I can send the original "silvery" one when I arrive home later today.

Try any of those approaches and check out how they look in-game, however, forget about real-time reflections, it's impossible to achieve it without the Water shader and the $reflecttexture _rt_WaterReflection / $refracttexture _rt_WaterRefraction.

Do not hesitate to give me a buzz if you need further assistance from me.

Avatar
DaMaGepy
361 Posts
Posted Jul 29, 2014
Replied 8 hours later
speaking of waters.... anyone know how to lower the volume of that annoying loud soun when I step into a water? MAybe just replacing the wav that it plays with a lower volumed sounfile is enugh? Even if I only step into a small puddle it still plays that annoying effect.
Avatar
josepezdj
2,386 Posts
Posted Jul 29, 2014
Replied 22 minutes later
@Damagepy: Well, looking into the file "portal 2/portal2/scripts/surfaceproperties.txt" you'll find the different sound entries each surface property will fire.

You've got "mud", "water" and "slime" here. But all of them fire these sound entries:

  • Mud.StepLeft
"Mud.StepLeft"
{
   "channel"      "CHAN_AUTO"
   "soundlevel"      "SNDLVL_NORM"
   "volume"      "0.60"
   "pitch"      "90,105"
   "rndwave"
   {
      "wave"      "player/footsteps/mud1.wav"
      "wave"      "player/footsteps/mud3.wav"
   }
}
  • Mud.StepRight
"Mud.StepRight"
{
   "channel"      "CHAN_AUTO"
   "soundlevel"      "SNDLVL_NORM"
   "volume"      "0.60"
   "pitch"      "90,105"
   "rndwave"
   {
      "wave"      "player/footsteps/mud2.wav"
      "wave"      "player/footsteps/mud4.wav"
   }
}

Those 2 sound entries are defined inside "portal 2/portal2/scripts/game_sounds_physics.txt", where you find the 4 sound files they're using:

  • player/footsteps/mud1.wav
  • player/footsteps/mud2.wav
  • player/footsteps/mud3.wav
  • player/footsteps/mud4.wav

(all relative to /sound and inside the "pak01_dir.VPK")

The only way I can think of tweaking this is to create a DLC3 folder and a new pak01_dir.VPK file with any of the above changed/edited.

Avatar
FelixGriffin
2,680 Posts
Posted Jul 29, 2014
Replied 3 minutes later
Since the surfaceproperties file isn't in a VPK, you could pak a copy into your BSP with the volume levels for those entries lowered.
Avatar
ChickenMobile
2,460 Posts
Posted Jul 30, 2014
Replied 19 hours later

josepezdj wrote:
To me there are 2 possible shaders to use here, LightmappedGeneric and Refract to have water without the Water shader and therefore to be able to apply the material to brush entities. However the idea behind both is the same, you've already got 2 interesting animated textures (from the HL years) inside the pak01_dir.VPK:

Believe it or not I fiddled around with these textures and the refract shader for around 2 hours or so on Tuesday. 'Refract' seems to fade very close to the player proximity (of around 2 meters) and again, doesn't look very good. I can see how this could be useful for making custom distorted glass, but for large bodies of water - not so good.

Thanks for the examples Jose, I'll give it a whirl and see how it turns out.

EDIT: The vertical wall water looks lovely! But... it fades like the rest of the refract textures

water0001.jpg EDIT2: I would assume that the texture would act differently on a model seeing as kleiner's tubes have almost identical .vmt structure.
Avatar
josepezdj
2,386 Posts
Posted Jul 30, 2014
Replied 26 minutes later
Yup. However, I discovered when I made those capsules that the texture scale in the brush textured with the material is important for that fading out effect. If you can, try to adjust it so the water keeps being visible along the necessary "meters" in the room containing that pool. I can't really remember how that worked exactly though, I think that lower scale values (< 0.25) will make the material visible for more meters...

**EDIT**: Well, maybe for my capsule models I achieved it, and it's true that I avoided the fading out effect. I can check when I arrive home... If you need me, I can turn your water brushes into models

Avatar
ChickenMobile
2,460 Posts
Posted Jul 30, 2014
Replied 11 minutes later
Making a movable water model using the refract texture would be extremely useful... especially in places where you do not actually interact with it.

Might bring out the propper!

Advertisement
Registered users don't see ads! Register now!
Avatar
josepezdj
2,386 Posts
Posted Jul 30, 2014
Replied 4 minutes later
Yeah, off the top of my head I DO think that was one of the main reasons why I turned those capsule glasses into models.

If you can't propper it just post the VMF with your water brush and I'll propper it for you