Browse Source

Removed a couple more examples.

Mr.doob 4 years ago
parent
commit
2dbcb41d02

+ 0 - 1
docs/api/en/lights/PointLight.html

@@ -30,7 +30,6 @@ scene.add( light );
 
 		<p>
 			[example:webgl_lights_pointlights lights / pointlights ]<br />
-			[example:webgl_lights_pointlights2 lights / pointlights2 ]<br />
 			[example:webgl_effects_anaglyph effects / anaglyph ]<br />
 			[example:webgl_geometry_text geometry / text ]<br />
 			[example:webgl_lensflares lensflares ]

+ 0 - 1
docs/api/zh/lights/PointLight.html

@@ -29,7 +29,6 @@
 
 		<p>
 			[example:webgl_lights_pointlights lights / pointlights ]<br />
-			[example:webgl_lights_pointlights2 lights / pointlights2 ]<br />
 			[example:webgl_effects_anaglyph effects / anaglyph ]<br />
 			[example:webgl_geometry_text geometry / text ]<br />
 			[example:webgl_lensflares lensflares ]

+ 0 - 2
examples/files.json

@@ -62,7 +62,6 @@
 		"webgl_lights_hemisphere",
 		"webgl_lights_physical",
 		"webgl_lights_pointlights",
-		"webgl_lights_pointlights2",
 		"webgl_lights_spotlight",
 		"webgl_lights_spotlights",
 		"webgl_lights_rectarealight",
@@ -207,7 +206,6 @@
 		"webgl_shader_lava",
 		"webgl_shader2",
 		"webgl_shaders_ocean",
-		"webgl_shaders_ocean2",
 		"webgl_shaders_sky",
 		"webgl_shaders_tonemapping",
 		"webgl_shading_physical",

+ 0 - 386
examples/js/misc/Ocean.js

