Water material stopped working in 4.0.3

Hello!

I’ve been using Water Material for a while, yet after updating to Babylon 4.0.3 it has stopped working, throwing BABYLON.WaterMaterial is not a constructor error.

I HAVE updated the water material too.

Any thoughts?

An explanation how the project is set up.

MaterialLibrary scripts are loaded as needed (there are many modules where they aren’t):

this.water = document.createElement('script');
                    this.water.onload = function () {
                        Utils.createWater(settings.scene.water, scene, skybox);
                    };
                    document.head.appendChild(this.water);
                    this.water.src = "libs/babylon/shaders/babylon.waterMaterial.js";

This worked fine in Babylon v 3.2.0.

Ping @julien-moreau but it seems to be ok in the playground though ???

https://www.babylonjs-playground.com/#1SLLOJ#20

Yep. Works in the playground.
I’ve even tried to use waterMaterial.js from 3.2.0 with Babylon 4.0.3. It doesn’t throw the error but doesn’t work either.

So it is definitely smthg on the client code ? are you using same version for water and core ???

Yep. Same versions. As I mentioned before, it used to work with Babylon 3.2.0.

Hey @max123, have you solved the problem? :slight_smile:

Hi @julien-moreau, this was solved here: [SOLVED] Requirejs + babylon4 = trouble
Thanks for asking :slight_smile:

1 Like

Hi, I am having this problem too! And I see right now than it does not works in PG too.

This definitely works for me https://www.babylonjs-playground.com/#1SLLOJ#20 could you please share which PG does not work ?

Hey @sebavan
Excuse is my fault!
I did an upgrade in my MacPro to High Sierra MacOS and it stops working in Safari browser. But it opens in Chrome on my Android so the trouble is in Safari on High Sierra.

Ohhhhh, @julien-moreau could you take a look ? else I ll see if I can repro.

@sebavan and @julien-moreau

My Safari is Version 12.1.2 (13607.3.10)
but I am using NVIDIA Web Driver because I put an nVidia GTX960 in may MacPro and it needs this
driver to work with it.

There are this error messages in javascript console

