Jump to content
The Dark Mod Forums

Messing with sea water


SteveL

Recommended Posts

I take it this is incorrect, then:

to the best of my knowledge, it is impossible to use 2 vfps in one shader. Thats the whole purpose of the undertaking. Believe me i've tried.


I wonder how long it'll be before someone tries adapting this for fog.

  • Like 1

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

Fantastic job you've done there Steve! That water looks really good, I wonder how this would look with the clear water texture on it

Link to comment
Share on other sites

I take it this is incorrect, then:

 

You can have only one shader program of each type in any one material stage / draw call, but materials can have multiple stages.

 

The original sea water 01 material had 3 draws: one to distort the background, and two layers of sea water.

 

The material I showed in the vid bumped that up to 4 draw calls for the water surface: The fixed version is back to 3, because the alpha layer is now drawn at the same time as the distortion. I merged the distortion shader program with the depth-testing one.

Link to comment
Share on other sites

Man that has got to be the fastest fix, for the smallest effort for the best visuals, to date...?

 

Heh I spent a good 90 minutes on that in total!

 

Because this is now a fix to the distortion shader that all waters use, we could in theory drop it into all existing water shaders like we did the fix for foreground distortion. You can set the depth at which the water looks completely opaque, either in the material file or with a shaderparm. For very clear water, you'd set it to something big like 1000000.

 

One potential fly in the ointment: I think people have achieved similar effects in the past with dark underwater fog lights, although that's buggy from a distance whereas this shouldn't be. But we can't just go changing all the default waters without checking what those look like first... it might be a bad combination in which case we'd have to content ourselves with some new murky shaders instead of upgrading old ones.

 

I have to go cook but I'll tidy up the new vertex program and material file and post them here later. There's no engine change for this, it's just a couple of extra files that mappers can play around with and package with their map if they wish.

Link to comment
Share on other sites

You can have only one shader program of each type in any one material stage / draw call, but materials can have multiple stages.

 

The original sea water 01 material had 3 draws: one to distort the background, and two layers of sea water.

 

The material I showed in the vid bumped that up to 4 draw calls for the water surface: The fixed version is back to 3, because the alpha layer is now drawn at the same time as the distortion. I merged the distortion shader program with the depth-testing one.

From the context of the thread I quoted, I think it was taking about multiple stages that use the program/vertexProgram/fragmentProgram keywords:

 

I wonder if you could just call each vfp in a separate stage in the same material definition?

to the best of my knowledge, it is impossible to use 2 vfps in one shader.

But anyway, evidently it is possible. Edit: maybe ungoliant's problem was with mixing postprocess effects...?

Edited by VanishedOne

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

I want to try a different way of implementing it, but I'll post the WIP for Biker and anyone wanting to experiment with it.

 

Material file

This is for your materials/ folder

semiopaque.mtr.txt

 

Shader program

This needs to go in a glprogs/ folder alongside your other top-level folders (maps/, materials/ etc).

heatHazeWithAlphaDepth.vfp.txt

 

__

 

How it works

The above shader draws a value 0.0 to 1.0 in the alpha channel of your screen. It says for each pixel, what % of the water shader to use and what % of the background colour to show. The two always add up to 100%. So if you set the opaque distance in the material file to 48 units (like it is in my example), and the distance between the water surface and the background for a given pixel is 16 units, then the alpha for that pixel will get set to 16 / 48 = 0.333, and you'll get 33% of the seawater shader and 66% of the background in the colour mix for that pixel. That's what "blend gl_dst_alpha, gl_one_minus_dst_alpha" means in the shader: multiply the colour from the current texture by the alpha that's already in the screen buffer (destination alpha) and the background colour by 1 minus the destination alpha.

 

Next thing I want to try