@@ -1,386 +0,0 @@
-THREE.Ocean = function ( renderer, camera, scene, options ) {
-
-	// flag used to trigger parameter changes
-	this.changed = true;
-	this.initial = true;
-
-	// Assign required parameters as object properties
-	this.oceanCamera = new THREE.OrthographicCamera(); //camera.clone();
-	this.oceanCamera.position.z = 1;
-	this.renderer = renderer;
-	this.renderer.clearColor( 0xffffff );
-
-	this.scene = new THREE.Scene();
-
-	// Assign optional parameters as variables and object properties
-	function optionalParameter( value, defaultValue ) {
-
-		return value !== undefined ? value : defaultValue;
-
-	}
-
-	options = options || {};
-	this.clearColor = optionalParameter( options.CLEAR_COLOR, [ 1.0, 1.0, 1.0, 0.0 ] );
-	this.geometryOrigin = optionalParameter( options.GEOMETRY_ORIGIN, [ - 1000.0, - 1000.0 ] );
-	this.sunDirectionX = optionalParameter( options.SUN_DIRECTION[ 0 ], - 1.0 );
-	this.sunDirectionY = optionalParameter( options.SUN_DIRECTION[ 1 ], 1.0 );
-	this.sunDirectionZ = optionalParameter( options.SUN_DIRECTION[ 2 ], 1.0 );
-	this.oceanColor = optionalParameter( options.OCEAN_COLOR, new THREE.Vector3( 0.004, 0.016, 0.047 ) );
-	this.skyColor = optionalParameter( options.SKY_COLOR, new THREE.Vector3( 3.2, 9.6, 12.8 ) );
-	this.exposure = optionalParameter( options.EXPOSURE, 0.35 );
-	this.geometryResolution = optionalParameter( options.GEOMETRY_RESOLUTION, 32 );
-	this.geometrySize = optionalParameter( options.GEOMETRY_SIZE, 2000 );
-	this.resolution = optionalParameter( options.RESOLUTION, 64 );
-	this.floatSize = optionalParameter( options.SIZE_OF_FLOAT, 4 );
-	this.windX = optionalParameter( options.INITIAL_WIND[ 0 ], 10.0 );
-	this.windY = optionalParameter( options.INITIAL_WIND[ 1 ], 10.0 );
-	this.size = optionalParameter( options.INITIAL_SIZE, 250.0 );
-	this.choppiness = optionalParameter( options.INITIAL_CHOPPINESS, 1.5 );
-
-	//
-	this.matrixNeedsUpdate = false;
-
-	// Setup framebuffer pipeline
-	var renderTargetType = optionalParameter( options.USE_HALF_FLOAT, false ) ? THREE.HalfFloatType : THREE.FloatType;
-	var LinearClampParams = {
-		minFilter: THREE.LinearFilter,
-		magFilter: THREE.LinearFilter,
-		wrapS: THREE.ClampToEdgeWrapping,
-		wrapT: THREE.ClampToEdgeWrapping,
-		format: THREE.RGBAFormat,
-		depthBuffer: false,
-		premultiplyAlpha: false,
-		type: renderTargetType
-	};
-	var NearestClampParams = {
-		minFilter: THREE.NearestFilter,
-		magFilter: THREE.NearestFilter,
-		wrapS: THREE.ClampToEdgeWrapping,
-		wrapT: THREE.ClampToEdgeWrapping,
-		format: THREE.RGBAFormat,
-		depthBuffer: false,
-		premultiplyAlpha: false,
-		type: renderTargetType
-	};
-	var NearestRepeatParams = {
-		minFilter: THREE.NearestFilter,
-		magFilter: THREE.NearestFilter,
-		wrapS: THREE.RepeatWrapping,
-		wrapT: THREE.RepeatWrapping,
-		format: THREE.RGBAFormat,
-		depthBuffer: false,
-		premultiplyAlpha: false,
-		type: renderTargetType
-	};
-	this.initialSpectrumFramebuffer = new THREE.WebGLRenderTarget( this.resolution, this.resolution, NearestRepeatParams );
-	this.spectrumFramebuffer = new THREE.WebGLRenderTarget( this.resolution, this.resolution, NearestClampParams );
-	this.pingPhaseFramebuffer = new THREE.WebGLRenderTarget( this.resolution, this.resolution, NearestClampParams );
-	this.pongPhaseFramebuffer = new THREE.WebGLRenderTarget( this.resolution, this.resolution, NearestClampParams );
-	this.pingTransformFramebuffer = new THREE.WebGLRenderTarget( this.resolution, this.resolution, NearestClampParams );
-	this.pongTransformFramebuffer = new THREE.WebGLRenderTarget( this.resolution, this.resolution, NearestClampParams );
-	this.displacementMapFramebuffer = new THREE.WebGLRenderTarget( this.resolution, this.resolution, LinearClampParams );
-	this.normalMapFramebuffer = new THREE.WebGLRenderTarget( this.resolution, this.resolution, LinearClampParams );
-
-	// Define shaders and constant uniforms
-	////////////////////////////////////////
-
-	// 0 - The vertex shader used in all of the simulation steps
-	var fullscreeenVertexShader = THREE.OceanShaders[ 'ocean_sim_vertex' ];
-
-	// 1 - Horizontal wave vertices used for FFT
-	var oceanHorizontalShader = THREE.OceanShaders[ 'ocean_subtransform' ];
-	var oceanHorizontalUniforms = THREE.UniformsUtils.clone( oceanHorizontalShader.uniforms );
-	this.materialOceanHorizontal = new THREE.ShaderMaterial( {
-		uniforms: oceanHorizontalUniforms,
-		vertexShader: fullscreeenVertexShader.vertexShader,
-		fragmentShader: '#define HORIZONTAL \n' + oceanHorizontalShader.fragmentShader
-	} );
-	this.materialOceanHorizontal.uniforms.u_transformSize = { value: this.resolution };
-	this.materialOceanHorizontal.uniforms.u_subtransformSize = { value: null };
-	this.materialOceanHorizontal.uniforms.u_input = { value: null };
-	this.materialOceanHorizontal.depthTest = false;
-
-	// 2 - Vertical wave vertices used for FFT
-	var oceanVerticalShader = THREE.OceanShaders[ 'ocean_subtransform' ];
-	var oceanVerticalUniforms = THREE.UniformsUtils.clone( oceanVerticalShader.uniforms );
-	this.materialOceanVertical = new THREE.ShaderMaterial( {
-		uniforms: oceanVerticalUniforms,
-		vertexShader: fullscreeenVertexShader.vertexShader,
-		fragmentShader: oceanVerticalShader.fragmentShader
-	} );
-	this.materialOceanVertical.uniforms.u_transformSize = { value: this.resolution };
-	this.materialOceanVertical.uniforms.u_subtransformSize = { value: null };
-	this.materialOceanVertical.uniforms.u_input = { value: null };
-	this.materialOceanVertical.depthTest = false;
-
-	// 3 - Initial spectrum used to generate height map
-	var initialSpectrumShader = THREE.OceanShaders[ 'ocean_initial_spectrum' ];
-	var initialSpectrumUniforms = THREE.UniformsUtils.clone( initialSpectrumShader.uniforms );
-	this.materialInitialSpectrum = new THREE.ShaderMaterial( {
-		uniforms: initialSpectrumUniforms,
-		vertexShader: initialSpectrumShader.vertexShader,
-		fragmentShader: initialSpectrumShader.fragmentShader
-	} );
-	this.materialInitialSpectrum.uniforms.u_wind = { value: new THREE.Vector2() };
-	this.materialInitialSpectrum.uniforms.u_resolution = { value: this.resolution };
-	this.materialInitialSpectrum.depthTest = false;
-
-	// 4 - Phases used to animate heightmap
-	var phaseShader = THREE.OceanShaders[ 'ocean_phase' ];
-	var phaseUniforms = THREE.UniformsUtils.clone( phaseShader.uniforms );
-	this.materialPhase = new THREE.ShaderMaterial( {
-		uniforms: phaseUniforms,
-		vertexShader: fullscreeenVertexShader.vertexShader,
-		fragmentShader: phaseShader.fragmentShader
-	} );
-	this.materialPhase.uniforms.u_resolution = { value: this.resolution };
-	this.materialPhase.depthTest = false;
-
-	// 5 - Shader used to update spectrum
-	var spectrumShader = THREE.OceanShaders[ 'ocean_spectrum' ];
-	var spectrumUniforms = THREE.UniformsUtils.clone( spectrumShader.uniforms );
-	this.materialSpectrum = new THREE.ShaderMaterial( {
-		uniforms: spectrumUniforms,
-		vertexShader: fullscreeenVertexShader.vertexShader,
-		fragmentShader: spectrumShader.fragmentShader
-	} );
-	this.materialSpectrum.uniforms.u_initialSpectrum = { value: null };
-	this.materialSpectrum.uniforms.u_resolution = { value: this.resolution };
-	this.materialSpectrum.depthTest = false;
-
-	// 6 - Shader used to update spectrum normals
-	var normalShader = THREE.OceanShaders[ 'ocean_normals' ];
-	var normalUniforms = THREE.UniformsUtils.clone( normalShader.uniforms );
-	this.materialNormal = new THREE.ShaderMaterial( {
-		uniforms: normalUniforms,
-		vertexShader: fullscreeenVertexShader.vertexShader,
-		fragmentShader: normalShader.fragmentShader
-	} );
-	this.materialNormal.uniforms.u_displacementMap = { value: null };
-	this.materialNormal.uniforms.u_resolution = { value: this.resolution };
-	this.materialNormal.depthTest = false;
-
-	// 7 - Shader used to update normals
-	var oceanShader = THREE.OceanShaders[ 'ocean_main' ];
-	var oceanUniforms = THREE.UniformsUtils.clone( oceanShader.uniforms );
-	this.materialOcean = new THREE.ShaderMaterial( {
-		uniforms: oceanUniforms,
-		vertexShader: oceanShader.vertexShader,
-		fragmentShader: oceanShader.fragmentShader
-	} );
-	// this.materialOcean.wireframe = true;
-	this.materialOcean.uniforms.u_geometrySize = { value: this.resolution };
-	this.materialOcean.uniforms.u_displacementMap = { value: this.displacementMapFramebuffer.texture };
-	this.materialOcean.uniforms.u_normalMap = { value: this.normalMapFramebuffer.texture };
-	this.materialOcean.uniforms.u_oceanColor = { value: this.oceanColor };
-	this.materialOcean.uniforms.u_skyColor = { value: this.skyColor };
-	this.materialOcean.uniforms.u_sunDirection = { value: new THREE.Vector3( this.sunDirectionX, this.sunDirectionY, this.sunDirectionZ ) };
-	this.materialOcean.uniforms.u_exposure = { value: this.exposure };
-	this.materialOcean.uniforms.u_size = { value: this.size };
-
-	// Disable blending to prevent default premultiplied alpha values
-	this.materialOceanHorizontal.blending = 0;
-	this.materialOceanVertical.blending = 0;
-	this.materialInitialSpectrum.blending = 0;
-	this.materialPhase.blending = 0;
-	this.materialSpectrum.blending = 0;
-	this.materialNormal.blending = 0;
-	this.materialOcean.blending = 0;
-
-	// Create the simulation plane
-	this.screenQuad = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ) );
-	this.scene.add( this.screenQuad );
-
-	// Initialise spectrum data
-	this.generateSeedPhaseTexture();
-
-	// Generate the ocean mesh
-	this.generateMesh();
-
-};
-
-THREE.Ocean.prototype.generateMesh = function () {
-
-	var geometry = new THREE.PlaneGeometry( this.geometrySize, this.geometrySize, this.geometryResolution, this.geometryResolution );
-
-	geometry.rotateX( - Math.PI / 2 );
-
-	this.oceanMesh = new THREE.Mesh( geometry, this.materialOcean );
-
-};
-
-THREE.Ocean.prototype.render = function () {
-
-	var currentRenderTarget = this.renderer.getRenderTarget();
-
-	this.scene.overrideMaterial = null;
-
-	if ( this.changed )
-		this.renderInitialSpectrum();
-
-	this.renderWavePhase();
-	this.renderSpectrum();
-	this.renderSpectrumFFT();
-	this.renderNormalMap();
-	this.scene.overrideMaterial = null;
-
-	this.renderer.setRenderTarget( currentRenderTarget );
-
-};
-
-THREE.Ocean.prototype.generateSeedPhaseTexture = function () {
-
-	// Setup the seed texture
-	this.pingPhase = true;
-	var phaseArray = new window.Float32Array( this.resolution * this.resolution * 4 );
-	for ( var i = 0; i < this.resolution; i ++ ) {
-
-		for ( var j = 0; j < this.resolution; j ++ ) {
-
-			phaseArray[ i * this.resolution * 4 + j * 4 ] = Math.random() * 2.0 * Math.PI;
-			phaseArray[ i * this.resolution * 4 + j * 4 + 1 ] = 0.0;
-			phaseArray[ i * this.resolution * 4 + j * 4 + 2 ] = 0.0;
-			phaseArray[ i * this.resolution * 4 + j * 4 + 3 ] = 0.0;
-
-		}
-
-	}
-
-	this.pingPhaseTexture = new THREE.DataTexture( phaseArray, this.resolution, this.resolution, THREE.RGBAFormat );
-	this.pingPhaseTexture.wrapS = THREE.ClampToEdgeWrapping;
-	this.pingPhaseTexture.wrapT = THREE.ClampToEdgeWrapping;
-	this.pingPhaseTexture.type = THREE.FloatType;
-
-};
-
-THREE.Ocean.prototype.renderInitialSpectrum = function () {
-
-	this.scene.overrideMaterial = this.materialInitialSpectrum;
-	this.materialInitialSpectrum.uniforms.u_wind.value.set( this.windX, this.windY );
-	this.materialInitialSpectrum.uniforms.u_size.value = this.size;
-
-	this.renderer.setRenderTarget( this.initialSpectrumFramebuffer );
-	this.renderer.clear();
-	this.renderer.render( this.scene, this.oceanCamera );
-
-};
-
-THREE.Ocean.prototype.renderWavePhase = function () {
-
-	this.scene.overrideMaterial = this.materialPhase;
-	this.screenQuad.material = this.materialPhase;
-
-	if ( this.initial ) {
-
-		this.materialPhase.uniforms.u_phases.value = this.pingPhaseTexture;
-		this.initial = false;
-
-	} else {
-
-		this.materialPhase.uniforms.u_phases.value = this.pingPhase ? this.pingPhaseFramebuffer.texture : this.pongPhaseFramebuffer.texture;
-
-	}
-
-	this.materialPhase.uniforms.u_deltaTime.value = this.deltaTime;
-	this.materialPhase.uniforms.u_size.value = this.size;
-	this.renderer.setRenderTarget( this.pingPhase ? this.pongPhaseFramebuffer : this.pingPhaseFramebuffer );
-	this.renderer.render( this.scene, this.oceanCamera );
-	this.pingPhase = ! this.pingPhase;
-
-};
-
-THREE.Ocean.prototype.renderSpectrum = function () {
-
-	this.scene.overrideMaterial = this.materialSpectrum;
-	this.materialSpectrum.uniforms.u_initialSpectrum.value = this.initialSpectrumFramebuffer.texture;
-	this.materialSpectrum.uniforms.u_phases.value = this.pingPhase ? this.pingPhaseFramebuffer.texture : this.pongPhaseFramebuffer.texture;
-	this.materialSpectrum.uniforms.u_choppiness.value = this.choppiness;
-	this.materialSpectrum.uniforms.u_size.value = this.size;
-
-	this.renderer.setRenderTarget( this.spectrumFramebuffer );
-	this.renderer.render( this.scene, this.oceanCamera );
-
-};
-
-THREE.Ocean.prototype.renderSpectrumFFT = function () {
-
-	// GPU FFT using Stockham formulation
-	var iterations = Math.log( this.resolution ) / Math.log( 2 ); // log2
-
-	this.scene.overrideMaterial = this.materialOceanHorizontal;
-
-	for ( var i = 0; i < iterations; i ++ ) {
-
-		if ( i === 0 ) {
-
-			this.materialOceanHorizontal.uniforms.u_input.value = this.spectrumFramebuffer.texture;
-			this.materialOceanHorizontal.uniforms.u_subtransformSize.value = Math.pow( 2, ( i % ( iterations ) ) + 1 );
-
-			this.renderer.setRenderTarget( this.pingTransformFramebuffer );
-			this.renderer.render( this.scene, this.oceanCamera );
-
-		} else if ( i % 2 === 1 ) {
-
-			this.materialOceanHorizontal.uniforms.u_input.value = this.pingTransformFramebuffer.texture;
-			this.materialOceanHorizontal.uniforms.u_subtransformSize.value = Math.pow( 2, ( i % ( iterations ) ) + 1 );
-
-			this.renderer.setRenderTarget( this.pongTransformFramebuffer );
-			this.renderer.render( this.scene, this.oceanCamera );
-
-		} else {
-
-			this.materialOceanHorizontal.uniforms.u_input.value = this.pongTransformFramebuffer.texture;
-			this.materialOceanHorizontal.uniforms.u_subtransformSize.value = Math.pow( 2, ( i % ( iterations ) ) + 1 );
-
-			this.renderer.setRenderTarget( this.pingTransformFramebuffer );
-			this.renderer.render( this.scene, this.oceanCamera );
-
-		}
-
-	}
-
-	this.scene.overrideMaterial = this.materialOceanVertical;
-
-	for ( var i = iterations; i < iterations * 2; i ++ ) {
-
-		if ( i === iterations * 2 - 1 ) {
-
-			this.materialOceanVertical.uniforms.u_input.value = ( iterations % 2 === 0 ) ? this.pingTransformFramebuffer.texture : this.pongTransformFramebuffer.texture;
-			this.materialOceanVertical.uniforms.u_subtransformSize.value = Math.pow( 2, ( i % ( iterations ) ) + 1 );
-
-			this.renderer.setRenderTarget( this.displacementMapFramebuffer );
-			this.renderer.render( this.scene, this.oceanCamera );
-
-		} else if ( i % 2 === 1 ) {
-
-			this.materialOceanVertical.uniforms.u_input.value = this.pingTransformFramebuffer.texture;
-			this.materialOceanVertical.uniforms.u_subtransformSize.value = Math.pow( 2, ( i % ( iterations ) ) + 1 );
-
-			this.renderer.setRenderTarget( this.pongTransformFramebuffer );
-			this.renderer.render( this.scene, this.oceanCamera );
-
-		} else {
-
-			this.materialOceanVertical.uniforms.u_input.value = this.pongTransformFramebuffer.texture;
-			this.materialOceanVertical.uniforms.u_subtransformSize.value = Math.pow( 2, ( i % ( iterations ) ) + 1 );
-
-			this.renderer.setRenderTarget( this.pingTransformFramebuffer );
-			this.renderer.render( this.scene, this.oceanCamera );
-
-		}
-
-	}
-
-};
-
-THREE.Ocean.prototype.renderNormalMap = function () {
-
-	this.scene.overrideMaterial = this.materialNormal;
-	if ( this.changed ) this.materialNormal.uniforms.u_size.value = this.size;
-	this.materialNormal.uniforms.u_displacementMap.value = this.displacementMapFramebuffer.texture;
-
-	this.renderer.setRenderTarget( this.normalMapFramebuffer );
-	this.renderer.clear();
-	this.renderer.render( this.scene, this.oceanCamera );
-
-};

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