Babylon.js v4.1.0-alpha.17 - WebGL1
[Error] WebGL: ERROR: 0:2841: ‘IMAGEPROCESSING’ : unexpected token after conditional expression
compileShader
_compileRawShader (babylon.js:16:133552)
createShaderProgram (babylon.js:16:134052)
_preparePipelineContext (babylon.js:16:135766)
_prepareEffect (babylon.js:16:82338)
_useFinalCode (babylon.js:16:78405)
(anonymous function) (babylon.js:16:77841)
(anonymous function) (babylon.js:16:69618)
_ProcessIncludes (babylon.js:16:73814)
Process (babylon.js:16:69562)
(anonymous function) (babylon.js:16:77809)
(anonymous function) (babylon.js:16:69618)
_ProcessIncludes (babylon.js:16:73814)
Process (babylon.js:16:69562)
(anonymous function) (babylon.js:16:77767)
_loadFragmentShader (babylon.js:16:80542)
(anonymous function) (babylon.js:16:77743)
_loadVertexShader (babylon.js:16:80111)
e (babylon.js:16:77707)
createEffect (babylon.js:16:133054)
isReadyForSubMesh (babylonjs.materials.min.js:16:16006)
render (babylon.js:16:35306)
render (babylon.js:16:581305)
renderUnsorted (babylon.js:16:2466254)
render (babylon.js:16:2464698)
render (babylon.js:16:712751)
_renderForCamera (babylon.js:16:319781)
_processSubCameras (babylon.js:16:320354)
render (babylon.js:16:325300)
(anonymous function) (main.js:135)
(anonymous function)
_renderLoop (babylon.js:16:115461)
(anonymous function)
[Error] BJS - [15:02:02]: Unable to compile effect:
_ErrorEnabled (babylon.js:16:208054)
_processCompilationErrors (babylon.js:16:83467)
_prepareEffect (babylon.js:16:83298)
_useFinalCode (babylon.js:16:78405)
(anonymous function) (babylon.js:16:77841)
(anonymous function) (babylon.js:16:69618)
_ProcessIncludes (babylon.js:16:73814)
Process (babylon.js:16:69562)
(anonymous function) (babylon.js:16:77809)
(anonymous function) (babylon.js:16:69618)
_ProcessIncludes (babylon.js:16:73814)
Process (babylon.js:16:69562)
(anonymous function) (babylon.js:16:77767)
_loadFragmentShader (babylon.js:16:80542)
(anonymous function) (babylon.js:16:77743)
_loadVertexShader (babylon.js:16:80111)
e (babylon.js:16:77707)
createEffect (babylon.js:16:133054)
isReadyForSubMesh (babylonjs.materials.min.js:16:16006)
render (babylon.js:16:35306)
render (babylon.js:16:581305)
renderUnsorted (babylon.js:16:2466254)
render (babylon.js:16:2464698)
render (babylon.js:16:712751)
_renderForCamera (babylon.js:16:319781)
_processSubCameras (babylon.js:16:320354)
render (babylon.js:16:325300)
(anonymous function) (main.js:135)
(anonymous function)
_renderLoop (babylon.js:16:115461)
(anonymous function)
[Error] BJS - [15:02:02]: Uniforms: world, view, viewProjection, vEyePosition, vLightsType, vDiffuseColor, vSpecularColor, vFogInfos, vFogColor, pointSize, vNormalInfos, mBones, vClipPlane, vClipPlane2, vClipPlane3, vClipPlane4, normalMatrix, logarithmicDepthConstant, worldReflectionViewProjection, windDirection, waveLength, time, windForce, cameraPosition, bumpHeight, waveHeight, waterColor, waterColor2, colorBlendFactor, colorBlendFactor2, waveSpeed, vLightData0, vLightDiffuse0, vLightSpecular0, vLightDirection0, vLightFalloff0, vLightGround0, lightMatrix0, shadowsInfo0, depthValues0, normalSampler, refractionSampler, reflectionSampler, shadowSampler0, depthSampler0
_ErrorEnabled (babylon.js:16:208054)
_processCompilationErrors (babylon.js:16:83506)
_prepareEffect (babylon.js:16:83298)
_useFinalCode (babylon.js:16:78405)
(anonymous function) (babylon.js:16:77841)
(anonymous function) (babylon.js:16:69618)
_ProcessIncludes (babylon.js:16:73814)
Process (babylon.js:16:69562)
(anonymous function) (babylon.js:16:77809)
(anonymous function) (babylon.js:16:69618)
_ProcessIncludes (babylon.js:16:73814)
Process (babylon.js:16:69562)
(anonymous function) (babylon.js:16:77767)
_loadFragmentShader (babylon.js:16:80542)
(anonymous function) (babylon.js:16:77743)
_loadVertexShader (babylon.js:16:80111)
e (babylon.js:16:77707)
createEffect (babylon.js:16:133054)
isReadyForSubMesh (babylonjs.materials.min.js:16:16006)
render (babylon.js:16:35306)
render (babylon.js:16:581305)
renderUnsorted (babylon.js:16:2466254)
render (babylon.js:16:2464698)
render (babylon.js:16:712751)
_renderForCamera (babylon.js:16:319781)
_processSubCameras (babylon.js:16:320354)
render (babylon.js:16:325300)
(anonymous function) (main.js:135)
(anonymous function)
_renderLoop (babylon.js:16:115461)
(anonymous function)
[Error] BJS - [15:02:02]: Attributes: position, normal, uv
_ErrorEnabled (babylon.js:16:208054)
_processCompilationErrors (babylon.js:16:83580)
_prepareEffect (babylon.js:16:83298)
_useFinalCode (babylon.js:16:78405)
(anonymous function) (babylon.js:16:77841)
(anonymous function) (babylon.js:16:69618)
_ProcessIncludes (babylon.js:16:73814)
Process (babylon.js:16:69562)
(anonymous function) (babylon.js:16:77809)
(anonymous function) (babylon.js:16:69618)
_ProcessIncludes (babylon.js:16:73814)
Process (babylon.js:16:69562)
(anonymous function) (babylon.js:16:77767)
_loadFragmentShader (babylon.js:16:80542)
(anonymous function) (babylon.js:16:77743)
_loadVertexShader (babylon.js:16:80111)
e (babylon.js:16:77707)
createEffect (babylon.js:16:133054)
isReadyForSubMesh (babylonjs.materials.min.js:16:16006)
render (babylon.js:16:35306)
render (babylon.js:16:581305)
renderUnsorted (babylon.js:16:2466254)
render (babylon.js:16:2464698)
render (babylon.js:16:712751)
_renderForCamera (babylon.js:16:319781)
_processSubCameras (babylon.js:16:320354)
render (babylon.js:16:325300)
(anonymous function) (main.js:135)
(anonymous function)
_renderLoop (babylon.js:16:115461)
(anonymous function)
[Error] BJS - [15:02:02]: Defines:
#define BUMP
#define REFLECTION
#define NORMAL
#define UV1
#define NUM_BONE_INFLUENCERS 0
#define BonesPerMesh 0
#define SPECULARTERM
#define VIGNETTEBLENDMODEMULTIPLY
#define SAMPLER3DGREENDEPTH
#define SAMPLER3DBGRMAP
#define LIGHT0
#define HEMILIGHT0

