Skip to content
This repository
Browse code

more work

  • Loading branch information...
commit 6ff8571fac11528fb9b93a142dd52b327c014b5c 1 parent 2b27bf6
Jerome Etienne authored July 06, 2012
6  build/tquery-bundle.js
@@ -1849,7 +1849,7 @@ fragmentShader:"precision mediump float;\nuniform vec3 color;\nuniform sampler2D
1849 1849
 */
1850 1850
 var tQuery	= function(object, root)
1851 1851
 {
1852  
-	// support for tQuery(tGeometry, tMaterial)
  1852
+	// support for tQuery(geometry, material)
1853 1853
 	if( arguments.length === 2 && 
1854 1854
 			(arguments[0] instanceof THREE.Geometry || arguments[0] instanceof tQuery.Geometry)
1855 1855
 			&& 
@@ -4022,6 +4022,10 @@ tQuery.World.register('pageTitle', function(element){
4022 4022
 	element.style.position	= "absolute";
4023 4023
 	element.style.width	= "100%";
4024 4024
 	element.style.textAlign	= "center";
  4025
+	element.style.textAlign	= "center";
  4026
+	element.style.fontWeight= "bolder";
  4027
+	element.style.fontSize	= "120%";
  4028
+	element.style.fontFamily= "arial";
4025 4029
 	// for chained API
4026 4030
 	return this;
4027 4031
 });
2  build/tquery.js
@@ -14,7 +14,7 @@
14 14
 */
15 15
 var tQuery	= function(object, root)
16 16
 {
17  
-	// support for tQuery(tGeometry, tMaterial)
  17
+	// support for tQuery(geometry, material)
18 18
 	if( arguments.length === 2 && 
19 19
 			(arguments[0] instanceof THREE.Geometry || arguments[0] instanceof tQuery.Geometry)
20 20
 			&& 
4  plugins/boilerplate/tquery.world.boilerplate.js
@@ -34,6 +34,10 @@ tQuery.World.register('pageTitle', function(element){
34 34
 	element.style.position	= "absolute";
35 35
 	element.style.width	= "100%";
36 36
 	element.style.textAlign	= "center";
  37
+	element.style.textAlign	= "center";
  38
+	element.style.fontWeight= "bolder";
  39
+	element.style.fontSize	= "120%";
  40
+	element.style.fontFamily= "arial";
37 41
 	// for chained API
38 42
 	return this;
39 43
 });
246  plugins/lavamaterial/tquery.lavamaterial.js
@@ -9,10 +9,18 @@ tQuery.Object3D.register('useLavaMaterial', function(scale){
9 9
 
10 10
 	this.each(function(object3d){
11 11
 		var uniforms	= {
12  
-			time	: { type: "f", value: 1.0 },
13  
-			scale	: { type: "f", value: scale }
  12
+			fogDensity	: { type: "f", value: 0.45 },
  13
+			fogColor	: { type: "v3", value: new THREE.Vector3( 0, 0, 0 ) },
  14
+			time		: { type: "f", value: 1.0 },
  15
+			resolution	: { type: "v2", value: new THREE.Vector2( window.innerWidth, window.innerHeight ) },
  16
+			uvScale		: { type: "v2", value: new THREE.Vector2( 3.0, 1.0 ) },
  17
+			texture1	: { type: "t", value: 0, texture: THREE.ImageUtils.loadTexture( "../images/cloud.png" ) },
  18
+			texture2	: { type: "t", value: 1, texture: THREE.ImageUtils.loadTexture( "../images/lavatile.jpg" ) }
14 19
 		};
15 20
 		
  21
+		uniforms.texture1.texture.wrapS = uniforms.texture1.texture.wrapT = THREE.RepeatWrapping;
  22
+		uniforms.texture2.texture.wrapS = uniforms.texture2.texture.wrapT = THREE.RepeatWrapping;
  23
+		
16 24
 		var material	= new THREE.ShaderMaterial({
17 25
 			uniforms	: uniforms,
18 26
 			vertexShader	: tQuery.Object3D.prototype.useLavaMaterial._vertexShaderText,
@@ -22,7 +30,7 @@ tQuery.Object3D.register('useLavaMaterial', function(scale){
22 30
 		object3d.material	= material;
23 31
 		
24 32
 		tQuery.world.loop().hook(function(delta, now){
25  
-			uniforms.time.value += 0.275 * delta;
  33
+			uniforms.time.value += 0.2 * 10 * delta;
26 34
 		});
27 35
 	});
28 36
 	// for chained API
@@ -31,192 +39,62 @@ tQuery.Object3D.register('useLavaMaterial', function(scale){
31 39
 
32 40
 // converted by document.getElementById( 'vertexShader' ).textContent.split('\n').map(function(line){ return "\'"+line+"\',"; }).join('\n');
33 41
 tQuery.Object3D.prototype.useLavaMaterial._vertexShaderText = [
34  
-'		uniform float time;',
35  
-'		uniform float scale;',
36  
-'',
37  
-'		varying vec3 vTexCoord3D;',
38  
-'		varying vec3 vNormal;',
39  
-'		varying vec3 vViewPosition;',
40  
-'',
41  
-'		void main( void ) {',
  42
+'	uniform vec2 uvScale;',
  43
+'	varying vec2 vUv;',
42 44
 '',
43  
-'			vec4 mPosition = objectMatrix * vec4( position, 1.0 );',
44  
-'			vNormal = normalize( normalMatrix * normal );',
45  
-'			vViewPosition = cameraPosition - mPosition.xyz;',
  45
+'	void main()',
  46
+'	{',
46 47
 '',
47  
-'			vTexCoord3D = scale * ( position.xyz + vec3( 0.0, 0.0, -time ) );',
48  
-'			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',
  48
+'		vUv		= uvScale * uv;',
  49
+'		vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );',
  50
+'		gl_Position	= projectionMatrix * mvPosition;',
49 51
 '',
50  
-'		}',
51  
-'',
52  
-'	'	
  52
+'	}'
53 53
 ].join('\n');
54 54
 
55 55
 // converted by document.getElementById( 'fragmentShader' ).textContent.split('\n').map(function(line){ return "\""+line+"\","; }).join('\n');
56 56
 tQuery.Object3D.prototype.useLavaMaterial._fragmentShaderText = [
57  
-"",
58  
-"",
59  
-"		//",
60  
-"		// Description : Array and textureless GLSL 3D simplex noise function.",
61  
-"		//      Author : Ian McEwan, Ashima Arts.",
62  
-"		//  Maintainer : ijm",
63  
-"		//     Lastmod : 20110409 (stegu)",
64  
-"		//     License : Copyright (C) 2011 Ashima Arts. All rights reserved.",
65  
-"		//               Distributed under the MIT License. See LICENSE file.",
66  
-"		//",
67  
-"",
68  
-"		uniform float time;",
69  
-"",
70  
-"		varying vec3 vTexCoord3D;",
71  
-"		varying vec3 vNormal;",
72  
-"		varying vec3 vViewPosition;",
73  
-"",
74  
-"		vec4 permute( vec4 x ) {",
75  
-"",
76  
-"			return mod( ( ( x * 34.0 ) + 1.0 ) * x, 289.0 );",
77  
-"",
78  
-"		}",
79  
-"",
80  
-"		vec4 taylorInvSqrt( vec4 r ) {",
81  
-"",
82  
-"			return 1.79284291400159 - 0.85373472095314 * r;",
83  
-"",
84  
-"		}",
85  
-"",
86  
-"		float snoise( vec3 v ) {",
87  
-"",
88  
-"			const vec2 C = vec2( 1.0 / 6.0, 1.0 / 3.0 );",
89  
-"			const vec4 D = vec4( 0.0, 0.5, 1.0, 2.0 );",
90  
-"",
91  
-"			// First corner",
92  
-"",
93  
-"			vec3 i  = floor( v + dot( v, C.yyy ) );",
94  
-"			vec3 x0 = v - i + dot( i, C.xxx );",
95  
-"",
96  
-"			// Other corners",
97  
-"",
98  
-"			vec3 g = step( x0.yzx, x0.xyz );",
99  
-"			vec3 l = 1.0 - g;",
100  
-"			vec3 i1 = min( g.xyz, l.zxy );",
101  
-"			vec3 i2 = max( g.xyz, l.zxy );",
102  
-"",
103  
-"			//  x0 = x0 - 0. + 0.0 * C",
104  
-"			vec3 x1 = x0 - i1 + 1.0 * C.xxx;",
105  
-"			vec3 x2 = x0 - i2 + 2.0 * C.xxx;",
106  
-"			vec3 x3 = x0 - 1. + 3.0 * C.xxx;",
107  
-"",
108  
-"			// Permutations",
109  
-"",
110  
-"			i = mod( i, 289.0 );",
111  
-"			vec4 p = permute( permute( permute(",
112  
-"					 i.z + vec4( 0.0, i1.z, i2.z, 1.0 ) )",
113  
-"				   + i.y + vec4( 0.0, i1.y, i2.y, 1.0 ) )",
114  
-"				   + i.x + vec4( 0.0, i1.x, i2.x, 1.0 ) );",
115  
-"",
116  
-"			// Gradients",
117  
-"			// ( N*N points uniformly over a square, mapped onto an octahedron.)",
118  
-"",
119  
-"			float n_ = 1.0 / 7.0; // N=7",
120  
-"",
121  
-"			vec3 ns = n_ * D.wyz - D.xzx;",
122  
-"",
123  
-"			vec4 j = p - 49.0 * floor( p * ns.z *ns.z );  //  mod(p,N*N)",
124  
-"",
125  
-"			vec4 x_ = floor( j * ns.z );",
126  
-"			vec4 y_ = floor( j - 7.0 * x_ );    // mod(j,N)",
127  
-"",
128  
-"			vec4 x = x_ *ns.x + ns.yyyy;",
129  
-"			vec4 y = y_ *ns.x + ns.yyyy;",
130  
-"			vec4 h = 1.0 - abs( x ) - abs( y );",
131  
-"",
132  
-"			vec4 b0 = vec4( x.xy, y.xy );",
133  
-"			vec4 b1 = vec4( x.zw, y.zw );",
134  
-"",
135  
-"			vec4 s0 = floor( b0 ) * 2.0 + 1.0;",
136  
-"			vec4 s1 = floor( b1 ) * 2.0 + 1.0;",
137  
-"			vec4 sh = -step( h, vec4( 0.0 ) );",
138  
-"",
139  
-"			vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;",
140  
-"			vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;",
141  
-"",
142  
-"			vec3 p0 = vec3( a0.xy, h.x );",
143  
-"			vec3 p1 = vec3( a0.zw, h.y );",
144  
-"			vec3 p2 = vec3( a1.xy, h.z );",
145  
-"			vec3 p3 = vec3( a1.zw, h.w );",
146  
-"",
147  
-"			// Normalise gradients",
148  
-"",
149  
-"			vec4 norm = taylorInvSqrt( vec4( dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3) ) );",
150  
-"			p0 *= norm.x;",
151  
-"			p1 *= norm.y;",
152  
-"			p2 *= norm.z;",
153  
-"			p3 *= norm.w;",
154  
-"",
155  
-"			// Mix final noise value",
156  
-"",
157  
-"			vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3) ), 0.0 );",
158  
-"			m = m * m;",
159  
-"			return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),",
160  
-"										dot(p2,x2), dot(p3,x3) ) );",
161  
-"",
162  
-"		}",
163  
-"",
164  
-"		float heightMap( vec3 coord ) {",
165  
-"",
166  
-"			float n = abs( snoise( coord ) );",
167  
-"",
168  
-"			n += 0.25   * abs( snoise( coord * 2.0 ) );",
169  
-"			n += 0.25   * abs( snoise( coord * 4.0 ) );",
170  
-"			n += 0.125  * abs( snoise( coord * 8.0 ) );",
171  
-"			n += 0.0625 * abs( snoise( coord * 16.0 ) );",
172  
-"",
173  
-"			return n;",
174  
-"",
175  
-"		}",
176  
-"",
177  
-"		void main( void ) {",
178  
-"",
179  
-"			// height",
180  
-"",
181  
-"			float n = heightMap( vTexCoord3D );",
182  
-"",
183  
-"			// color",
184  
-"",
185  
-"			gl_FragColor = vec4( vec3( 1.5 - n, 1.0 - n, 0.5 - n ), 1.0 );",
186  
-"",
187  
-"			// normal",
188  
-"",
189  
-"			const float e = 0.001;",
190  
-"",
191  
-"			float nx = heightMap( vTexCoord3D + vec3( e, 0.0, 0.0 ) );",
192  
-"			float ny = heightMap( vTexCoord3D + vec3( 0.0, e, 0.0 ) );",
193  
-"			float nz = heightMap( vTexCoord3D + vec3( 0.0, 0.0, e ) );",
194  
-"",
195  
-"			vec3 normal = normalize( vNormal + 0.05 * vec3( n - nx, n - ny, n - nz ) / e );",
196  
-"",
197  
-"			// diffuse light",
198  
-"",
199  
-"			vec3 vLightWeighting = vec3( 0.1 );",
200  
-"",
201  
-"			vec4 lDirection = viewMatrix * vec4( normalize( vec3( 1.0, 0.0, 0.5 ) ), 0.0 );",
202  
-"			float directionalLightWeighting = dot( normal, normalize( lDirection.xyz ) ) * 0.25 + 0.75;",
203  
-"			vLightWeighting += vec3( 1.0 ) * directionalLightWeighting;",
204  
-"",
205  
-"			// specular light",
206  
-"",
207  
-"			vec3 dirHalfVector = normalize( lDirection.xyz + normalize( vViewPosition ) );",
208  
-"",
209  
-"			float dirDotNormalHalf = dot( normal, dirHalfVector );",
210  
-"",
211  
-"			float dirSpecularWeight = 0.0;",
212  
-"			if ( dirDotNormalHalf >= 0.0 )",
213  
-"				dirSpecularWeight = ( 1.0 - n ) * pow( dirDotNormalHalf, 5.0 );",
214  
-"",
215  
-"			vLightWeighting += vec3( 1.0, 0.5, 0.0 ) * dirSpecularWeight * n * 2.0;",
216  
-"",
217  
-"			gl_FragColor *= vec4( vLightWeighting, 1.0 );",
218  
-"",
219  
-"		}",
220  
-"",
221  
-"	"
  57
+'	uniform float time;',
  58
+'	uniform vec2 resolution;',
  59
+'',
  60
+'	uniform float fogDensity;',
  61
+'	uniform vec3 fogColor;',
  62
+'',
  63
+'	uniform sampler2D texture1;',
  64
+'	uniform sampler2D texture2;',
  65
+'',
  66
+'	varying vec2 vUv;',
  67
+'',
  68
+'	void main( void ) {',
  69
+'',
  70
+'		vec2 position = -1.0 + 2.0 * vUv;',
  71
+'',
  72
+'		vec4 noise = texture2D( texture1, vUv );',
  73
+'		vec2 T1 = vUv + vec2( 1.5, -1.5 ) * time  *0.02;',
  74
+'		vec2 T2 = vUv + vec2( -0.5, 2.0 ) * time * 0.01;',
  75
+'',
  76
+'		T1.x += noise.x * 2.0;',
  77
+'		T1.y += noise.y * 2.0;',
  78
+'		T2.x -= noise.y * 0.2;',
  79
+'		T2.y += noise.z * 0.2;',
  80
+'',
  81
+'		float p = texture2D( texture1, T1 * 2.0 ).a;',
  82
+'',
  83
+'		vec4 color = texture2D( texture2, T2 * 2.0 );',
  84
+'		vec4 temp = color * ( vec4( p, p, p, p ) * 2.0 ) + ( color * color - 0.1 );',
  85
+'',
  86
+'		if( temp.r > 1.0 ){ temp.bg += clamp( temp.r - 2.0, 0.0, 100.0 ); }',
  87
+'		if( temp.g > 1.0 ){ temp.rb += temp.g - 1.0; }',
  88
+'		if( temp.b > 1.0 ){ temp.rg += temp.b - 1.0; }',
  89
+'',
  90
+'		gl_FragColor = temp;',
  91
+'',
  92
+'		float depth = gl_FragCoord.z / gl_FragCoord.w;',
  93
+'		const float LOG2 = 1.442695;',
  94
+'		float fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );',
  95
+'		fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );',
  96
+'',
  97
+'		gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );',
  98
+'',
  99
+'	}'
222 100
 ].join('\n');

0 notes on commit 6ff8571

Please sign in to comment.
Something went wrong with that request. Please try again.