diff options
-rw-r--r-- | assets/shaders/Deform.frag.glsl | 3 | ||||
-rw-r--r-- | assets/shaders/Fly.frag.glsl | 5 | ||||
-rw-r--r-- | assets/shaders/Julia.frag.glsl | 3 | ||||
-rw-r--r-- | assets/shaders/Keleidoscope.frag.glsl | 8 | ||||
-rwxr-xr-x | js/lib/rdge/materials/bump-metal-material.js | 187 | ||||
-rw-r--r-- | js/lib/rdge/materials/deform-material.js | 21 | ||||
-rw-r--r-- | js/lib/rdge/materials/flag-material.js | 110 | ||||
-rwxr-xr-x | js/lib/rdge/materials/flat-material.js | 113 | ||||
-rw-r--r-- | js/lib/rdge/materials/fly-material.js | 38 | ||||
-rw-r--r-- | js/lib/rdge/materials/julia-material.js | 52 | ||||
-rw-r--r-- | js/lib/rdge/materials/keleidoscope-material.js | 52 | ||||
-rwxr-xr-x | js/lib/rdge/materials/linear-gradient-material.js | 252 | ||||
-rw-r--r-- | js/lib/rdge/materials/pulse-material.js | 4 | ||||
-rw-r--r-- | js/lib/rdge/materials/water-material.js | 387 |
14 files changed, 222 insertions, 1013 deletions
diff --git a/assets/shaders/Deform.frag.glsl b/assets/shaders/Deform.frag.glsl index 1dbe45a0..a2bb4fa0 100644 --- a/assets/shaders/Deform.frag.glsl +++ b/assets/shaders/Deform.frag.glsl | |||
@@ -3,6 +3,7 @@ precision highp float; | |||
3 | #endif | 3 | #endif |
4 | 4 | ||
5 | uniform float u_time; | 5 | uniform float u_time; |
6 | uniform float u_speed; | ||
6 | uniform vec2 u_resolution; | 7 | uniform vec2 u_resolution; |
7 | //uniform vec4 mouse; | 8 | //uniform vec4 mouse; |
8 | uniform sampler2D u_tex0; | 9 | uniform sampler2D u_tex0; |
@@ -19,7 +20,7 @@ void main(void) | |||
19 | float r2 = sqrt(dot(p+m,p+m)); | 20 | float r2 = sqrt(dot(p+m,p+m)); |
20 | 21 | ||
21 | vec2 uv; | 22 | vec2 uv; |
22 | uv.x = 0.2*u_time + (r1-r2)*0.25; | 23 | uv.x = 0.2*u_time*u_speed + (r1-r2)*0.25; |
23 | uv.y = sin(2.0*(a1-a2)); | 24 | uv.y = sin(2.0*(a1-a2)); |
24 | 25 | ||
25 | float w = r1*r2*0.8; | 26 | float w = r1*r2*0.8; |
diff --git a/assets/shaders/Fly.frag.glsl b/assets/shaders/Fly.frag.glsl index f99b5ab8..d36928a1 100644 --- a/assets/shaders/Fly.frag.glsl +++ b/assets/shaders/Fly.frag.glsl | |||
@@ -4,6 +4,7 @@ precision highp float; | |||
4 | 4 | ||
5 | uniform vec2 u_resolution; | 5 | uniform vec2 u_resolution; |
6 | uniform float u_time; | 6 | uniform float u_time; |
7 | uniform float u_speed; | ||
7 | uniform sampler2D u_tex0; | 8 | uniform sampler2D u_tex0; |
8 | 9 | ||
9 | void main(void) | 10 | void main(void) |
@@ -11,13 +12,13 @@ void main(void) | |||
11 | vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; | 12 | vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; |
12 | vec2 uv; | 13 | vec2 uv; |
13 | 14 | ||
14 | float an = u_time*.25; | 15 | float an = u_time*u_speed*.25; |
15 | 16 | ||
16 | float x = p.x*cos(an)-p.y*sin(an); | 17 | float x = p.x*cos(an)-p.y*sin(an); |
17 | float y = p.x*sin(an)+p.y*cos(an); | 18 | float y = p.x*sin(an)+p.y*cos(an); |
18 | 19 | ||
19 | uv.x = .25*x/abs(y); | 20 | uv.x = .25*x/abs(y); |
20 | uv.y = .20*u_time + .25/abs(y); | 21 | uv.y = .20*u_time*u_speed + .25/abs(y); |
21 | 22 | ||
22 | gl_FragColor = vec4(texture2D(u_tex0,uv).xyz * y*y, 1.0); | 23 | gl_FragColor = vec4(texture2D(u_tex0,uv).xyz * y*y, 1.0); |
23 | } | 24 | } |
diff --git a/assets/shaders/Julia.frag.glsl b/assets/shaders/Julia.frag.glsl index 68cda703..7e616c40 100644 --- a/assets/shaders/Julia.frag.glsl +++ b/assets/shaders/Julia.frag.glsl | |||
@@ -4,11 +4,12 @@ precision highp float; | |||
4 | 4 | ||
5 | uniform vec2 u_resolution; | 5 | uniform vec2 u_resolution; |
6 | uniform float u_time; | 6 | uniform float u_time; |
7 | uniform float u_speed; | ||
7 | 8 | ||
8 | void main(void) | 9 | void main(void) |
9 | { | 10 | { |
10 | vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; | 11 | vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; |
11 | vec2 cc = vec2( cos(.25*u_time), sin(.25*u_time*1.423) ); | 12 | vec2 cc = vec2( cos(.25*u_time*u_speed), sin(.25*u_time*u_speed*1.423) ); |
12 | 13 | ||
13 | float dmin = 1000.0; | 14 | float dmin = 1000.0; |
14 | vec2 z = p*vec2(1.33,1.0); | 15 | vec2 z = p*vec2(1.33,1.0); |
diff --git a/assets/shaders/Keleidoscope.frag.glsl b/assets/shaders/Keleidoscope.frag.glsl index 7d1bdb17..7d95a95b 100644 --- a/assets/shaders/Keleidoscope.frag.glsl +++ b/assets/shaders/Keleidoscope.frag.glsl | |||
@@ -4,20 +4,24 @@ precision highp float; | |||
4 | 4 | ||
5 | uniform vec2 u_resolution; | 5 | uniform vec2 u_resolution; |
6 | uniform float u_time; | 6 | uniform float u_time; |
7 | uniform float u_speed; | ||
7 | uniform sampler2D u_tex0; | 8 | uniform sampler2D u_tex0; |
8 | 9 | ||
9 | void main(void) | 10 | void main(void) |
10 | { | 11 | { |
11 | vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; | 12 | vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; |
12 | vec2 uv; | 13 | vec2 uv; |
14 | |||
15 | float time = u_time * u_speed; | ||
13 | 16 | ||
14 | float a = atan(p.y,p.x); | 17 | float a = atan(p.y,p.x); |
15 | float r = sqrt(dot(p,p)); | 18 | float r = sqrt(dot(p,p)); |
16 | 19 | ||
17 | uv.x = 7.0*a/3.1416; | 20 | uv.x = 7.0*a/3.1416; |
18 | uv.y = -u_time+ sin(7.0*r+u_time) + .7*cos(u_time+7.0*a); | 21 | uv.y = -time + sin(7.0*r+time) + .7*cos( |
22 | +7.0*a); | ||
19 | 23 | ||
20 | float w = .5+.5*(sin(u_time+7.0*r)+ .7*cos(u_time+7.0*a)); | 24 | float w = .5+.5*(sin(time+7.0*r)+ .7*cos(time+7.0*a)); |
21 | 25 | ||
22 | vec3 col = texture2D(u_tex0,uv*.5).xyz; | 26 | vec3 col = texture2D(u_tex0,uv*.5).xyz; |
23 | 27 | ||
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js index 30624f7b..f73f1d34 100755 --- a/js/lib/rdge/materials/bump-metal-material.js +++ b/js/lib/rdge/materials/bump-metal-material.js | |||
@@ -19,11 +19,10 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
19 | this._name = "BumpMetalMaterial"; | 19 | this._name = "BumpMetalMaterial"; |
20 | this._shaderName = "bumpMetal"; | 20 | this._shaderName = "bumpMetal"; |
21 | 21 | ||
22 | this._lightDiff = [0.3, 0.3, 0.3, 1.0]; | 22 | |
23 | 23 | this._defaultDiffuseTexture = "assets/images/metal.png"; | |
24 | this._diffuseTexture = "assets/images/metal.png"; | 24 | this._defaultSpecularTexture = "assets/images/silver.png"; |
25 | this._specularTexture = "assets/images/silver.png"; | 25 | this._defaultNormalTexture = "assets/images/normalMap.png"; |
26 | this._normalTexture = "assets/images/normalMap.png"; | ||
27 | 26 | ||
28 | // keep the array of initialized textures | 27 | // keep the array of initialized textures |
29 | this._textures = []; | 28 | this._textures = []; |
@@ -33,77 +32,22 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
33 | /////////////////////////////////////////////////////////////////////// | 32 | /////////////////////////////////////////////////////////////////////// |
34 | // Property Accessors | 33 | // Property Accessors |
35 | /////////////////////////////////////////////////////////////////////// | 34 | /////////////////////////////////////////////////////////////////////// |
36 | this.getName = function() { | ||
37 | return this._name; | ||
38 | }; | ||
39 | |||
40 | this.getShaderName = function() { | ||
41 | return this._shaderName; | ||
42 | }; | ||
43 | |||
44 | this.getLightDiff = function() { | ||
45 | return this._lightDiff; | ||
46 | }; | ||
47 | |||
48 | this.setLightDiff = function(ld) { | ||
49 | this._lightDiff = ld; | ||
50 | // Bad property name. Commenting for now | ||
51 | |||
52 | if (this._shader && this._shader['default']){ | ||
53 | this._shader['default'].u_light0Diff.set( ld ); | ||
54 | } | ||
55 | |||
56 | }; | ||
57 | |||
58 | this.getDiffuseTexture = function() { return this._propValues[this._propNames[1]] ? this._propValues[this._propNames[1]].slice() : null }; | ||
59 | this.setDiffuseTexture = function(m) { this._propValues[this._propNames[1]] = m ? m.slice(0) : null; this.initTexture(1); }; | ||
60 | |||
61 | this.getNormalTexture = function() { return this._propValues[this._propNames[2]] ? this._propValues[this._propNames[2]].slice() : null }; | ||
62 | this.setNormalTexture = function(m) { this._propValues[this._propNames[2]] = m ? m.slice(0) : null; this.initTexture(2); }; | ||
63 | |||
64 | this.getSpecularTexture = function() { return this._propValues[this._propNames[3]] ? this._propValues[this._propNames[3]].slice() : null }; | ||
65 | this.setSpecularTexture = function(m) { this._propValues[this._propNames[3]] = m ? m.slice(0) : null; this.initTexture(3); }; | ||
66 | |||
67 | this.isAnimated = function() { return true; }; | 35 | this.isAnimated = function() { return true; }; |
36 | this.getShaderDef = function() { return bumpMetalMaterialDef; }; | ||
68 | 37 | ||
69 | /////////////////////////////////////////////////////////////////////// | 38 | /////////////////////////////////////////////////////////////////////// |
70 | // Material Property Accessors | 39 | // Material Property Accessors |
71 | /////////////////////////////////////////////////////////////////////// | 40 | /////////////////////////////////////////////////////////////////////// |
72 | this._propNames = ["lightDiff", "diffuseTexture", "normalMap" ]; | 41 | this._propNames = ["u_light0Diff", "u_colMap", "u_normalMap", "u_glowMap" ]; |
73 | this._propLabels = ["Diffuse Color", "Diffuse Map", "Bump Map" ]; | 42 | this._propLabels = ["Diffuse Color", "Diffuse Map", "Bump Map", "Specular Map" ]; |
74 | this._propTypes = ["color", "file", "file" ]; | 43 | this._propTypes = ["color", "file", "file", "file" ]; |
75 | this._propValues = []; | 44 | this._propValues = []; |
76 | 45 | ||
77 | this._propValues[ this._propNames[0] ] = this._lightDiff.slice(0); | 46 | this._propValues[ this._propNames[0] ] = [0.3, 0.3, 0.3, 1.0]; |
78 | this._propValues[ this._propNames[1] ] = this._diffuseTexture.slice(0); | 47 | this._propValues[ this._propNames[1] ] = this._defaultDiffuseTexture.slice(0); |
79 | this._propValues[ this._propNames[2] ] = this._normalTexture.slice(0); | 48 | this._propValues[ this._propNames[2] ] = this._defaultNormalTexture.slice(0); |
80 | 49 | this._propValues[ this._propNames[3] ] = this._defaultSpecularTexture.slice(0); | |
81 | // TODO - shader techniques are not all named the same, i.e., FlatMaterial uses "colorMe" and BrickMaterial uses "default" | ||
82 | this.setProperty = function( prop, value ) | ||
83 | { | ||
84 | // every material should do something with the "color" property | ||
85 | if (prop === "color") return; | ||
86 | 50 | ||
87 | // make sure we have legitimate imput | ||
88 | var ok = this.validateProperty( prop, value ); | ||
89 | if (!ok) | ||
90 | { | ||
91 | console.log( "invalid property in Bump Metal Materia;" + prop + " : " + value ); | ||
92 | return; | ||
93 | } | ||
94 | |||
95 | switch (prop) | ||
96 | { | ||
97 | case "lightDiff": this.setLightDiff( value ); break; | ||
98 |