_ErrorEnabled (babylon.js:16:208054)
_processCompilationErrors (babylon.js:16:83638)
_prepareEffect (babylon.js:16:83298)
_useFinalCode (babylon.js:16:78405)
(anonymous function) (babylon.js:16:77841)
(anonymous function) (babylon.js:16:69618)
_ProcessIncludes (babylon.js:16:73814)
Process (babylon.js:16:69562)
(anonymous function) (babylon.js:16:77809)
(anonymous function) (babylon.js:16:69618)
_ProcessIncludes (babylon.js:16:73814)
Process (babylon.js:16:69562)
(anonymous function) (babylon.js:16:77767)
_loadFragmentShader (babylon.js:16:80542)
(anonymous function) (babylon.js:16:77743)
_loadVertexShader (babylon.js:16:80111)
e (babylon.js:16:77707)
createEffect (babylon.js:16:133054)
isReadyForSubMesh (babylonjs.materials.min.js:16:16006)
render (babylon.js:16:35306)
render (babylon.js:16:581305)
renderUnsorted (babylon.js:16:2466254)
render (babylon.js:16:2464698)
render (babylon.js:16:712751)
_renderForCamera (babylon.js:16:319781)
_processSubCameras (babylon.js:16:320354)
render (babylon.js:16:325300)
(anonymous function) (main.js:135)
(anonymous function)
_renderLoop (babylon.js:16:115461)
(anonymous function)

[Error] BJS - [15:02:02]: Error: FRAGMENT SHADER ERROR: 0:2841: ‘IMAGEPROCESSING’ : unexpected token after conditional expression

_ErrorEnabled (babylon.js:16:208054)
_processCompilationErrors (babylon.js:16:83677)
_prepareEffect (babylon.js:16:83298)
_useFinalCode (babylon.js:16:78405)
(anonymous function) (babylon.js:16:77841)
(anonymous function) (babylon.js:16:69618)
_ProcessIncludes (babylon.js:16:73814)
Process (babylon.js:16:69562)
(anonymous function) (babylon.js:16:77809)
(anonymous function) (babylon.js:16:69618)
_ProcessIncludes (babylon.js:16:73814)
Process (babylon.js:16:69562)
(anonymous function) (babylon.js:16:77767)
_loadFragmentShader (babylon.js:16:80542)
(anonymous function) (babylon.js:16:77743)
_loadVertexShader (babylon.js:16:80111)
e (babylon.js:16:77707)
createEffect (babylon.js:16:133054)
isReadyForSubMesh (babylonjs.materials.min.js:16:16006)
render (babylon.js:16:35306)
render (babylon.js:16:581305)
renderUnsorted (babylon.js:16:2466254)
render (babylon.js:16:2464698)
render (babylon.js:16:712751)
_renderForCamera (babylon.js:16:319781)
_processSubCameras (babylon.js:16:320354)
render (babylon.js:16:325300)
(anonymous function) (main.js:135)
(anonymous function)
_renderLoop (babylon.js:16:115461)
(anonymous function)

[Error] Failed to load resource: the server responded with a status of 404 () (split.min.js.map, line 0)
[Error] Failed to load resource: the server responded with a status of 404 () (jquery.min.map, line 0)

That is good news cause it will be easy to repro then !!! @julien-moreau I am looking into it now, do not bother so far :slight_smile:

Ok found the issue (WebGL1 only i ll deploy it in 15 minutes) thanks for reporting.

@sebavan

I look at this water sample in my MacBookPro, which is running with standard drivers, and the error occur too.

Thank you for finding it!

It is all good now !!! you can check the playground again.

It seems to me that Julien is in the process of completely rewriting the material of water because he was old and to other problems with reflection.

yup but in the mean time, the bug is fixed to prevent back compat issues :slight_smile:

Yes of course. The time that the new is there.

1 Like