Archive 17/01/2023.

Editing the default water material

davidpox

Hi! I’m currently using the water sample (23) and I was wondering how I would go about changing the alpha of the water. I want water that is pretty grimy and not so transparent. Changing the MatDiffColor doesn’t have any effects on the material.

Any help is appreciated =)

Lumak

Two changes:

  1. in CoreData\Techniques\Water.xml, add
    <pass name="refract" blend="alpha" />
  1. in your shader:
    glsl: change
    gl_FragColor = vec4(GetFog(finalColor, GetFogFactor(vEyeVec.w)), 1.0);

to

    gl_FragColor = vec4(GetFog(finalColor, GetFogFactor(vEyeVec.w)), yourMatAlpha);

similar for hlsl.

davidpox

Hmmm I just tried that but that only seems to change the… intensity of the colour.


First is Alpha to 0.5f
Second is to 1.0f

Doesn’t seem to change the opacity of the water itself

1vanK

in material “Materials\Water.xml”

    <parameter name="FresnelPower" value="100" />
    <parameter name="WaterTint" value="1.0 1.0 1.0" />

absolute transparent water

I was wondering how I would go about changing the alpha of the water

In this example water absolutely nontransparent. All that you see is just special texture on the plane.

Lumak

Here’s my test:

It’s hard to tell when the alpha=0.5, unless you have a unique texture on a model that’s partially submerged in the water.

edit: Iet me take that back. Unless you’re applying a diffTexture to the water, which is not the case for ex. 23, it’ll be difficult to see the transparency effect.

davidpox

So how would I go about recreating more realistic looking water? For example here:

This water is greenish, and you can’t see to the bottom of the lake.

Lumak

If just the opacity settings, you don’t need alpha blend, so keep the coredata\techniques\water.xml the same and try the material below:

<material>
    <!-- The water example will assign the reflection texture to the diffuse unit -->
    <!-- The engine will automatically assign the refraction (viewport) texture to the environment unit during refract pass -->
    <technique name="Techniques/Water.xml" />
    <texture unit="normal" name="Textures/WaterNoise.dds" />
    <parameter name="NoiseSpeed" value="0.005 0.005" />
    <parameter name="NoiseTiling" value="80" />
    <parameter name="NoiseStrength" value="0.1" />
    <parameter name="FresnelPower" value="4" />
    <parameter name="WaterTint" value="0.3 0.4 0.3" />
</material>