Realistic water in Quake 3

Discussion for Level editing, modeling, programming, or any of the other technical aspects of Quake
Post Reply
Infernis
Posts: 613
Joined: Thu Feb 17, 2005 12:00 pm

Realistic water in Quake 3

Post by Infernis »

If my memory is correct then I know for sure that I've seen it somewhere. Either in a thread here or over at SD, in a map or in a Q3map2 guide.

What am I talking about? Realistic water. As in see through water that reflects on the surrounding walls. Below is a screen from FEAR to illustrate my point. Please tell me if I'm growing senile or not. If not, I would appreciate a push in the right direction as to where to find the neccesary info/files/map/etc.

Thanks in advance!

Image
Inf - Leaving in it's torturous wake nothing but vicious, cannabalistic, mutated, radiated and horribly disfigured hordes of satanic killers!
Silicone_Milk
Posts: 2237
Joined: Sat Mar 12, 2005 10:49 pm

Re: Realistic water in Quake 3

Post by Silicone_Milk »

I thought you were saying that shot was quake 3 for a second. My jaw dropped.

Then I realized it wasn't and I was disappointed.
a13n
Posts: 1672
Joined: Thu Feb 10, 2005 2:08 am

Re: Realistic water in Quake 3

Post by a13n »

@Infernis
You only mean indoor-projection to wall by realistic?
sumatra
Posts: 325
Joined: Sat Feb 12, 2005 10:02 pm

Re: Realistic water in Quake 3

Post by sumatra »

