Need properly working GLSL water Topic is solved

Problems building or running the engine, queries about how to use features etc.
slapin
Bronze Sponsor
Bronze Sponsor
Posts: 146
Joined: Fri May 23, 2025 5:04 pm
x 5

Need properly working GLSL water

Post by slapin »

Hi, all!

Lately I was trying to make any Ogre water run with varying degree of failure (from basic graphics problems with normal water in Samples to total and complete failure with OgreWater.

I did some of my custom water which is much closer to success than others but I'm quite poor shader alchemist to
make it work completely (uses just colors and waves with basic set of sines, and basic fragment shasder w/o fresnel or render targets).

However I want Fresnel and render targets to work. I tried compositor approach but got unsolvable problems (mainly related to noise and texture edges) with bad graphics effects so I decided just alpha-blend everything and it works like a charm without any render targets and compositors.
For above style water where below stuff is barely visible it is fine for me. I could not make depth work too, but I mitigated that using model-space distance to camera.

I guess that is bad practice but it worked fine on slowest of my targets so it should still be fine. I guess my sanity is much more important than realism (my goal is stylized water anyway).

But now I need underwater camera view, which is another thing and requires fullscreen fresnel effect, and I can't make it work, like at all. I guess I need to set up plane before camera which will display viewport texture using some UV sine effect, but for some reason I see repeating edge patterns whatever texture mode I set, clamped or not.
So I'd like to see something working with GLSL. I believe OgreWater looks superb on DX11/12 but that is not my case. I'm fine with hacky and/or non-realistic approach, I just need something I can work off. I'll ditch caustics too, as I won't be able to do it anyway.

Please help!
Also need to mention that at any stage the number of texture samples have to be not more than 4 due to lowest target limits.

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 146
Joined: Fri May 23, 2025 5:04 pm
x 5

Re: Need properly working GLSL water

Post by slapin »

The reflection problems

Image

This one is ok:

Image

But only when camera is below.

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 146
Joined: Fri May 23, 2025 5:04 pm
x 5

Re: Need properly working GLSL water

Post by slapin »

I was unable to make render targets work directly so I use compositor

Code: Select all

compositor Fresnel
{
    technique
    {
        texture reflection 512 512 PF_BYTE_RGB
        texture refraction 512 512 PF_BYTE_RGB

    target reflection
    {
        visibility_mask 0x00F // SURFACE objects
        input previous
    }
    target refraction
    {
        visibility_mask 0x0F0 // SUBMERGED objects
        input previous
    }
    target_output
    {
        input previous
    }
}
}

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 146
Joined: Fri May 23, 2025 5:04 pm
x 5

Re: Need properly working GLSL water

Post by slapin »

And refraction from the sample works perfectly.

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 146
Joined: Fri May 23, 2025 5:04 pm
x 5

Re: Need properly working GLSL water

Post by slapin »

Figured out render targets. Removed compositor, just using render targets, now works fine.
Will have to find out how to do underwater effects, but for now it works.

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 146
Joined: Fri May 23, 2025 5:04 pm
x 5

Re: Need properly working GLSL water

Post by slapin »

Found a way to put refraction, reflection, refraction depth, reflection depth on the same texture. This way I'm one step closer to GL ES 2.0 water...