@@ -1,369 +0,0 @@
-// Description: A deep water ocean shader set
-// based on an implementation of a Tessendorf Waves
-// originally presented by David Li ( www.david.li/waves )
-
-// The general method is to apply shaders to simulation Framebuffers
-// and then sample these framebuffers when rendering the ocean mesh
-
-// The set uses 7 shaders:
-
-// -- Simulation shaders
-// [1] ocean_sim_vertex         -> Vertex shader used to set up a 2x2 simulation plane centered at (0,0)
-// [2] ocean_subtransform       -> Fragment shader used to subtransform the mesh (generates the displacement map)
-// [3] ocean_initial_spectrum   -> Fragment shader used to set intitial wave frequency at a texel coordinate
-// [4] ocean_phase              -> Fragment shader used to set wave phase at a texel coordinate
-// [5] ocean_spectrum           -> Fragment shader used to set current wave frequency at a texel coordinate
-// [6] ocean_normal             -> Fragment shader used to set face normals at a texel coordinate
-
-// -- Rendering Shader
-// [7] ocean_main               -> Vertex and Fragment shader used to create the final render
-
-THREE.OceanShaders = {};
-THREE.OceanShaders[ 'ocean_sim_vertex' ] = {
-	vertexShader: [
-		'varying vec2 vUV;',
-
-		'void main (void) {',
-		'	vUV = position.xy * 0.5 + 0.5;',
-		'	gl_Position = vec4(position, 1.0 );',
-		'}'
-	].join( '\n' )
-};
-THREE.OceanShaders[ 'ocean_subtransform' ] = {
-	uniforms: {
-		'u_input': { value: null },
-		'u_transformSize': { value: 512.0 },
-		'u_subtransformSize': { value: 250.0 }
-	},
-	fragmentShader: [
-		//GPU FFT using a Stockham formulation
-
-		'precision highp float;',
-		'#include <common>',
-
-		'uniform sampler2D u_input;',
-		'uniform float u_transformSize;',
-		'uniform float u_subtransformSize;',
-
-		'varying vec2 vUV;',
-
-		'vec2 multiplyComplex (vec2 a, vec2 b) {',
-		'	return vec2(a[0] * b[0] - a[1] * b[1], a[1] * b[0] + a[0] * b[1]);',
-		'}',
-
-		'void main (void) {',
-		'	#ifdef HORIZONTAL',
-		'	float index = vUV.x * u_transformSize - 0.5;',
-		'	#else',
-		'	float index = vUV.y * u_transformSize - 0.5;',
-		'	#endif',
-
-		'	float evenIndex = floor(index / u_subtransformSize) * (u_subtransformSize * 0.5) + mod(index, u_subtransformSize * 0.5);',
-
-		//transform two complex sequences simultaneously
-		'	#ifdef HORIZONTAL',
-		'	vec4 even = texture2D(u_input, vec2(evenIndex + 0.5, gl_FragCoord.y) / u_transformSize).rgba;',
-		'	vec4 odd = texture2D(u_input, vec2(evenIndex + u_transformSize * 0.5 + 0.5, gl_FragCoord.y) / u_transformSize).rgba;',
-		'	#else',
-		'	vec4 even = texture2D(u_input, vec2(gl_FragCoord.x, evenIndex + 0.5) / u_transformSize).rgba;',
-		'	vec4 odd = texture2D(u_input, vec2(gl_FragCoord.x, evenIndex + u_transformSize * 0.5 + 0.5) / u_transformSize).rgba;',
-		'	#endif',
-
-		'	float twiddleArgument = -2.0 * PI * (index / u_subtransformSize);',
-		'	vec2 twiddle = vec2(cos(twiddleArgument), sin(twiddleArgument));',
-
-		'	vec2 outputA = even.xy + multiplyComplex(twiddle, odd.xy);',
-		'	vec2 outputB = even.zw + multiplyComplex(twiddle, odd.zw);',
-
-		'	gl_FragColor = vec4(outputA, outputB);',
-		'}'
-	].join( '\n' )
-};
-THREE.OceanShaders[ 'ocean_initial_spectrum' ] = {
-	uniforms: {
-		'u_wind': { value: new THREE.Vector2( 10.0, 10.0 ) },
-		'u_resolution': { value: 512.0 },
-		'u_size': { value: 250.0 }
-	},
-	vertexShader: [
-		'void main (void) {',
-		'	gl_Position = vec4(position, 1.0);',
-		'}'
-	].join( '\n' ),
-	fragmentShader: [
-		'precision highp float;',
-		'#include <common>',
-
-		'const float G = 9.81;',
-		'const float KM = 370.0;',
-		'const float CM = 0.23;',
-
-		'uniform vec2 u_wind;',
-		'uniform float u_resolution;',
-		'uniform float u_size;',
-
-		'float omega (float k) {',
-		'	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;',
-
-		'	float n = (coordinates.x < u_resolution * 0.5) ? coordinates.x : coordinates.x - u_resolution;',
-		'	float m = (coordinates.y < u_resolution * 0.5) ? coordinates.y : coordinates.y - u_resolution;',
-
-		'	vec2 K = (2.0 * PI * vec2(n, m)) / u_size;',
-		'	float k = length(K);',
-
-		'	float l_wind = length(u_wind);',
-
-		'	float Omega = 0.84;',
-		'	float kp = G * pow2(Omega / l_wind);',
-
-		'	float c = omega(k) / k;',
-		'	float cp = omega(kp) / kp;',
-
-		'	float Lpm = exp(-1.25 * pow2(kp / k));',
-		'	float gamma = 1.7;',
-		'	float sigma = 0.08 * (1.0 + 4.0 * pow(Omega, -3.0));',
-		'	float Gamma = exp(-pow2(sqrt(k / kp) - 1.0) / 2.0 * pow2(sigma));',
-		'	float Jp = pow(gamma, Gamma);',
-		'	float Fp = Lpm * Jp * exp(-Omega / sqrt(10.0) * (sqrt(k / kp) - 1.0));',
-		'	float alphap = 0.006 * sqrt(Omega);',
-		'	float Bl = 0.5 * alphap * cp / c * Fp;',
-
-		'	float z0 = 0.000037 * pow2(l_wind) / G * pow(l_wind / cp, 0.9);',
-		'	float uStar = 0.41 * l_wind / log(10.0 / z0);',
-		'	float alpham = 0.01 * ((uStar < CM) ? (1.0 + log(uStar / CM)) : (1.0 + 3.0 * log(uStar / CM)));',
-		'	float Fm = exp(-0.25 * pow2(k / KM - 1.0));',
-		'	float Bh = 0.5 * alpham * CM / c * Fm * Lpm;',
-
-		'	float a0 = log(2.0) / 4.0;',
-		'	float am = 0.13 * uStar / CM;',
-		'	float Delta = tanh(a0 + 4.0 * pow(c / cp, 2.5) + am * pow(CM / c, 2.5));',
-
-		'	float cosPhi = dot(normalize(u_wind), normalize(K));',
-
-		'	float S = (1.0 / (2.0 * PI)) * pow(k, -4.0) * (Bl + Bh) * (1.0 + Delta * (2.0 * cosPhi * cosPhi - 1.0));',
-
-		'	float dk = 2.0 * PI / u_size;',
-		'	float h = sqrt(S / 2.0) * dk;',
-
-		'	if (K.x == 0.0 && K.y == 0.0) {',
-		'		h = 0.0;', //no DC term
-		'	}',
-		'	gl_FragColor = vec4(h, 0.0, 0.0, 0.0);',
-		'}'
-	].join( '\n' )
-};
-THREE.OceanShaders[ 'ocean_phase' ] = {
-	uniforms: {
-		'u_phases': { value: null },
-		'u_deltaTime': { value: null },
-		'u_resolution': { value: null },
-		'u_size': { value: null }
-	},
-	fragmentShader: [
-		'precision highp float;',
-		'#include <common>',
-
-		'const float G = 9.81;',
-		'const float KM = 370.0;',
-
-		'varying vec2 vUV;',
-
-		'uniform sampler2D u_phases;',
-		'uniform float u_deltaTime;',
-		'uniform float u_resolution;',
-		'uniform float u_size;',
-
-		'float omega (float k) {',
-		'	return sqrt(G * k * (1.0 + k * k / KM * KM));',
-		'}',
-
-		'void main (void) {',
-		'	float deltaTime = 1.0 / 60.0;',
-		'	vec2 coordinates = gl_FragCoord.xy - 0.5;',
-		'	float n = (coordinates.x < u_resolution * 0.5) ? coordinates.x : coordinates.x - u_resolution;',
-		'	float m = (coordinates.y < u_resolution * 0.5) ? coordinates.y : coordinates.y - u_resolution;',
-		'	vec2 waveVector = (2.0 * PI * vec2(n, m)) / u_size;',
-
-		'	float phase = texture2D(u_phases, vUV).r;',
-		'	float deltaPhase = omega(length(waveVector)) * u_deltaTime;',
-		'	phase = mod(phase + deltaPhase, 2.0 * PI);',
-
-		'	gl_FragColor = vec4(phase, 0.0, 0.0, 0.0);',
-		'}'
-	].join( '\n' )
-};
-THREE.OceanShaders[ 'ocean_spectrum' ] = {
-	uniforms: {
-		'u_size': { value: null },
-		'u_resolution': { value: null },
-		'u_choppiness': { value: null },
-		'u_phases': { value: null },
-		'u_initialSpectrum': { value: null }
-	},
-	fragmentShader: [
-		'precision highp float;',
-		'#include <common>',
-
-		'const float G = 9.81;',
-		'const float KM = 370.0;',
-
-		'varying vec2 vUV;',
-
-		'uniform float u_size;',
-		'uniform float u_resolution;',
-		'uniform float u_choppiness;',
-		'uniform sampler2D u_phases;',
-		'uniform sampler2D u_initialSpectrum;',
-
-		'vec2 multiplyComplex (vec2 a, vec2 b) {',
-		'	return vec2(a[0] * b[0] - a[1] * b[1], a[1] * b[0] + a[0] * b[1]);',
-		'}',
-
-		'vec2 multiplyByI (vec2 z) {',
-		'	return vec2(-z[1], z[0]);',
-		'}',
-
-		'float omega (float k) {',
-		'	return sqrt(G * k * (1.0 + k * k / KM * KM));',
-		'}',
-
-		'void main (void) {',
-		'	vec2 coordinates = gl_FragCoord.xy - 0.5;',
-		'	float n = (coordinates.x < u_resolution * 0.5) ? coordinates.x : coordinates.x - u_resolution;',
-		'	float m = (coordinates.y < u_resolution * 0.5) ? coordinates.y : coordinates.y - u_resolution;',
-		'	vec2 waveVector = (2.0 * PI * vec2(n, m)) / u_size;',
-
-		'	float phase = texture2D(u_phases, vUV).r;',
-		'	vec2 phaseVector = vec2(cos(phase), sin(phase));',
-
-		'	vec2 h0 = texture2D(u_initialSpectrum, vUV).rg;',
-		'	vec2 h0Star = texture2D(u_initialSpectrum, vec2(1.0 - vUV + 1.0 / u_resolution)).rg;',
-		'	h0Star.y *= -1.0;',
-
-		'	vec2 h = multiplyComplex(h0, phaseVector) + multiplyComplex(h0Star, vec2(phaseVector.x, -phaseVector.y));',
-
-		'	vec2 hX = -multiplyByI(h * (waveVector.x / length(waveVector))) * u_choppiness;',
-		'	vec2 hZ = -multiplyByI(h * (waveVector.y / length(waveVector))) * u_choppiness;',
-
-		//no DC term
-		'	if (waveVector.x == 0.0 && waveVector.y == 0.0) {',
-		'		h = vec2(0.0);',
-		'		hX = vec2(0.0);',
-		'		hZ = vec2(0.0);',
-		'	}',
-
-		'	gl_FragColor = vec4(hX + multiplyByI(h), hZ);',
-		'}'
-	].join( '\n' )
-};
-THREE.OceanShaders[ 'ocean_normals' ] = {
-	uniforms: {
-		'u_displacementMap': { value: null },
-		'u_resolution': { value: null },
-		'u_size': { value: null }
-	},
-	fragmentShader: [
-		'precision highp float;',
-
-		'varying vec2 vUV;',
-
-		'uniform sampler2D u_displacementMap;',
-		'uniform float u_resolution;',
-		'uniform float u_size;',
-
-		'void main (void) {',
-		'	float texel = 1.0 / u_resolution;',
-		'	float texelSize = u_size / u_resolution;',
-
-		'	vec3 center = texture2D(u_displacementMap, vUV).rgb;',
-		'	vec3 right = vec3(texelSize, 0.0, 0.0) + texture2D(u_displacementMap, vUV + vec2(texel, 0.0)).rgb - center;',
-		'	vec3 left = vec3(-texelSize, 0.0, 0.0) + texture2D(u_displacementMap, vUV + vec2(-texel, 0.0)).rgb - center;',
-		'	vec3 top = vec3(0.0, 0.0, -texelSize) + texture2D(u_displacementMap, vUV + vec2(0.0, -texel)).rgb - center;',
-		'	vec3 bottom = vec3(0.0, 0.0, texelSize) + texture2D(u_displacementMap, vUV + vec2(0.0, texel)).rgb - center;',
-
-		'	vec3 topRight = cross(right, top);',
-		'	vec3 topLeft = cross(top, left);',
-		'	vec3 bottomLeft = cross(left, bottom);',
-		'	vec3 bottomRight = cross(bottom, right);',
-
-		'	gl_FragColor = vec4(normalize(topRight + topLeft + bottomLeft + bottomRight), 1.0);',
-		'}'
-	].join( '\n' )
-};
-THREE.OceanShaders[ 'ocean_main' ] = {
-	uniforms: {
-		'u_displacementMap': { value: null },
-		'u_normalMap': { value: null },
-		'u_geometrySize': { value: null },
-		'u_size': { value: null },
-		'u_projectionMatrix': { value: null },
-		'u_viewMatrix': { value: null },
-		'u_cameraPosition': { value: null },
-		'u_skyColor': { value: null },
-		'u_oceanColor': { value: null },
-		'u_sunDirection': { value: null },
-		'u_exposure': { value: null }
-	},
-	vertexShader: [
-		'precision highp float;',
-
-		'varying vec3 vPos;',
-		'varying vec2 vUV;',
-
-		'uniform mat4 u_projectionMatrix;',
-		'uniform mat4 u_viewMatrix;',
-		'uniform float u_size;',
-		'uniform float u_geometrySize;',
-		'uniform sampler2D u_displacementMap;',
-
-		'void main (void) {',
-		'	vec3 newPos = position + texture2D(u_displacementMap, uv).rgb * (u_geometrySize / u_size);',
-		'	vPos = newPos;',
-		'	vUV = uv;',
-		'	gl_Position = u_projectionMatrix * u_viewMatrix * vec4(newPos, 1.0);',
-		'}'
-	].join( '\n' ),
-	fragmentShader: [
-		'precision highp float;',
-
-		'varying vec3 vPos;',
-		'varying vec2 vUV;',
-
-		'uniform sampler2D u_displacementMap;',
-		'uniform sampler2D u_normalMap;',
-		'uniform vec3 u_cameraPosition;',
-		'uniform vec3 u_oceanColor;',
-		'uniform vec3 u_skyColor;',
-		'uniform vec3 u_sunDirection;',
-		'uniform float u_exposure;',
-
-		'vec3 hdr (vec3 color, float exposure) {',
-		'	return 1.0 - exp(-color * exposure);',
-		'}',
-
-		'void main (void) {',
-		'	vec3 normal = texture2D(u_normalMap, vUV).rgb;',
-
-		'	vec3 view = normalize(u_cameraPosition - vPos);',
-		'	float fresnel = 0.02 + 0.98 * pow(1.0 - dot(normal, view), 5.0);',
-		'	vec3 sky = fresnel * u_skyColor;',
-
-		'	float diffuse = clamp(dot(normal, normalize(u_sunDirection)), 0.0, 1.0);',
-		'	vec3 water = (1.0 - fresnel) * u_oceanColor * u_skyColor * diffuse;',
-
-		'	vec3 color = sky + water;',
-
-		'	gl_FragColor = vec4(hdr(color, u_exposure), 1.0);',
-		'}'
-	].join( '\n' )
-};

