From 31e924e1b8b8da8342b3ff2341c8284915486c0b Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 22 Mar 2012 15:32:19 -0700 Subject: Added Paris and Raiders materials --- assets/canvas-runtime.js | 1 + assets/descriptor.json | 4 ++ assets/images/paris.png | Bin 0 -> 4108 bytes assets/images/powderblue.png | Bin 0 -> 176 bytes assets/images/raiders.png | Bin 0 -> 5674 bytes assets/shaders/Paris.frag.glsl | 68 +++++++++++++++++++++ js/io/system/ninjalibrary.json | 2 +- js/lib/geom/geom-obj.js | 2 + js/lib/rdge/materials/radial-blur-material.js | 2 - js/lib/rdge/materials/water-material.js | 84 +++++++++++++++++++++++++- js/models/materials-model.js | 5 ++ 11 files changed, 162 insertions(+), 6 deletions(-) create mode 100644 assets/images/paris.png create mode 100644 assets/images/powderblue.png create mode 100644 assets/images/raiders.png create mode 100644 assets/shaders/Paris.frag.glsl diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index 7f2dc8ab..dd909e26 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js @@ -526,6 +526,7 @@ function RuntimeGeomObj() case "deform": case "water": + case "paris": case "tunnel": case "reliefTunnel": case "squareTunnel": diff --git a/assets/descriptor.json b/assets/descriptor.json index af0520dd..85fbc996 100644 --- a/assets/descriptor.json +++ b/assets/descriptor.json @@ -21,6 +21,9 @@ "images/cubelight.png", "images/random_normal.png", "images/white.png", + "images/paris.png", + "images/powderblue.png", + "images/raiders.png", "shaders/Basic.frag.glsl", "shaders/TwistVert.vert.glsl", "shaders/Basic.vert.glsl", @@ -36,6 +39,7 @@ "shaders/Keleidoscope.frag.glsl", "shaders/plasma.frag.glsl", "shaders/Mandel.frag.glsl", + "shaders/Paris.frag.glsl", "shaders/plasma.vert.glsl", "shaders/Pulse.frag.glsl", "shaders/radialBlur.frag.glsl", diff --git a/assets/images/paris.png b/assets/images/paris.png new file mode 100644 index 00000000..b7ef6c7b Binary files /dev/null and b/assets/images/paris.png differ diff --git a/assets/images/powderblue.png b/assets/images/powderblue.png new file mode 100644 index 00000000..a4ef33b4 Binary files /dev/null and b/assets/images/powderblue.png differ diff --git a/assets/images/raiders.png b/assets/images/raiders.png new file mode 100644 index 00000000..64c39c89 Binary files /dev/null and b/assets/images/raiders.png differ diff --git a/assets/shaders/Paris.frag.glsl b/assets/shaders/Paris.frag.glsl new file mode 100644 index 00000000..690b1453 --- /dev/null +++ b/assets/shaders/Paris.frag.glsl @@ -0,0 +1,68 @@ +#ifdef GL_ES +precision highp float; +#endif + +uniform sampler2D u_tex0; +uniform float u_time; +uniform vec2 u_resolution; +const float PI = 3.1415926535897932; + +//speed + +const float speed = 0.1; +const float speed_x = 0.075; +const float speed_y = 0.000; + +// geometry +const float intensity = 1.5; +const int steps = 8; +//const float frequency = 4.0; +const float frequency = 2.0; +const int angle = 7; // better when a prime + +// reflection and emboss +const float delta = 20.; +const float intence = 400.; +const float emboss = 0.3; + +//---------- crystals effect + + float col(vec2 coord) + { + float delta_theta = 2.0 * PI / float(angle); + float col = 0.0; + float theta = 0.0; + for (int i = 0; i < steps; i++) + { + vec2 adjc = coord; + theta = delta_theta*float(i); + adjc.x += cos(theta)*u_time*speed + u_time * speed_x; + adjc.y -= sin(theta)*u_time*speed - u_time * speed_y; + col = col + cos( (adjc.x*cos(theta) - adjc.y*sin(theta))*frequency)*intensity; + } + + return cos(col); + } + +//---------- main + +void main(void) +{ +vec2 p = (gl_FragCoord.xy) / u_resolution.xy, c1 = p, c2 = p; +float cc1 = col(c1); + +c2.x += u_resolution.x/delta; +float dx = emboss*(cc1-col(c2))/delta; + +c2.x = p.x; +c2.y += u_resolution.y/delta; +float dy = emboss*(cc1-col(c2))/delta; + +c1.x += dx; +c1.y = -(c1.y+dy); + +float alpha = 1.+dot(dx,dy)*intence; +gl_FragColor = texture2D(u_tex0,c1)*(alpha); +// gl_FragColor = vec4(col(p),0,0,1); + +} diff --git a/js/io/system/ninjalibrary.json b/js/io/system/ninjalibrary.json index 00ee7ed2..a863a135 100644 --- a/js/io/system/ninjalibrary.json +++ b/js/io/system/ninjalibrary.json @@ -1,6 +1,6 @@ { "libraries": [ {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.6.0.0"}, - {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.1.0"} + {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.1.2"} ] } \ No newline at end of file diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index 75b7808b..dbef4859 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js @@ -301,6 +301,7 @@ var GeomObj = function GLGeomObj() { case "plasma": case "deform": case "water": + case "paris": case "tunnel": case "reliefTunnel": case "squareTunnel": @@ -373,6 +374,7 @@ var GeomObj = function GLGeomObj() { case "plasma": case "deform": case "water": + case "paris": case "tunnel": case "reliefTunnel": case "squareTunnel": diff --git a/js/lib/rdge/materials/radial-blur-material.js b/js/lib/rdge/materials/radial-blur-material.js index 91eebcff..f4a4baa2 100644 --- a/js/lib/rdge/materials/radial-blur-material.js +++ b/js/lib/rdge/materials/radial-blur-material.js @@ -275,7 +275,6 @@ var radialBlurMaterialDef = }; -/* var RaidersMaterial = function RaidersMaterial() { // initialize the inherited members @@ -295,7 +294,6 @@ if (typeof exports === "object") { exports.RaidersMaterial = RaidersMaterial; } -*/ RadialBlurMaterial.prototype = new Material(); diff --git a/js/lib/rdge/materials/water-material.js b/js/lib/rdge/materials/water-material.js index 565055a1..b7413f55 100644 --- a/js/lib/rdge/materials/water-material.js +++ b/js/lib/rdge/materials/water-material.js @@ -117,7 +117,6 @@ var waterMaterialDef = } }; -/* var ParisMaterial = function ParisMaterial() { // initialize the inherited members @@ -125,19 +124,98 @@ var ParisMaterial = function ParisMaterial() this.inheritedFrom(); this._name = "ParisMaterial"; - this._shaderName = "water"; + this._shaderName = "paris"; this._texMap = 'assets/images/paris.png'; this._propValues[ this._propNames[0] ] = this._texMap.slice(0); this._diffuseColor = [0.5, 0.5, 0.5, 0.5]; this._propValues[ this._propNames[1] ] = this._diffuseColor.slice(); + + // duplcate method requirde + this.dup = function( world ) { + // allocate a new uber material + var newMat = new ParisMaterial(); + + // copy over the current values; + var propNames = [], propValues = [], propTypes = [], propLabels = []; + this.getAllProperties( propNames, propValues, propTypes, propLabels); + var n = propNames.length; + for (var i=0; i