Browse Source

fix ocean shader for WebGL2

aardgoose 6 years ago
parent
commit
d2c7ae35a4
2 changed files with 4 additions and 0 deletions
  1. 2 0
      examples/js/shaders/OceanShaders.js
  2. 2 0
      examples/jsm/shaders/OceanShaders.js

+ 2 - 0
examples/js/shaders/OceanShaders.js

@@ -110,9 +110,11 @@ THREE.OceanShaders[ 'ocean_initial_spectrum' ] = {
 			'return sqrt(G * k * (1.0 + pow2(k / KM)));',
 		'}',
 
+		'#if __VERSION__ == 100',
 		'float tanh (float x) {',
 			'return (1.0 - exp(-2.0 * x)) / (1.0 + exp(-2.0 * x));',
 		'}',
+		'#endif',
 
 		'void main (void) {',
 			'vec2 coordinates = gl_FragCoord.xy - 0.5;',

+ 2 - 0
examples/jsm/shaders/OceanShaders.js

@@ -114,9 +114,11 @@ OceanShaders[ 'ocean_initial_spectrum' ] = {
 			'return sqrt(G * k * (1.0 + pow2(k / KM)));',
 		'}',
 
+		'#if __VERSION__ == 100',
 		'float tanh (float x) {',
 			'return (1.0 - exp(-2.0 * x)) / (1.0 + exp(-2.0 * x));',
 		'}',
+		'#endif',
 
 		'void main (void) {',
 			'vec2 coordinates = gl_FragCoord.xy - 0.5;',