Problem with Water-Shader

Greetings,

I got a problem with the post waterfilter.

bug

GPU is an ati/amd x1400 mobility with 256mb memory.

I’ve searched for the failing cast but couldn’t find it. Any suggestions?

Regards,

ceiphren

I think the problem is line 284 of the shader :

float biasFactor = 1.0/samples;

samples is an int. It should be cast to float

float biasFactor = 1.0/float(samples);

Could you try this?

@nehon: No, didn’t work. Still the same error.

Don’t you have the exact line where is fails? usually the shader code is outputed in the console with proper lines

@remy: I contacted the user to send the error report. Currently I’m waiting for an answer.

@nehon: The int to float conversion is just a warning, the actual error is the first line:

“Fragment Shader is not supported by HW”

Here’s an article about this error:

I think the water shader is just too complex to run on this video card. There are a lot of water shader features that could be disabled though (on the WaterFilter class). That might help get it closer to the point of running (although I doubt the performance would be good enough…)

I had that error on a 2008 iMac.

It sucks, but… maybe what you could do for old graphics cards only is a IF statement branch in java when your app is launching so that instead of loading the WaterFilter, it creates a semi transparent blue quad geometry, it’s very GPU efficient and still looks water-ish, OF COURSE not as good as the WaterFilter with the waves and the foam… but hey, at least old graphics card will be able to play your game. You could even make animated waves using a texture atlas! (I think I’ll actually implement this myself lol!)

Hi guys,

though it states that the X1400 supports GLSL 1.2 the user gets the same error. The log didn’t told more than already known. So I guess the shader is just to heavy for a low end card like this.

Erf…I’m sorry, I guess having a fallback as benjamin described is not really acceptable for your game.

Only thing you could do I guess is to try to reduce the number of instructions of the frag shader…

First you could ditch out the underwater part. I guess you don’t use it, and it’s a fair share of the code.
Then some parts are splitted in several lines for readability, they could be merged in one line. You won’t gain much doing this, just the extra assignation that an additional line adds, but…
Also most compilers inline this so I’m not sure it’s gonna help a lot.

Only sure thing is to remove parts you don’t use…

There are many parts of the shader that can be removed out by using various methods on WaterFilter like I mentioned before.

For example:

setUseFoam(false)
setUseCaustics(false)
setUseHQShoreline(false)
setUseRefraction(false)
setUseRipples(false)
setUseSpecular(false)

It will significantly reduce the shader instruction count which may allow it to run on that card (but still, at questionable performance …)

And of course there’s always the option of switching to SimpleWaterProcessor which should work anywhere.