Water Transparency

Ask questions, discuss ideas, get answers
Post Reply
User avatar
Swaffy
Posts: 1715
Joined: Sun Aug 29, 2010 9:25 pm
Location: Cibolo, Texas

Water Transparency

Post by Swaffy »

Another noob question.

I have shallow water on two of my maps.

- My objects that are partially in the water simply disappear at the parts going under the water line.
- I want to be able to see the ground below the water.

How can I edit the water [or water settings] for it to have transparency?

Two example images. Hint: look at the giant bass fish.

Image

Image

Example code from my map's "init.con" file:

Code: Select all

water.specularEnable 1
water.texLayer1 texture/water05
water.texLayer2 texture/water06
water.normalMap texture/normalMap01

rem water.scrollDirectionNormalmap 1/0
rem water.scrollDirection1 1/-0.5
rem water.scrollDirection2 1/0.5
water.scrollDirectionNormalmap 1/0
water.scrollDirection1 1/-0.5
water.scrollDirection2 1/0.5

water.specularColor 0.65/0.55/0.4
water.scrollLayer1 0.02
water.scrollLayer2 0.02
water.scrollNormalmap 0.02
water.specularStreakFactor 0.001
water.tileLayer1 0.5
water.tileLayer2 0.5
water.tileNormalmap 1
water.lightDirection -0.3/0.5/-0.65
water.color 1/1/1
water.deepColor 1/1/1
water.waterAlphaDepth 0
water.waterShallowAlpha 0.5
(Forum Thread|Download) Swaffy'sMod v0.34 | Download link to come Soon™
User avatar
Senshi
Posts: 697
Joined: Sun Oct 18, 2009 1:14 pm
Location: Germany
Contact:

Re: Water Transparency

Post by Senshi »

water.waterAlphaDepth 0
water.waterShallowAlpha 0.5

That's the values.

AlphaDepth defines the depth to which you want the water to be transparent. So with a value of 10 you can see 10BF meters below the water surface.
The ShallowAlpha is a value between 0 and 1 and defines how transparent the water should be, 0 being fully transparent (IIRC).

I suggest starting with some low values, the effect is VERY extreme!
water.waterAlphaDepth 3
water.waterShallowAlpha 0.2

Those are the settings I used for my Guadalcanal Desert conversion, and the whole beach - offshore shallows become a wonderful medley of reefs and sand banks.
Check the old thread about it, I have some screenshots there:
http://battlefieldmodding.com/ssm/phpBB ... f=7&t=5060

Another tip: To test/figure out the best values, you can avoid having to save&restart (trial&error approach) by launching your map in the debugger bf1942_r.exe, then you can just go to that location and use the console to change the values to whatever values you want (just type the exact same commands as above in the console), the changes are applied instantly. This goes for all environmental settings like lighting etc. as well. In the editor I usually only set up a rough and crude lighting, the fine-tuning is done in the debugger. Of course you have to note down your "perfect" values and afterwards apply them all at once in the proper .con files.

Check here:
http://bfmods.com/viewtopic.php?f=9&t=996&p=6994#p6983
for a fairly elaborate explanation (including animated GIF!) of most available lighting settings. About 90% of the maps that exist for BF42 only use the basic BC42 presets and generic values instead of putting a bit of effort into this, despite the fact that a good lighting setup has tremendous effect on immersion.
User avatar
Swaffy
Posts: 1715
Joined: Sun Aug 29, 2010 9:25 pm
Location: Cibolo, Texas

Re: Water Transparency

Post by Swaffy »

Wow, thanks for all the help. It is much appreciated. I was planning on getting to the lightmaps later on, but I guess I can spend some time playing with them right now. The "palette.pal" part seems a bit confusing but I can figure it out.

[Edit] Okay. The water has transparency, but the static objects still disappear at the parts touching the water. Is this unfixable, built into the game?
(Forum Thread|Download) Swaffy'sMod v0.34 | Download link to come Soon™
User avatar
Apache Thunder
Posts: 1213
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Water Transparency

Post by Apache Thunder »

It's not really an issue with the water, but with how the statics involved are set up. 99% of all statics will appear correctly below water. However if the objects in question, like your fish, use partial transparency in their textures and have it enabled in the rs file (looks like the fins of your fish is where the alpha blending is occurring), then they or their mesh parts with the affected materials will no longer be visible below the water line. Since your fish likely use just one material using one texture, the entire mesh is invisible below the water line.

To fix this I would recommend using alphatestref property instead of using partial transparency (which is enabled via the "transparent true" setting in the RS file so remove that line or set it to false). AlphaTestRef will for the most part allow the fins to have transparency without any blending and thus the issues with water will not be a problem anymore.

So see if you can get the mesh to appear correctly by adding "alphatestref 0.45" command to your RS file(s) of the affected statics thereby replacing the transparent setting. (remove the transparent command or set it to false)

You don't have to fiddle with the water alpha settings since it won't help. The game can't blend alpha with both water and objects with alpha enabled in their textures. Thus you get that issue with them not showing underwater.

If you can't get it to show properly, PM me the texture and SM/RS files and I'll take a look at them and see if I can get them working for you.
ImageImageImage
I have cameras in your head!
Post Reply