That method might be too restrictive.. It's reduced the contrast in the seawater texture quite a lot. It's made the blue surface water brighter and the highlights duller. I want to try something else, although I haven't really tried to fix it yet. We could make the second draw of the water texture independent of the alpha, for example. But the thing I want to try next is to get the shader to adjust the background colour directly instead of just setting up how it merges with the water surface texture. So we'd set an extra parameter in the material to indicate the opaque water colour. The shader would fade the background to that colour and not bother drawing anything into the alpha channel... you'd then just apply whatever water surface detail you want as a separate stage. It might be easier to adjust the water brightness that way. And it would be simpler too.

 

EDIT: Hmm we would lose the soft edge on the seawater that way. I guess we can leave both options open. Paint the alpha values, which the rest of the material can choose to use or ignore, and paint the water colour independently, again optional. I'll put together a few examples in another video so we can see what they look like.

  • Like 1
Link to comment
Share on other sites

Could you use the diffuse texture from the dark seawater..? (textures/water_source/sea_water_002) or just make a darker version of sea_water_001

 

What value in the material def do I edit toe change how far the player can see through the water..? I guess I change the current value of 48 in the following line -

 

- vertexParm 2 ( 1.0 / 48.0 ) // Set this to ( 1.0 / opaque_depth )

 

Also I'd like to try this new technique on a few other water textures -

 

- textures/water_source/water_green

- textures/water_source/water_blue

- textures/water_source/water_colored

- textures/water_source/water_dark

 

So with the depth set to 384, I took the following wip shots -

 

post-496-0-35241400-1461536617_thumb.jpg

post-496-0-09674900-1461536622_thumb.jpg

Link to comment
Share on other sites

What value in the material def do I edit toe change how far the player can see through the water..? I guess I change the current value of 48 in the following line -

 

- vertexParm 2 ( 1.0 / 48.0 ) // Set this to ( 1.0 / opaque_depth )

 

Also I'd like to try this new technique on a few other water textures -

 

- textures/water_source/water_green

- textures/water_source/water_blue

- textures/water_source/water_colored

- textures/water_source/water_dark

 

So with the depth set to 384, I took the following wip shots -

 

Cool, they're looking good already even before we experiment with method #2 and other shaders. Yes as you discovered that's how to change the murkiness. I'll change it in the next version so you just put the depth in instead of ( 1.0 / depth ) which is unnecessarily confusing.

 

I plan to put a more waters in a test map and try tweaking it for each. The ones you called out look like a good selection to start with.

  • Like 1
Link to comment
Share on other sites

Grand, the only issue with sea_water_001, its appears to glow so as a result the small boat looks like its floating in place rather than on the water.

 

The best fix I've found so far is to use my original material above but reduce the rgb of the two water layers to 0.1 and 0.05.

 

I've made a new test map with lots of water channels and I've started to play around with it. I've also made a shader program that can fade out the water to a set colour independent of the surface overlays. It's not added as much flexibility as I thought, for the sea water anyway... the original looked better. I'm still on sea water but most of our waters work quite differently. Sea water uses a filtering blend, so it always darkens the background. We might find other waters work better with the colour-fade shader. Still messing with the options, but in the meantime see what you think of the reduced-rgb version of the material I posted above.

  • Like 2
Link to comment
Share on other sites

It doesn't handle lights as such, so lights in the water would be treated the same as any light. Lights light surfaces, and surfaces behind the water have their resulting colour filtered by the shader according to how much water there is in the way. There'd be no glow in the water itself, just light from whatever surfaces get lit.

Link to comment
Share on other sites

I haven't posted an update, I meant you can change the rgb numbers in that shader for the last two stages. Instead of rgb 0.2 and rgb 0.15 like I put in my posted material, it looks better and darker using rgb 0.1 and rgb 0.05.

Link to comment
Share on other sites

  • 1 year later...
  • 2 months later...

I tested this and discovered there is a significant problem...splash particles are not visible using this water surface. While you can see the splash over top of the object making them, none of the splash displays over top of the water surface itself.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 0 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...