+ 0 - 409
examples/jsm/misc/Ocean.js

@@ -1,409 +0,0 @@
-import {
-	ClampToEdgeWrapping,
-	DataTexture,
-	FloatType,
-	HalfFloatType,
-	LinearFilter,
-	Mesh,
-	NearestFilter,
-	OrthographicCamera,
-	PlaneGeometry,
-	RGBAFormat,
-	RepeatWrapping,
-	Scene,
-	ShaderMaterial,
-	UniformsUtils,
-	Vector2,
-	Vector3,
-	WebGLRenderTarget
-} from '../../../build/three.module.js';
-import { OceanShaders } from '../shaders/OceanShaders.js';
-
-var Ocean = function ( renderer, camera, scene, options ) {
-
-	// flag used to trigger parameter changes
-	this.changed = true;
-	this.initial = true;
-
-	// Assign required parameters as object properties
-	this.oceanCamera = new OrthographicCamera(); //camera.clone();
-	this.oceanCamera.position.z = 1;
-	this.renderer = renderer;
-	this.renderer.clearColor( 0xffffff );
-
-	this.scene = new Scene();
-
-	// Assign optional parameters as variables and object properties
-	function optionalParameter( value, defaultValue ) {
-
-		return value !== undefined ? value : defaultValue;
-
-	}
-
-	options = options || {};
-	this.clearColor = optionalParameter( options.CLEAR_COLOR, [ 1.0, 1.0, 1.0, 0.0 ] );
-	this.geometryOrigin = optionalParameter( options.GEOMETRY_ORIGIN, [ - 1000.0, - 1000.0 ] );
-	this.sunDirectionX = optionalParameter( options.SUN_DIRECTION[ 0 ], - 1.0 );
-	this.sunDirectionY = optionalParameter( options.SUN_DIRECTION[ 1 ], 1.0 );
-	this.sunDirectionZ = optionalParameter( options.SUN_DIRECTION[ 2 ], 1.0 );
-	this.oceanColor = optionalParameter( options.OCEAN_COLOR, new Vector3( 0.004, 0.016, 0.047 ) );
-	this.skyColor = optionalParameter( options.SKY_COLOR, new Vector3( 3.2, 9.6, 12.8 ) );
-	this.exposure = optionalParameter( options.EXPOSURE, 0.35 );
-	this.geometryResolution = optionalParameter( options.GEOMETRY_RESOLUTION, 32 );
-	this.geometrySize = optionalParameter( options.GEOMETRY_SIZE, 2000 );
-	this.resolution = optionalParameter( options.RESOLUTION, 64 );
-	this.floatSize = optionalParameter( options.SIZE_OF_FLOAT, 4 );
-	this.windX = optionalParameter( options.INITIAL_WIND[ 0 ], 10.0 );
-	this.windY = optionalParameter( options.INITIAL_WIND[ 1 ], 10.0 );
-	this.size = optionalParameter( options.INITIAL_SIZE, 250.0 );
-	this.choppiness = optionalParameter( options.INITIAL_CHOPPINESS, 1.5 );
-
-	//
-	this.matrixNeedsUpdate = false;
-
-	// Setup framebuffer pipeline
-	var renderTargetType = optionalParameter( options.USE_HALF_FLOAT, false ) ? HalfFloatType : FloatType;
-	var LinearClampParams = {
-		minFilter: LinearFilter,
-		magFilter: LinearFilter,
-		wrapS: ClampToEdgeWrapping,
-		wrapT: ClampToEdgeWrapping,
-		format: RGBAFormat,
-		depthBuffer: false,
-		premultiplyAlpha: false,
-		type: renderTargetType
-	};
-	var NearestClampParams = {
-		minFilter: NearestFilter,
-		magFilter: NearestFilter,
-		wrapS: ClampToEdgeWrapping,
-		wrapT: ClampToEdgeWrapping,
-		format: RGBAFormat,
-		depthBuffer: false,
-		premultiplyAlpha: false,
-		type: renderTargetType
-	};
-	var NearestRepeatParams = {
-		minFilter: NearestFilter,
-		magFilter: NearestFilter,
-		wrapS: RepeatWrapping,
-		wrapT: RepeatWrapping,
-		format: RGBAFormat,
-		depthBuffer: false,
-		premultiplyAlpha: false,
-		type: renderTargetType
-	};
-	this.initialSpectrumFramebuffer = new WebGLRenderTarget( this.resolution, this.resolution, NearestRepeatParams );
-	this.spectrumFramebuffer = new WebGLRenderTarget( this.resolution, this.resolution, NearestClampParams );
-	this.pingPhaseFramebuffer = new WebGLRenderTarget( this.resolution, this.resolution, NearestClampParams );
-	this.pongPhaseFramebuffer = new WebGLRenderTarget( this.resolution, this.resolution, NearestClampParams );
-	this.pingTransformFramebuffer = new WebGLRenderTarget( this.resolution, this.resolution, NearestClampParams );
-	this.pongTransformFramebuffer = new WebGLRenderTarget( this.resolution, this.resolution, NearestClampParams );
-	this.displacementMapFramebuffer = new WebGLRenderTarget( this.resolution, this.resolution, LinearClampParams );
-	this.normalMapFramebuffer = new WebGLRenderTarget( this.resolution, this.resolution, LinearClampParams );
-
-	// Define shaders and constant uniforms
-	////////////////////////////////////////
-
-	// 0 - The vertex shader used in all of the simulation steps
-	var fullscreeenVertexShader = OceanShaders[ 'ocean_sim_vertex' ];
-
-	// 1 - Horizontal wave vertices used for FFT
-	var oceanHorizontalShader = OceanShaders[ 'ocean_subtransform' ];
-	var oceanHorizontalUniforms = UniformsUtils.clone( oceanHorizontalShader.uniforms );
-	this.materialOceanHorizontal = new ShaderMaterial( {
-		uniforms: oceanHorizontalUniforms,
-		vertexShader: fullscreeenVertexShader.vertexShader,
-		fragmentShader: '#define HORIZONTAL \n' + oceanHorizontalShader.fragmentShader
-	} );
-	this.materialOceanHorizontal.uniforms.u_transformSize = { value: this.resolution };
-	this.materialOceanHorizontal.uniforms.u_subtransformSize = { value: null };
-	this.materialOceanHorizontal.uniforms.u_input = { value: null };
-	this.materialOceanHorizontal.depthTest = false;
-
-	// 2 - Vertical wave vertices used for FFT
-	var oceanVerticalShader = OceanShaders[ 'ocean_subtransform' ];
-	var oceanVerticalUniforms = UniformsUtils.clone( oceanVerticalShader.uniforms );
-	this.materialOceanVertical = new ShaderMaterial( {
-		uniforms: oceanVerticalUniforms,
-		vertexShader: fullscreeenVertexShader.vertexShader,
-		fragmentShader: oceanVerticalShader.fragmentShader
-	} );
-	this.materialOceanVertical.uniforms.u_transformSize = { value: this.resolution };
-	this.materialOceanVertical.uniforms.u_subtransformSize = { value: null };
-	this.materialOceanVertical.uniforms.u_input = { value: null };
-	this.materialOceanVertical.depthTest = false;
-
-	// 3 - Initial spectrum used to generate height map
-	var initialSpectrumShader = OceanShaders[ 'ocean_initial_spectrum' ];
-	var initialSpectrumUniforms = UniformsUtils.clone( initialSpectrumShader.uniforms );
-	this.materialInitialSpectrum = new ShaderMaterial( {
-		uniforms: initialSpectrumUniforms,
-		vertexShader: initialSpectrumShader.vertexShader,
-		fragmentShader: initialSpectrumShader.fragmentShader
-	} );
-	this.materialInitialSpectrum.uniforms.u_wind = { value: new Vector2() };
-	this.materialInitialSpectrum.uniforms.u_resolution = { value: this.resolution };
-	this.materialInitialSpectrum.depthTest = false;
-
-	// 4 - Phases used to animate heightmap
-	var phaseShader = OceanShaders[ 'ocean_phase' ];
-	var phaseUniforms = UniformsUtils.clone( phaseShader.uniforms );
-	this.materialPhase = new ShaderMaterial( {
-		uniforms: phaseUniforms,
-		vertexShader: fullscreeenVertexShader.vertexShader,
-		fragmentShader: phaseShader.fragmentShader
-	} );
-	this.materialPhase.uniforms.u_resolution = { value: this.resolution };
-	this.materialPhase.depthTest = false;
-
-	// 5 - Shader used to update spectrum
-	var spectrumShader = OceanShaders[ 'ocean_spectrum' ];
-	var spectrumUniforms = UniformsUtils.clone( spectrumShader.uniforms );
-	this.materialSpectrum = new ShaderMaterial( {
-		uniforms: spectrumUniforms,
-		vertexShader: fullscreeenVertexShader.vertexShader,
-		fragmentShader: spectrumShader.fragmentShader
-	} );
-	this.materialSpectrum.uniforms.u_initialSpectrum = { value: null };
-	this.materialSpectrum.uniforms.u_resolution = { value: this.resolution };
-	this.materialSpectrum.depthTest = false;
-
-	// 6 - Shader used to update spectrum normals
-	var normalShader = OceanShaders[ 'ocean_normals' ];
-	var normalUniforms = UniformsUtils.clone( normalShader.uniforms );
-	this.materialNormal = new ShaderMaterial( {
-		uniforms: normalUniforms,
-		vertexShader: fullscreeenVertexShader.vertexShader,
-		fragmentShader: normalShader.fragmentShader
-	} );
-	this.materialNormal.uniforms.u_displacementMap = { value: null };
-	this.materialNormal.uniforms.u_resolution = { value: this.resolution };
-	this.materialNormal.depthTest = false;
-
-	// 7 - Shader used to update normals
-	var oceanShader = OceanShaders[ 'ocean_main' ];
-	var oceanUniforms = UniformsUtils.clone( oceanShader.uniforms );
-	this.materialOcean = new ShaderMaterial( {
-		uniforms: oceanUniforms,
-		vertexShader: oceanShader.vertexShader,
-		fragmentShader: oceanShader.fragmentShader
-	} );
-	// this.materialOcean.wireframe = true;
-	this.materialOcean.uniforms.u_geometrySize = { value: this.resolution };
-	this.materialOcean.uniforms.u_displacementMap = { value: this.displacementMapFramebuffer.texture };
-	this.materialOcean.uniforms.u_normalMap = { value: this.normalMapFramebuffer.texture };
-	this.materialOcean.uniforms.u_oceanColor = { value: this.oceanColor };
-	this.materialOcean.uniforms.u_skyColor = { value: this.skyColor };
-	this.materialOcean.uniforms.u_sunDirection = { value: new Vector3( this.sunDirectionX, this.sunDirectionY, this.sunDirectionZ ) };
-	this.materialOcean.uniforms.u_exposure = { value: this.exposure };
-	this.materialOcean.uniforms.u_size = { value: this.size };
-
-	// Disable blending to prevent default premultiplied alpha values
-	this.materialOceanHorizontal.blending = 0;
-	this.materialOceanVertical.blending = 0;
-	this.materialInitialSpectrum.blending = 0;
-	this.materialPhase.blending = 0;
-	this.materialSpectrum.blending = 0;
-	this.materialNormal.blending = 0;
-	this.materialOcean.blending = 0;
-
-	// Create the simulation plane
-	this.screenQuad = new Mesh( new PlaneGeometry( 2, 2 ) );
-	this.scene.add( this.screenQuad );
-
-	// Initialise spectrum data
-	this.generateSeedPhaseTexture();
-
-	// Generate the ocean mesh
-	this.generateMesh();
-
-};
-
-Ocean.prototype.generateMesh = function () {
-
-	var geometry = new PlaneGeometry( this.geometrySize, this.geometrySize, this.geometryResolution, this.geometryResolution );
-
-	geometry.rotateX( - Math.PI / 2 );
-
-	this.oceanMesh = new Mesh( geometry, this.materialOcean );
-
-};
-
-Ocean.prototype.render = function () {
-
-	var currentRenderTarget = this.renderer.getRenderTarget();
-
-	this.scene.overrideMaterial = null;
-
-	if ( this.changed )
-		this.renderInitialSpectrum();
-
-	this.renderWavePhase();
-	this.renderSpectrum();
-	this.renderSpectrumFFT();
-	this.renderNormalMap();
-	this.scene.overrideMaterial = null;
-
-	this.renderer.setRenderTarget( currentRenderTarget );
-
-};
-
-Ocean.prototype.generateSeedPhaseTexture = function () {
-
-	// Setup the seed texture
-	this.pingPhase = true;
-	var phaseArray = new window.Float32Array( this.resolution * this.resolution * 4 );
-	for ( var i = 0; i < this.resolution; i ++ ) {
-
-		for ( var j = 0; j < this.resolution; j ++ ) {
-
-			phaseArray[ i * this.resolution * 4 + j * 4 ] = Math.random() * 2.0 * Math.PI;
-			phaseArray[ i * this.resolution * 4 + j * 4 + 1 ] = 0.0;
-			phaseArray[ i * this.resolution * 4 + j * 4 + 2 ] = 0.0;
-			phaseArray[ i * this.resolution * 4 + j * 4 + 3 ] = 0.0;
-
-		}
-
-	}
-
-	this.pingPhaseTexture = new DataTexture( phaseArray, this.resolution, this.resolution, RGBAFormat );
-	this.pingPhaseTexture.wrapS = ClampToEdgeWrapping;
-	this.pingPhaseTexture.wrapT = ClampToEdgeWrapping;
-	this.pingPhaseTexture.type = FloatType;
-
-};
-
-Ocean.prototype.renderInitialSpectrum = function () {
-
-	this.scene.overrideMaterial = this.materialInitialSpectrum;
-	this.materialInitialSpectrum.uniforms.u_wind.value.set( this.windX, this.windY );
-	this.materialInitialSpectrum.uniforms.u_size.value = this.size;
-
-	this.renderer.setRenderTarget( this.initialSpectrumFramebuffer );
-	this.renderer.clear();
-	this.renderer.render( this.scene, this.oceanCamera );
-
-};
-
-Ocean.prototype.renderWavePhase = function () {
-
-	this.scene.overrideMaterial = this.materialPhase;
-	this.screenQuad.material = this.materialPhase;
-
-	if ( this.initial ) {
-
-		this.materialPhase.uniforms.u_phases.value = this.pingPhaseTexture;
-		this.initial = false;
-
-	} else {
-
-		this.materialPhase.uniforms.u_phases.value = this.pingPhase ? this.pingPhaseFramebuffer.texture : this.pongPhaseFramebuffer.texture;
-
-	}
-
-	this.materialPhase.uniforms.u_deltaTime.value = this.deltaTime;
-	this.materialPhase.uniforms.u_size.value = this.size;
-	this.renderer.setRenderTarget( this.pingPhase ? this.pongPhaseFramebuffer : this.pingPhaseFramebuffer );
-	this.renderer.render( this.scene, this.oceanCamera );
-	this.pingPhase = ! this.pingPhase;
-
-};
-
-Ocean.prototype.renderSpectrum = function () {
-
-	this.scene.overrideMaterial = this.materialSpectrum;
-	this.materialSpectrum.uniforms.u_initialSpectrum.value = this.initialSpectrumFramebuffer.texture;
-	this.materialSpectrum.uniforms.u_phases.value = this.pingPhase ? this.pingPhaseFramebuffer.texture : this.pongPhaseFramebuffer.texture;
-	this.materialSpectrum.uniforms.u_choppiness.value = this.choppiness;
-	this.materialSpectrum.uniforms.u_size.value = this.size;
-
-	this.renderer.setRenderTarget( this.spectrumFramebuffer );
-	this.renderer.render( this.scene, this.oceanCamera );
-
-};
-
-Ocean.prototype.renderSpectrumFFT = function () {
-
-	// GPU FFT using Stockham formulation
-	var iterations = Math.log( this.resolution ) / Math.log( 2 ); // log2
-
-	this.scene.overrideMaterial = this.materialOceanHorizontal;
-
-	for ( var i = 0; i < iterations; i ++ ) {
-
-		if ( i === 0 ) {
-
-			this.materialOceanHorizontal.uniforms.u_input.value = this.spectrumFramebuffer.texture;
-			this.materialOceanHorizontal.uniforms.u_subtransformSize.value = Math.pow( 2, ( i % ( iterations ) ) + 1 );
-
-			this.renderer.setRenderTarget( this.pingTransformFramebuffer );
-			this.renderer.render( this.scene, this.oceanCamera );
-
-		} else if ( i % 2 === 1 ) {
-
-			this.materialOceanHorizontal.uniforms.u_input.value = this.pingTransformFramebuffer.texture;
-			this.materialOceanHorizontal.uniforms.u_subtransformSize.value = Math.pow( 2, ( i % ( iterations ) ) + 1 );
-
-			this.renderer.setRenderTarget( this.pongTransformFramebuffer );
-			this.renderer.render( this.scene, this.oceanCamera );
-
-		} else {
-
-			this.materialOceanHorizontal.uniforms.u_input.value = this.pongTransformFramebuffer.texture;
-			this.materialOceanHorizontal.uniforms.u_subtransformSize.value = Math.pow( 2, ( i % ( iterations ) ) + 1 );
-
-			this.renderer.setRenderTarget( this.pingTransformFramebuffer );
-			this.renderer.render( this.scene, this.oceanCamera );
-
-		}
-
-	}
-
-	this.scene.overrideMaterial = this.materialOceanVertical;
-
-	for ( var i = iterations; i < iterations * 2; i ++ ) {
-
-		if ( i === iterations * 2 - 1 ) {
-
-			this.materialOceanVertical.uniforms.u_input.value = ( iterations % 2 === 0 ) ? this.pingTransformFramebuffer.texture : this.pongTransformFramebuffer.texture;
-			this.materialOceanVertical.uniforms.u_subtransformSize.value = Math.pow( 2, ( i % ( iterations ) ) + 1 );
-
-			this.renderer.setRenderTarget( this.displacementMapFramebuffer );
-			this.renderer.render( this.scene, this.oceanCamera );
-
-		} else if ( i % 2 === 1 ) {
-
-			this.materialOceanVertical.uniforms.u_input.value = this.pingTransformFramebuffer.texture;
-			this.materialOceanVertical.uniforms.u_subtransformSize.value = Math.pow( 2, ( i % ( iterations ) ) + 1 );
-
-			this.renderer.setRenderTarget( this.pongTransformFramebuffer );
-			this.renderer.render( this.scene, this.oceanCamera );
-
-		} else {
-
-			this.materialOceanVertical.uniforms.u_input.value = this.pongTransformFramebuffer.texture;
-			this.materialOceanVertical.uniforms.u_subtransformSize.value = Math.pow( 2, ( i % ( iterations ) ) + 1 );
-
-			this.renderer.setRenderTarget( this.pingTransformFramebuffer );
-			this.renderer.render( this.scene, this.oceanCamera );
-
-		}
-
-	}
-
-};
-
-Ocean.prototype.renderNormalMap = function () {
-
-	this.scene.overrideMaterial = this.materialNormal;
-	if ( this.changed ) this.materialNormal.uniforms.u_size.value = this.size;
-	this.materialNormal.uniforms.u_displacementMap.value = this.displacementMapFramebuffer.texture;
-
-	this.renderer.setRenderTarget( this.normalMapFramebuffer );
-	this.renderer.clear();
-	this.renderer.render( this.scene, this.oceanCamera );
-
-};
-
-export { Ocean };

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