IIRC there is a standard id walltexture that looks like reflecting water.
So if I understand you right, you don't search for a water texture, instead you search for a shader for the surrounding walls. Correct me if I'm wrong....
Someone should know the texture/shader, I'm busy now, help you later..
[url=http://www.pukkadesign.com][color=#41c0eb]..::pukkadesign.com[/color][/url]
Shallow
Posts: 167
Joined: Wed Feb 09, 2005 1:58 pm

Re: Realistic water in Quake 3

Post by Shallow »

This is something I meant to try ages ago but never got around to it. I think the way to go with this would be a set of decal patches, or better yet a carefully UVed model, that covers the walls and uses alpha-mod brushes to blend a scrolling or animated transparent texture to nothing.

(Ideally I'd want to use an additive blend to look more like reflected light, but unfortnately you can't modulate the RGB by the vertex alpha in Q3 so that's a no-go)

As sumatra says there is a standard shader that fakes caustic reflection effects, the texture from that would be a reasonable starting point for making the alpha channel you'll need.

Edit: It would be this sort of setup.

Image

You can us the middle row of control points on the patch to control the distance that the blend covers, or you could place more alphamod brushes. If you're using patches you will probably need to move those verts to stop it getting optimised down to just a single quad.

Rough shader (needs refinement)

Code: Select all

textures/yourmap/spanglycausticsthing
{
    surfaceparm trans
    surfaceparm nolightmap

    {
        map texture/blah/whatever.tga
        rgbgen identity
        alphagen vertex
        blendfunc blend
        tcmod scroll .01 .01
    }
}
You may want to play with the rgbgen - rgbgen identitylighting might look better.

The alpha channel on the texture probably wants to be fairly subdued. The RGB channel should be a fairly plain colour overall - let the alpha do all the work. Make it mostly black, with dark grey to mid grey for the bits you want bright.

Make sure you just use an alpha blend (blendfunc blend) in the decal's shader, don't add an alphafunc or it will look like shit :)

The tcmod line probably needs fiddling with. Adding a tcmod turb as well would probably be good idea.
Infernis
Posts: 613
Joined: Thu Feb 17, 2005 12:00 pm

Re: Realistic water in Quake 3

Post by Infernis »

Good to see your still breathing Shallow :D

It's always nice to get some support from you man, thanks!

Sum, your right, I found it and it's called "clear_calm1". Thanks for that suggestion. dONKEY said there was a map that used it called "Last Minutes Of Pompeii" by aVe. You can find it on lvl by clicking here.

I did a little test based on Shallow his suggestion. I posted a screenshot below to illustrate the result. I only made a patch covering the wall and I applied the water shader to it. The problem ofcourse is that there is no blending going on and you can clearly see I used a patch, due to the moving effect of the water. I'll experiment a bit more next week.

Image
Inf - Leaving in it's torturous wake nothing but vicious, cannabalistic, mutated, radiated and horribly disfigured hordes of satanic killers!
obsidian
Posts: 10970
Joined: Mon Feb 04, 2002 8:00 am

Re: Realistic water in Quake 3

Post by obsidian »

Texture projection might work better in certain situations, particularly if you mean to project the texture onto a non-planar surface. It also takes projection distance into consideration, so IIRC, you don't need the alphaMod volume brushes, also meaning that you can probably modulate the RGB values.

Create a patch, texture it with a decal shader, convert it into a _decal entity, target a target_position or info_null.

Only issue is that you will get projected texture streaking on surfaces perpendicular to the projection angle.
Infernis
Posts: 613
Joined: Thu Feb 17, 2005 12:00 pm

Re: Realistic water in Quake 3

Post by Infernis »

Texture projection does not seem to work better in this situation. In fact, it doesn't seem to work at all. I've followed the precise instructions about setting this up as posted by Rgoer in this thread over at SD. I see no difference when using this method in comparison to applying a patch with the shader on it. Ingame it looks exactly the same and I tried different compile options.

As for Shallow his suggestion. I built the scene precisely as you illustrated but the alphafade brushes don't seem to have a real effect. I'm using the shader from the map I mentioned earlier. This is the shader:
// Caustics
// Shader structure d'après ch4ndl3r

textures/caustics/water_caustics
{

qer_editorimage textures/liquids/pool3d_3e.tga
qer_trans 0.75

q3map_noTJunc
q3map_nonplanar
q3map_shadeAngle 179
// rendu plus efficace

surfaceparm nonsolid
surfaceparm nomarks
surfaceparm trans

// Ces deux directives sont obligatoires
surfaceparm nolightmap
polygonOffset


// optionnel
sort 6
// Place le decal légèrement
// en avant par rapport à la surface du brush

//cull disable
//deformVertexes wave 64 sin .25 .25 0 .5

{
map textures/liquids/pool3d_5e.tga
blendFunc GL_dst_color GL_one
tcmod scale .5 .5
tcmod scroll .025 .01
rgbGen identity
}
{
map textures/liquids/pool3d_3e.tga
blendFunc GL_dst_color GL_one
tcmod scale -.5 -.5
tcmod scroll .025 .025
}
}
Below you'll find a screenshot of the ingame result which appears to remain the same whatever I do. The point is that I want it to blend more with the underlying texture to give it a more natural effect. Now it still is clearly visible that a patch is applied by the difference in color. Or perhaps the shader is simply too bright. I've looked up all the used shader commands in the manual but I'm clueless as to how to effectively change this.

Image
Inf - Leaving in it's torturous wake nothing but vicious, cannabalistic, mutated, radiated and horribly disfigured hordes of satanic killers!
sumatra
Posts: 325
Joined: Sat Feb 12, 2005 10:02 pm

Re: Realistic water in Quake 3

Post by sumatra »

The problem is that those two pool textures are not dark enough.
Copy them to a new folder called caustics (for example) and change the paths in the shader file.
Then adjust the two copied textures with the gradiation curves in PS.
I can send you mine if you don't get it working..

Then you still need the alphablending to get a nice gradient to transparent to the top of the room. :cool:

Questions? Ask!
[url=http://www.pukkadesign.com][color=#41c0eb]..::pukkadesign.com[/color][/url]
Infernis
Posts: 613
Joined: Thu Feb 17, 2005 12:00 pm

Re: Realistic water in Quake 3

Post by Infernis »

You lost me with the graduation curves in PS. The PS help only displays "Noise filters" as a search result and Google isn't helping either. Please explain :?:
Inf - Leaving in it's torturous wake nothing but vicious, cannabalistic, mutated, radiated and horribly disfigured hordes of satanic killers!
obsidian
Posts: 10970
Joined: Mon Feb 04, 2002 8:00 am

Re: Realistic water in Quake 3

Post by obsidian »

You will need alphaGen vertex in both stages in order for alphaMod to work.

alphaMod uses vertex alpha to blend the textures, so you need to enable it for each stage.

And I think he meant levels curves instead of graduation.
sumatra
Posts: 325
Joined: Sat Feb 12, 2005 10:02 pm

Re: Realistic water in Quake 3

Post by sumatra »

yeah, level curves, gradiation is german 8) ..
[url=http://www.pukkadesign.com][color=#41c0eb]..::pukkadesign.com[/color][/url]
Shallow
Posts: 167
Joined: Wed Feb 09, 2005 1:58 pm

Re: Realistic water in Quake 3

Post by Shallow »

Though I'd do a quick test. It involved slightly more faffing than anticipated and became a longish test.

Provided you set up your new textures exactly like I said and don't use the default textures from the game it should work, to an extent. You'll also need to use a patch with two more rows than I showed to get a decent blend, with a 25% or 50% alphamod brush over the middle row of verts, and the 0% brush over the top verts.

I also had to tone down the alpha even more than I expected - I had thought I'd be using the lower 50% of the available tonal range, I went down to the lower 30% before it looked about right. By contrast, remember that the RGB needs to be nice and bright. I just used flat white.

I also discovered that I hadn't edited Q3 on this machine since my last reinstall, so my 1.4.0 project file was pointed to an ancient Q3map2 that had no idea what alphamod volumes were.

It looks OK from a distance but crappy close up. Somewhere in the renderer, it looks like some kind of clip is applied to alpha values that mean that once the alpha drops below a certain point, it gets treated as if it was zero. So a pixel that should have something like 10% alpha or less, gets treated as zero. It might be due to a lack of precision because there's only 8 bits a channel (or is it 7 with overbrights?), it might be something that was put in to fix problems on specific video cards, it might be drivers. Whatever it is, it means that you cannot get a smooth blend to zero. There will always be an identifiable edge, just as if you'd used an alphafunc. It means you can't get a nice fluffy fadeout at the top like you'd want.

Momentarily I suspected that perhaps the alpha channel on my caustics texture wasn't good enough, so to be sure I tested this with a straight 0-1 gradient fill in the alpha channel, and it's definitely the case that somewhere it gets screwed.

I'm probably being overly picky. If you were actually playing the map you'd never notice the edge issue.

Using rgbgen vertex in the shader looks alright too btw. It looks too bright in shadowy corners with rgbgen identity.

This is the shader I ended up with:

Code: Select all

textures/caustics/caustics
{
    surfaceparm trans
    surfaceparm nolightmap
    polygonoffset
 
    {
        map textures/caustics/caustics.tga
        rgbgen vertex
        alphagen vertex
        blendfunc blend
        tcmod scroll .1 .1
    }
    {
        map textures/caustics/caustics.tga // too lazy to make more than one texture!
        rgbgen vertex
        alphagen vertex
        blendfunc blend
        tcmod scale .66 .66
        tcmod scroll -.2 .05
    }
}
I suppose it might be possible to get around the alpha values being clipped by expliticitly using specific blendfuncs rather than the generic blend, but my shaders are too rusty to want to attempt that :)

It's a shame there's no such thing as 'alphamod', so you could layer a subtle pulsing waveform on top of the vertex alpha. You can't use an alphagen wave of course, because it cancels out the other alphagen.
Infernis
Posts: 613
Joined: Thu Feb 17, 2005 12:00 pm

Re: Realistic water in Quake 3

Post by Infernis »

Thanks for the heads up. I got it to work this weekend. Not entirely according towards your suggestion, but the result is satisfying none the less. I didn't post a reply yet, because I'm working on a test scene, to really illustrate the achieved effect. I will post it as soon as it's done.
Inf - Leaving in it's torturous wake nothing but vicious, cannabalistic, mutated, radiated and horribly disfigured hordes of satanic killers!
Post Reply