@@ -1,375 +0,0 @@
-import {
-	Vector2
-} from '../../../build/three.module.js';
-
-// Description: A deep water ocean shader set
-// based on an implementation of a Tessendorf Waves
-// originally presented by David Li ( www.david.li/waves )
-
-// The general method is to apply shaders to simulation Framebuffers
-// and then sample these framebuffers when rendering the ocean mesh
-
-// The set uses 7 shaders:
-
-// -- Simulation shaders
-// [1] ocean_sim_vertex         -> Vertex shader used to set up a 2x2 simulation plane centered at (0,0)
-// [2] ocean_subtransform       -> Fragment shader used to subtransform the mesh (generates the displacement map)
-// [3] ocean_initial_spectrum   -> Fragment shader used to set intitial wave frequency at a texel coordinate
-// [4] ocean_phase              -> Fragment shader used to set wave phase at a texel coordinate
-// [5] ocean_spectrum           -> Fragment shader used to set current wave frequency at a texel coordinate
-// [6] ocean_normal             -> Fragment shader used to set face normals at a texel coordinate
-
-// -- Rendering Shader
-// [7] ocean_main               -> Vertex and Fragment shader used to create the final render
-
-var OceanShaders = {};
-OceanShaders[ 'ocean_sim_vertex' ] = {
-	vertexShader: [
-		'varying vec2 vUV;',
-
-		'void main (void) {',
-		'	vUV = position.xy * 0.5 + 0.5;',
-		'	gl_Position = vec4(position, 1.0 );',
-		'}'
-	].join( '\n' )
-};
-OceanShaders[ 'ocean_subtransform' ] = {
-	uniforms: {
-		'u_input': { value: null },
-		'u_transformSize': { value: 512.0 },
-		'u_subtransformSize': { value: 250.0 }
-	},
-	fragmentShader: [
-		//GPU FFT using a Stockham formulation
-
-		'precision highp float;',
-		'#include <common>',
-
-		'uniform sampler2D u_input;',
-		'uniform float u_transformSize;',
-		'uniform float u_subtransformSize;',
-
-		'varying vec2 vUV;',
-
-		'vec2 multiplyComplex (vec2 a, vec2 b) {',
-		'	return vec2(a[0] * b[0] - a[1] * b[1], a[1] * b[0] + a[0] * b[1]);',
-		'}',
-
-		'void main (void) {',
-		'	#ifdef HORIZONTAL',
-		'	float index = vUV.x * u_transformSize - 0.5;',
-		'	#else',
-		'	float index = vUV.y * u_transformSize - 0.5;',
-		'	#endif',
-
-		'	float evenIndex = floor(index / u_subtransformSize) * (u_subtransformSize * 0.5) + mod(index, u_subtransformSize * 0.5);',
-
-		//transform two complex sequences simultaneously
-		'	#ifdef HORIZONTAL',
-		'	vec4 even = texture2D(u_input, vec2(evenIndex + 0.5, gl_FragCoord.y) / u_transformSize).rgba;',
-		'	vec4 odd = texture2D(u_input, vec2(evenIndex + u_transformSize * 0.5 + 0.5, gl_FragCoord.y) / u_transformSize).rgba;',
-		'	#else',
-		'	vec4 even = texture2D(u_input, vec2(gl_FragCoord.x, evenIndex + 0.5) / u_transformSize).rgba;',
-		'	vec4 odd = texture2D(u_input, vec2(gl_FragCoord.x, evenIndex + u_transformSize * 0.5 + 0.5) / u_transformSize).rgba;',
-		'	#endif',
-
-		'	float twiddleArgument = -2.0 * PI * (index / u_subtransformSize);',
-		'	vec2 twiddle = vec2(cos(twiddleArgument), sin(twiddleArgument));',
-
-		'	vec2 outputA = even.xy + multiplyComplex(twiddle, odd.xy);',
-		'	vec2 outputB = even.zw + multiplyComplex(twiddle, odd.zw);',
-
-		'	gl_FragColor = vec4(outputA, outputB);',
-		'}'
-	].join( '\n' )
-};
-OceanShaders[ 'ocean_initial_spectrum' ] = {
-	uniforms: {
-		'u_wind': { value: new Vector2( 10.0, 10.0 ) },
-		'u_resolution': { value: 512.0 },
-		'u_size': { value: 250.0 }
-	},
-	vertexShader: [
-		'void main (void) {',
-		'	gl_Position = vec4(position, 1.0);',
-		'}'
-	].join( '\n' ),
-	fragmentShader: [
-		'precision highp float;',
-		'#include <common>',
-
-		'const float G = 9.81;',
-		'const float KM = 370.0;',
-		'const float CM = 0.23;',
-
-		'uniform vec2 u_wind;',
-		'uniform float u_resolution;',
-		'uniform float u_size;',
-
-		'float omega (float k) {',
-		'	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;',
-
-		'	float n = (coordinates.x < u_resolution * 0.5) ? coordinates.x : coordinates.x - u_resolution;',
-		'	float m = (coordinates.y < u_resolution * 0.5) ? coordinates.y : coordinates.y - u_resolution;',
-
-		'	vec2 K = (2.0 * PI * vec2(n, m)) / u_size;',
-		'	float k = length(K);',
-
-		'	float l_wind = length(u_wind);',
-
-		'	float Omega = 0.84;',
-		'	float kp = G * pow2(Omega / l_wind);',
-
-		'	float c = omega(k) / k;',
-		'	float cp = omega(kp) / kp;',
-
-		'	float Lpm = exp(-1.25 * pow2(kp / k));',
-		'	float gamma = 1.7;',
-		'	float sigma = 0.08 * (1.0 + 4.0 * pow(Omega, -3.0));',
-		'	float Gamma = exp(-pow2(sqrt(k / kp) - 1.0) / 2.0 * pow2(sigma));',
-		'	float Jp = pow(gamma, Gamma);',
-		'	float Fp = Lpm * Jp * exp(-Omega / sqrt(10.0) * (sqrt(k / kp) - 1.0));',
-		'	float alphap = 0.006 * sqrt(Omega);',
-		'	float Bl = 0.5 * alphap * cp / c * Fp;',
-
-		'	float z0 = 0.000037 * pow2(l_wind) / G * pow(l_wind / cp, 0.9);',
-		'	float uStar = 0.41 * l_wind / log(10.0 / z0);',
-		'	float alpham = 0.01 * ((uStar < CM) ? (1.0 + log(uStar / CM)) : (1.0 + 3.0 * log(uStar / CM)));',
-		'	float Fm = exp(-0.25 * pow2(k / KM - 1.0));',
-		'	float Bh = 0.5 * alpham * CM / c * Fm * Lpm;',
-
-		'	float a0 = log(2.0) / 4.0;',
-		'	float am = 0.13 * uStar / CM;',
-		'	float Delta = tanh(a0 + 4.0 * pow(c / cp, 2.5) + am * pow(CM / c, 2.5));',
-
-		'	float cosPhi = dot(normalize(u_wind), normalize(K));',
-
-		'	float S = (1.0 / (2.0 * PI)) * pow(k, -4.0) * (Bl + Bh) * (1.0 + Delta * (2.0 * cosPhi * cosPhi - 1.0));',
-
-		'	float dk = 2.0 * PI / u_size;',
-		'	float h = sqrt(S / 2.0) * dk;',
-
-		'	if (K.x == 0.0 && K.y == 0.0) {',
-		'		h = 0.0;', //no DC term
-		'	}',
-		'	gl_FragColor = vec4(h, 0.0, 0.0, 0.0);',
-		'}'
-	].join( '\n' )
-};
-OceanShaders[ 'ocean_phase' ] = {
-	uniforms: {
-		'u_phases': { value: null },
-		'u_deltaTime': { value: null },
-		'u_resolution': { value: null },
-		'u_size': { value: null }
-	},
-	fragmentShader: [
-		'precision highp float;',
-		'#include <common>',
-
-		'const float G = 9.81;',
-		'const float KM = 370.0;',
-
-		'varying vec2 vUV;',
-
-		'uniform sampler2D u_phases;',
-		'uniform float u_deltaTime;',
-		'uniform float u_resolution;',
-		'uniform float u_size;',
-
-		'float omega (float k) {',
-		'	return sqrt(G * k * (1.0 + k * k / KM * KM));',
-		'}',
-
-		'void main (void) {',
-		'	float deltaTime = 1.0 / 60.0;',
-		'	vec2 coordinates = gl_FragCoord.xy - 0.5;',
-		'	float n = (coordinates.x < u_resolution * 0.5) ? coordinates.x : coordinates.x - u_resolution;',
-		'	float m = (coordinates.y < u_resolution * 0.5) ? coordinates.y : coordinates.y - u_resolution;',
-		'	vec2 waveVector = (2.0 * PI * vec2(n, m)) / u_size;',
-
-		'	float phase = texture2D(u_phases, vUV).r;',
-		'	float deltaPhase = omega(length(waveVector)) * u_deltaTime;',
-		'	phase = mod(phase + deltaPhase, 2.0 * PI);',
-
-		'	gl_FragColor = vec4(phase, 0.0, 0.0, 0.0);',
-		'}'
-	].join( '\n' )
-};
-OceanShaders[ 'ocean_spectrum' ] = {
-	uniforms: {
-		'u_size': { value: null },
-		'u_resolution': { value: null },
-		'u_choppiness': { value: null },
-		'u_phases': { value: null },
-		'u_initialSpectrum': { value: null }
-	},
-	fragmentShader: [
-		'precision highp float;',
-		'#include <common>',
-
-		'const float G = 9.81;',
-		'const float KM = 370.0;',
-
-		'varying vec2 vUV;',
-
-		'uniform float u_size;',
-		'uniform float u_resolution;',
-		'uniform float u_choppiness;',
-		'uniform sampler2D u_phases;',
-		'uniform sampler2D u_initialSpectrum;',
-
-		'vec2 multiplyComplex (vec2 a, vec2 b) {',
-		'	return vec2(a[0] * b[0] - a[1] * b[1], a[1] * b[0] + a[0] * b[1]);',
-		'}',
-
-		'vec2 multiplyByI (vec2 z) {',
-		'	return vec2(-z[1], z[0]);',
-		'}',
-
-		'float omega (float k) {',
-		'	return sqrt(G * k * (1.0 + k * k / KM * KM));',
-		'}',
-
-		'void main (void) {',
-		'	vec2 coordinates = gl_FragCoord.xy - 0.5;',
-		'	float n = (coordinates.x < u_resolution * 0.5) ? coordinates.x : coordinates.x - u_resolution;',
-		'	float m = (coordinates.y < u_resolution * 0.5) ? coordinates.y : coordinates.y - u_resolution;',
-		'	vec2 waveVector = (2.0 * PI * vec2(n, m)) / u_size;',
-
-		'	float phase = texture2D(u_phases, vUV).r;',
-		'	vec2 phaseVector = vec2(cos(phase), sin(phase));',
-
-		'	vec2 h0 = texture2D(u_initialSpectrum, vUV).rg;',
-		'	vec2 h0Star = texture2D(u_initialSpectrum, vec2(1.0 - vUV + 1.0 / u_resolution)).rg;',
-		'	h0Star.y *= -1.0;',
-
-		'	vec2 h = multiplyComplex(h0, phaseVector) + multiplyComplex(h0Star, vec2(phaseVector.x, -phaseVector.y));',
-
-		'	vec2 hX = -multiplyByI(h * (waveVector.x / length(waveVector))) * u_choppiness;',
-		'	vec2 hZ = -multiplyByI(h * (waveVector.y / length(waveVector))) * u_choppiness;',
-
-		//no DC term
-		'	if (waveVector.x == 0.0 && waveVector.y == 0.0) {',
-		'		h = vec2(0.0);',
-		'		hX = vec2(0.0);',
-		'		hZ = vec2(0.0);',
-		'	}',
-
-		'	gl_FragColor = vec4(hX + multiplyByI(h), hZ);',
-		'}'
-	].join( '\n' )
-};
-OceanShaders[ 'ocean_normals' ] = {
-	uniforms: {
-		'u_displacementMap': { value: null },
-		'u_resolution': { value: null },
-		'u_size': { value: null }
-	},
-	fragmentShader: [
-		'precision highp float;',
-
-		'varying vec2 vUV;',
-
-		'uniform sampler2D u_displacementMap;',
-		'uniform float u_resolution;',
-		'uniform float u_size;',
-
-		'void main (void) {',
-		'	float texel = 1.0 / u_resolution;',
-		'	float texelSize = u_size / u_resolution;',
-
-		'	vec3 center = texture2D(u_displacementMap, vUV).rgb;',
-		'	vec3 right = vec3(texelSize, 0.0, 0.0) + texture2D(u_displacementMap, vUV + vec2(texel, 0.0)).rgb - center;',
-		'	vec3 left = vec3(-texelSize, 0.0, 0.0) + texture2D(u_displacementMap, vUV + vec2(-texel, 0.0)).rgb - center;',
-		'	vec3 top = vec3(0.0, 0.0, -texelSize) + texture2D(u_displacementMap, vUV + vec2(0.0, -texel)).rgb - center;',
-		'	vec3 bottom = vec3(0.0, 0.0, texelSize) + texture2D(u_displacementMap, vUV + vec2(0.0, texel)).rgb - center;',
-
-		'	vec3 topRight = cross(right, top);',
-		'	vec3 topLeft = cross(top, left);',
-		'	vec3 bottomLeft = cross(left, bottom);',
-		'	vec3 bottomRight = cross(bottom, right);',
-
-		'	gl_FragColor = vec4(normalize(topRight + topLeft + bottomLeft + bottomRight), 1.0);',
-		'}'
-	].join( '\n' )
-};
-OceanShaders[ 'ocean_main' ] = {
-	uniforms: {
-		'u_displacementMap': { value: null },
-		'u_normalMap': { value: null },
-		'u_geometrySize': { value: null },
-		'u_size': { value: null },
-		'u_projectionMatrix': { value: null },
-		'u_viewMatrix': { value: null },
-		'u_cameraPosition': { value: null },
-		'u_skyColor': { value: null },
-		'u_oceanColor': { value: null },
-		'u_sunDirection': { value: null },
-		'u_exposure': { value: null }
-	},
-	vertexShader: [
-		'precision highp float;',
-
-		'varying vec3 vPos;',
-		'varying vec2 vUV;',
-
-		'uniform mat4 u_projectionMatrix;',
-		'uniform mat4 u_viewMatrix;',
-		'uniform float u_size;',
-		'uniform float u_geometrySize;',
-		'uniform sampler2D u_displacementMap;',
-
-		'void main (void) {',
-		'	vec3 newPos = position + texture2D(u_displacementMap, uv).rgb * (u_geometrySize / u_size);',
-		'	vPos = newPos;',
-		'	vUV = uv;',
-		'	gl_Position = u_projectionMatrix * u_viewMatrix * vec4(newPos, 1.0);',
-		'}'
-	].join( '\n' ),
-	fragmentShader: [
-		'precision highp float;',
-
-		'varying vec3 vPos;',
-		'varying vec2 vUV;',
-
-		'uniform sampler2D u_displacementMap;',
-		'uniform sampler2D u_normalMap;',
-		'uniform vec3 u_cameraPosition;',
-		'uniform vec3 u_oceanColor;',
-		'uniform vec3 u_skyColor;',
-		'uniform vec3 u_sunDirection;',
-		'uniform float u_exposure;',
-
-		'vec3 hdr (vec3 color, float exposure) {',
-		'	return 1.0 - exp(-color * exposure);',
-		'}',
-
-		'void main (void) {',
-		'	vec3 normal = texture2D(u_normalMap, vUV).rgb;',
-
-		'	vec3 view = normalize(u_cameraPosition - vPos);',
-		'	float fresnel = 0.02 + 0.98 * pow(1.0 - dot(normal, view), 5.0);',
-		'	vec3 sky = fresnel * u_skyColor;',
-
-		'	float diffuse = clamp(dot(normal, normalize(u_sunDirection)), 0.0, 1.0);',
-		'	vec3 water = (1.0 - fresnel) * u_oceanColor * u_skyColor * diffuse;',
-
-		'	vec3 color = sky + water;',
-
-		'	gl_FragColor = vec4(hdr(color, u_exposure), 1.0);',
-		'}'
-	].join( '\n' )
-};
-
-export { OceanShaders };

BIN
examples/screenshots/webgl_lights_pointlights2.jpg


BIN
examples/screenshots/webgl_shaders_ocean2.jpg


+ 0 - 1
examples/tags.json

@@ -61,7 +61,6 @@
 	"webgl_refraction": [ "water" ],
 	"webgl_rtt": [ "renderTarget", "texture" ],
 	"webgl_shaders_ocean": [ "water" ],
-	"webgl_shaders_ocean2": [ "water" ],
 	"webgl_shaders_sky": [ "sun" ],
 	"webgl_shaders_tonemapping": [ "hrd" ],
 	"webgl_shading_physical": [ "pbr" ],

+ 0 - 214
examples/webgl_lights_pointlights2.html

@@ -1,214 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-	<head>
-		<title>three.js webgl - lights - point lights</title>
-		<meta charset="utf-8">
-		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
-		<link type="text/css" rel="stylesheet" href="main.css">
-	</head>
-	<body>
-
-		<div id="container"></div>
-		<div id="info">
-			<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> - point lights WebGL demo
-		</div>
-
-		<script type="module">
-
-			import * as THREE from '../build/three.module.js';
-
-			import Stats from './jsm/libs/stats.module.js';
-
-			import { TrackballControls } from './jsm/controls/TrackballControls.js';
-
-			let camera, scene, renderer, controls;
-			let light1, light2, light3, light4, light5, light6;
-
-			const clock = new THREE.Clock();
-
-			let stats;
-
-			init();
-			animate();
-
-			function init() {
-
-				const container = document.getElementById( 'container' );
-
-				// CAMERA
-
-				camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 1, 300 );
-				camera.position.set( 0, 15, 150 );
-				camera.lookAt( 0, 0, 0 );
-
-				// SCENE
-
-				scene = new THREE.Scene();
-				scene.background = new THREE.Color( 0x040306 );
-				scene.fog = new THREE.Fog( 0x040306, 10, 300 );
-
-				// TEXTURES
-
-				const textureLoader = new THREE.TextureLoader();
-
-				const texture = textureLoader.load( "textures/disturb.jpg" );
-				texture.repeat.set( 20, 10 );
-				texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
-				texture.encoding = THREE.sRGBEncoding;
-
-				// MATERIALS
-
-				const groundMaterial = new THREE.MeshPhongMaterial( { color: 0xffffff, map: texture } );
-				const objectMaterial = new THREE.MeshStandardMaterial( { color: 0xffffff, roughness: 0.5, metalness: 1.0 } );
-
-				// GROUND
-
-				const mesh = new THREE.Mesh( new THREE.PlaneGeometry( 800, 400, 2, 2 ), groundMaterial );
-				mesh.position.y = - 5;
-				mesh.rotation.x = - Math.PI / 2;
-				scene.add( mesh );
-
-				// OBJECTS
-
-				const objectGeometry = new THREE.TorusGeometry( 1.5, 0.4, 8, 16 );
-
-				for ( let i = 0; i < 5000; i ++ ) {
-
-					const mesh = new THREE.Mesh( objectGeometry, objectMaterial );
-
-					mesh.position.x = 400 * ( 0.5 - Math.random() );
-					mesh.position.y = 50 * ( 0.5 - Math.random() ) + 25;
-					mesh.position.z = 200 * ( 0.5 - Math.random() );
-
-					mesh.rotation.y = 3.14 * ( 0.5 - Math.random() );
-					mesh.rotation.x = 3.14 * ( 0.5 - Math.random() );
-
-					mesh.matrixAutoUpdate = false;
-					mesh.updateMatrix();
-					scene.add( mesh );
-
-				}
-
-				// LIGHTS
-
-				const intensity = 2.5;
-				const distance = 100;
-				const decay = 2.0;
-
-				const c1 = 0xff0040, c2 = 0x0040ff, c3 = 0x80ff80, c4 = 0xffaa00, c5 = 0x00ffaa, c6 = 0xff1100;
-
-				const sphere = new THREE.SphereGeometry( 0.25, 16, 8 );
-
-				light1 = new THREE.PointLight( c1, intensity, distance, decay );
-				light1.add( new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: c1 } ) ) );
-				scene.add( light1 );
-
-				light2 = new THREE.PointLight( c2, intensity, distance, decay );
-				light2.add( new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: c2 } ) ) );
-				scene.add( light2 );
-
-				light3 = new THREE.PointLight( c3, intensity, distance, decay );
-				light3.add( new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: c3 } ) ) );
-				scene.add( light3 );
-
-				light4 = new THREE.PointLight( c4, intensity, distance, decay );
-				light4.add( new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: c4 } ) ) );
-				scene.add( light4 );
-
-				light5 = new THREE.PointLight( c5, intensity, distance, decay );
-				light5.add( new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: c5 } ) ) );
-				scene.add( light5 );
-
-				light6 = new THREE.PointLight( c6, intensity, distance, decay );
-				light6.add( new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: c6 } ) ) );
-				scene.add( light6 );
-
-				const dlight = new THREE.DirectionalLight( 0xffffff, 0.05 );
-				dlight.position.set( 0.5, 1, 0 ).normalize();
-				scene.add( dlight );
-
-				// RENDERER
-
-				renderer = new THREE.WebGLRenderer( { antialias: true } );
-				renderer.setPixelRatio( window.devicePixelRatio );
-				renderer.setSize( window.innerWidth, window.innerHeight );
-				container.appendChild( renderer.domElement );
-				renderer.outputEncoding = THREE.sRGBEncoding;
-
-				// CONTROLS
-
-				controls = new TrackballControls( camera, renderer.domElement );
-
-				controls.rotateSpeed = 1.0;
-				controls.zoomSpeed = 1.2;
-				controls.panSpeed = 0.8;
-
-				controls.dynamicDampingFactor = 0.15;
-
-				controls.keys = [ 65, 83, 68 ];
-
-				// STATS
-
-				stats = new Stats();
-				container.appendChild( stats.dom );
-
-				//
-
-				window.addEventListener( 'resize', onWindowResize );
-
-			}
-
-			function onWindowResize() {
-
-				camera.aspect = window.innerWidth / window.innerHeight;
-				camera.updateProjectionMatrix();
-
-				renderer.setSize( window.innerWidth, window.innerHeight );
-
-				controls.handleResize();
-
-			}
-
-			//
-
-			function animate() {
-
-				requestAnimationFrame( animate );
-
-				render();
-				stats.update();
-
-			}
-
-			function render() {
-
-				const time = Date.now() * 0.00025;
-				const d = 150;
-
-				light1.position.x = Math.sin( time * 0.7 ) * d;
-				light1.position.z = Math.cos( time * 0.3 ) * d;
-
-				light2.position.x = Math.cos( time * 0.3 ) * d;
-				light2.position.z = Math.sin( time * 0.7 ) * d;
-
-				light3.position.x = Math.sin( time * 0.7 ) * d;
-				light3.position.z = Math.sin( time * 0.5 ) * d;
-
-				light4.position.x = Math.sin( time * 0.3 ) * d;
-				light4.position.z = Math.sin( time * 0.5 ) * d;
-
-				light5.position.x = Math.cos( time * 0.3 ) * d;
-				light5.position.z = Math.sin( time * 0.5 ) * d;
-
-				light6.position.x = Math.cos( time * 0.7 ) * d;
-				light6.position.z = Math.cos( time * 0.5 ) * d;
-
-				controls.update( clock.getDelta() );
-
-				renderer.render( scene, camera );
-
-			}
-
-		</script>
-	</body>
-</html>

+ 0 - 208
examples/webgl_shaders_ocean2.html

@@ -1,208 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-	<head>
-		<meta charset="utf-8" />
-		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
-		<link type="text/css" rel="stylesheet" href="main.css">
-	</head>
-	<body>
-		<div id="info">
-			<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> - webgl ocean simulation
-		</div>
-
-		<script type="module">
-
-			import * as THREE from '../build/three.module.js';
-
-			import Stats from './jsm/libs/stats.module.js';
-
-			import { GUI } from './jsm/libs/dat.gui.module.js';
-			import { OrbitControls } from './jsm/controls/OrbitControls.js';
-			import { Ocean } from './jsm/misc/Ocean.js';
-
-			const stats = new Stats();
-			document.body.appendChild( stats.dom );
-
-			let lastTime = ( new Date() ).getTime();
-
-			const DEMO = {
-				ms_Renderer: null,
-				ms_Camera: null,
-				ms_Scene: null,
-				ms_Controls: null,
-				ms_Ocean: null,
-
-				Initialize: function () {
-
-					this.ms_Renderer = new THREE.WebGLRenderer();
-					this.ms_Renderer.setPixelRatio( window.devicePixelRatio );
-					document.body.appendChild( this.ms_Renderer.domElement );
-
-					this.ms_Scene = new THREE.Scene();
-
-					this.ms_Camera = new THREE.PerspectiveCamera( 55.0, window.innerWidth / window.innerHeight, 0.5, 300000 );
-					this.ms_Camera.position.set( 450, 350, 450 );
-					this.ms_Camera.lookAt( 0, 0, 0 );
-
-					// Initialize Orbit control
-					this.ms_Controls = new OrbitControls( this.ms_Camera, this.ms_Renderer.domElement );
-					this.ms_Controls.userPan = false;
-					this.ms_Controls.userPanSpeed = 0.0;
-					this.ms_Controls.minDistance = 0;
-					this.ms_Controls.maxDistance = 2000.0;
-					this.ms_Controls.minPolarAngle = 0;
-					this.ms_Controls.maxPolarAngle = Math.PI * 0.495;
-
-					const gsize = 512;
-					const res = 1024;
-					const gres = res / 2;
-					const origx = - gsize / 2;
-					const origz = - gsize / 2;
-					this.ms_Ocean = new Ocean( this.ms_Renderer, this.ms_Camera, this.ms_Scene,
-						{
-							USE_HALF_FLOAT: false,
-							INITIAL_SIZE: 256.0,
-							INITIAL_WIND: [ 10.0, 10.0 ],
-							INITIAL_CHOPPINESS: 1.5,
-							CLEAR_COLOR: [ 1.0, 1.0, 1.0, 0.0 ],
-							GEOMETRY_ORIGIN: [ origx, origz ],
-							SUN_DIRECTION: [ - 1.0, 1.0, 1.0 ],
-							OCEAN_COLOR: new THREE.Vector3( 0.004, 0.016, 0.047 ),
-							SKY_COLOR: new THREE.Vector3( 3.2, 9.6, 12.8 ),
-							EXPOSURE: 0.35,
-							GEOMETRY_RESOLUTION: gres,
-							GEOMETRY_SIZE: gsize,
-							RESOLUTION: res
-						} );
-
-					this.ms_Ocean.materialOcean.uniforms[ "u_projectionMatrix" ] = { value: this.ms_Camera.projectionMatrix };
-					this.ms_Ocean.materialOcean.uniforms[ "u_viewMatrix" ] = { value: this.ms_Camera.matrixWorldInverse };
-					this.ms_Ocean.materialOcean.uniforms[ "u_cameraPosition" ] = { value: this.ms_Camera.position };
-					this.ms_Scene.add( this.ms_Ocean.oceanMesh );
-
-					const gui = new GUI();
-					gui.add( this.ms_Ocean, "size", 100, 5000 ).onChange( function ( v ) {
-
-						this.object.size = v;
-						this.object.changed = true;
-
-					} );
-
-					gui.add( this.ms_Ocean, "choppiness", 0.1, 4 ).onChange( function ( v ) {
-
-						this.object.choppiness = v;
-						this.object.changed = true;
-
-					} );
-
-					gui.add( this.ms_Ocean, "windX", - 15, 15 ).onChange( function ( v ) {
-
-						this.object.windX = v;
-						this.object.changed = true;
-
-					} );
-
-					gui.add( this.ms_Ocean, "windY", - 15, 15 ).onChange( function ( v ) {
-
-						this.object.windY = v;
-						this.object.changed = true;
-
-					} );
-
-					gui.add( this.ms_Ocean, "sunDirectionX", - 1.0, 1.0 ).onChange( function ( v ) {
-
-						this.object.sunDirectionX = v;
-						this.object.changed = true;
-
-					} );
-
-					gui.add( this.ms_Ocean, "sunDirectionY", - 1.0, 1.0 ).onChange( function ( v ) {
-
-						this.object.sunDirectionY = v;
-						this.object.changed = true;
-
-					} );
-
-					gui.add( this.ms_Ocean, "sunDirectionZ", - 1.0, 1.0 ).onChange( function ( v ) {
-
-						this.object.sunDirectionZ = v;
-						this.object.changed = true;
-
-					} );
-
-					gui.add( this.ms_Ocean, "exposure", 0.0, 0.5 ).onChange( function ( v ) {
-
-						this.object.exposure = v;
-						this.object.changed = true;
-
-					} );
-
-				},
-
-				Display: function () {
-
-					this.ms_Renderer.render( this.ms_Scene, this.ms_Camera );
-
-				},
-
-				Update: function () {
-
-					const currentTime = new Date().getTime();
-					this.ms_Ocean.deltaTime = ( currentTime - lastTime ) / 1000 || 0.0;
-					lastTime = currentTime;
-					this.ms_Ocean.render( this.ms_Ocean.deltaTime );
-					this.ms_Ocean.overrideMaterial = this.ms_Ocean.materialOcean;
-
-					if ( this.ms_Ocean.changed ) {
-
-						this.ms_Ocean.materialOcean.uniforms[ "u_size" ].value = this.ms_Ocean.size;
-						this.ms_Ocean.materialOcean.uniforms[ "u_sunDirection" ].value.set( this.ms_Ocean.sunDirectionX, this.ms_Ocean.sunDirectionY, this.ms_Ocean.sunDirectionZ );
-						this.ms_Ocean.materialOcean.uniforms[ "u_exposure" ].value = this.ms_Ocean.exposure;
-						this.ms_Ocean.changed = false;
-
-					}
-
-					this.ms_Ocean.materialOcean.uniforms[ "u_normalMap" ].value = this.ms_Ocean.normalMapFramebuffer.texture;
-					this.ms_Ocean.materialOcean.uniforms[ "u_displacementMap" ].value = this.ms_Ocean.displacementMapFramebuffer.texture;
-					this.ms_Ocean.materialOcean.uniforms[ "u_projectionMatrix" ].value = this.ms_Camera.projectionMatrix;
-					this.ms_Ocean.materialOcean.uniforms[ "u_viewMatrix" ].value = this.ms_Camera.matrixWorldInverse;
-					this.ms_Ocean.materialOcean.uniforms[ "u_cameraPosition" ].value = this.ms_Camera.position;
-					this.ms_Ocean.materialOcean.depthTest = true;
-					this.Display();
-
-				},
-
-				Resize: function ( inWidth, inHeight ) {
-
-					this.ms_Camera.aspect = inWidth / inHeight;
-					this.ms_Camera.updateProjectionMatrix();
-					this.ms_Renderer.setSize( inWidth, inHeight );
-					this.Display();
-
-				}
-
-			};
-
-			DEMO.Initialize();
-
-			window.addEventListener( 'resize', function () {
-
-				DEMO.Resize( window.innerWidth, window.innerHeight );
-
-			} );
-
-			DEMO.Resize( window.innerWidth, window.innerHeight );
-
-			function render() {
-
-				requestAnimationFrame( render );
-				DEMO.Update();
-				stats.update();
-
-			}
-
-			render();
-
-		</script>
-	</body>
-</html>

+ 0 - 1
utils/modularize.js

@@ -113,7 +113,6 @@ var files = [
 	{ path: 'misc/MD2CharacterComplex.js', dependencies: [ { name: 'MD2Loader', path: 'loaders/MD2Loader.js' }, { name: 'MorphBlendMesh', path: 'misc/MorphBlendMesh.js' } ], ignoreList: [] },
 	{ path: 'misc/MorphAnimMesh.js', dependencies: [], ignoreList: [] },
 	{ path: 'misc/MorphBlendMesh.js', dependencies: [], ignoreList: [] },
-	{ path: 'misc/Ocean.js', dependencies: [ { name: 'OceanShaders', path: 'shaders/OceanShaders.js' } ], ignoreList: [] },
 	{ path: 'misc/RollerCoaster.js', dependencies: [], ignoreList: [] },
 	{ path: 'misc/Volume.js', dependencies: [ { name: 'VolumeSlice', path: 'misc/VolumeSlice.js' } ], ignoreList: [] },
 	{ path: 'misc/VolumeSlice.js', dependencies: [], ignoreList: [] },