diff options
-rw-r--r-- | assets/shaders/Cloud.frag.glsl | 2 | ||||
-rw-r--r-- | assets/shaders/TwistVert.frag.glsl | 1 | ||||
-rw-r--r-- | assets/shaders/TwistVert.vert.glsl | 11 | ||||
-rwxr-xr-x | js/lib/rdge/materials/material.js | 1 | ||||
-rw-r--r-- | js/lib/rdge/materials/twist-vert-material.js | 362 | ||||
-rwxr-xr-x | js/panels/Materials/materials-popup.reel/materials-popup.js | 8 |
6 files changed, 187 insertions, 198 deletions
diff --git a/assets/shaders/Cloud.frag.glsl b/assets/shaders/Cloud.frag.glsl index 2447fd79..cd70d1a0 100644 --- a/assets/shaders/Cloud.frag.glsl +++ b/assets/shaders/Cloud.frag.glsl | |||
@@ -18,8 +18,6 @@ varying vec2 v_texCoord0; | |||
18 | void main() | 18 | void main() |
19 | { | 19 | { |
20 | vec4 c = texture2D(u_tex0, v_texCoord0); | 20 | vec4 c = texture2D(u_tex0, v_texCoord0); |
21 | //c.a *= u_surfaceAlpha; | ||
22 | //if ((c.r == 0.0) && (c.b == 0.0) && (c.g == 0.0) && (c.a == 1.0)) c = vec4( 0.0, 0.0, 1.0, 1.0 ); | ||
23 | gl_FragColor = c; | 21 | gl_FragColor = c; |
24 | } | 22 | } |
25 | \ No newline at end of file | 23 | \ No newline at end of file |
diff --git a/assets/shaders/TwistVert.frag.glsl b/assets/shaders/TwistVert.frag.glsl index f8490615..01c32c42 100644 --- a/assets/shaders/TwistVert.frag.glsl +++ b/assets/shaders/TwistVert.frag.glsl | |||
@@ -28,5 +28,4 @@ void main() | |||
28 | col = texture2D(u_tex1, v_texcoord).xyz; | 28 | col = texture2D(u_tex1, v_texcoord).xyz; |
29 | 29 | ||
30 | gl_FragColor = vec4(col, 1.0); | 30 | gl_FragColor = vec4(col, 1.0); |
31 | //gl_FragColor = v_color; | ||
32 | } | 31 | } |
diff --git a/assets/shaders/TwistVert.vert.glsl b/assets/shaders/TwistVert.vert.glsl index 29cb30ea..9734063d 100644 --- a/assets/shaders/TwistVert.vert.glsl +++ b/assets/shaders/TwistVert.vert.glsl | |||
@@ -19,7 +19,7 @@ attribute vec2 texcoord; | |||
19 | uniform float u_limit1; | 19 | uniform float u_limit1; |
20 | uniform float u_limit2; | 20 | uniform float u_limit2; |
21 | uniform float u_twistAmount; | 21 | uniform float u_twistAmount; |
22 | uniform float u_center; | 22 | //uniform float u_center; |
23 | 23 | ||
24 | // texture sampler uniforms | 24 | // texture sampler uniforms |
25 | uniform sampler2D u_tex0; | 25 | uniform sampler2D u_tex0; |
@@ -63,17 +63,14 @@ void main(void) | |||
63 | vec2 uv = texcoord; | 63 | vec2 uv = texcoord; |
64 | v_texcoord = texcoord; | 64 | v_texcoord = texcoord; |
65 | 65 | ||
66 | //v_color = vec4(texcoord.x, texcoord.y, 0, 1); | ||
67 | |||
68 | v_zNormal = 1.0; | 66 | v_zNormal = 1.0; |
69 | if (uv.x < u_limit2) | 67 | if (uv.x < u_limit2) |
70 | { | 68 | { |
71 | float angle = GetAngle( uv.x ); | 69 | float angle = GetAngle( uv.x ); |
72 | float cs = cos(angle), sn = sin(angle); | 70 | float cs = cos(angle), sn = sin(angle); |
73 | 71 | ||
74 | pos.y -= u_center; | ||
75 | vec3 ctrPt = pos; | 72 | vec3 ctrPt = pos; |
76 | float y = pos.y*cs - pos.z*sn + u_center; | 73 | float y = pos.y*cs - pos.z*sn; // + u_center; |
77 | pos.z = pos.y*sn + pos.z*cs; | 74 | pos.z = pos.y*sn + pos.z*cs; |
78 | pos.y = y; | 75 | pos.y = y; |
79 | 76 | ||
@@ -85,11 +82,7 @@ void main(void) | |||
85 | cs = cos(angle); sn = sin(angle); | 82 | cs = cos(angle); sn = sin(angle); |
86 | rotMat = mat3( vec3( 1.0, 0.0, 0.0 ), vec3( 0.0, cs, sn ), vec3( 0.0, -sn, cs ) ); | 83 | rotMat = mat3( vec3( 1.0, 0.0, 0.0 ), vec3( 0.0, cs, sn ), vec3( 0.0, -sn, cs ) ); |
87 | pt2 = rotMat * pt2; | 84 | pt2 = rotMat * pt2; |
88 | pt0.y += u_center; pt1.y += u_center; pt2.y += u_center; | ||
89 | //vec4 nrm = u_projMatrix * u_mvMatrix * vec4( cross(pt1-pt0, pt2-pt0), 1.0 ); | ||
90 | vec4 nrm = vec4( cross(pt1-pt0, pt2-pt0), 1.0 ); | 85 | vec4 nrm = vec4( cross(pt1-pt0, pt2-pt0), 1.0 ); |
91 | |||
92 | //v_zNormal = normal.y*sn + normal.z*cs; | ||
93 | v_zNormal = -nrm.z; | 86 | v_zNormal = -nrm.z; |
94 | } | 87 | } |
95 | 88 | ||
diff --git a/js/lib/rdge/materials/material.js b/js/lib/rdge/materials/material.js index 9f0ae6f1..b9de9988 100755 --- a/js/lib/rdge/materials/material.js +++ b/js/lib/rdge/materials/material.js | |||
@@ -192,6 +192,7 @@ var Material = function GLMaterial( world ) { | |||
192 | rtnVal = ((valType == "object") && (value.length >= 3)); | 192 | rtnVal = ((valType == "object") && (value.length >= 3)); |
193 | break; | 193 | break; |
194 | 194 | ||
195 | case "angle": | ||
195 | case "float": | 196 | case "float": |
196 | rtnVal = (valType == "number"); | 197 | rtnVal = (valType == "number"); |
197 | break; | 198 | break; |
diff --git a/js/lib/rdge/materials/twist-vert-material.js b/js/lib/rdge/materials/twist-vert-material.js index 7d9dd6d6..4d5ab88d 100644 --- a/js/lib/rdge/materials/twist-vert-material.js +++ b/js/lib/rdge/materials/twist-vert-material.js | |||
@@ -13,235 +13,227 @@ var Texture = require("js/lib/rdge/texture").Texture; | |||
13 | /////////////////////////////////////////////////////////////////////// | 13 | /////////////////////////////////////////////////////////////////////// |
14 | var TwistVertMaterial = function TwistVertMaterial() | 14 | var TwistVertMaterial = function TwistVertMaterial() |
15 | { | 15 | { |
16 | // initialize the inherited members | 16 | // initialize the inherited members |
17 | this.inheritedFrom = Material; | 17 | this.inheritedFrom = Material; |
18 | this.inheritedFrom(); | 18 | this.inheritedFrom(); |
19 | 19 | ||
20 | /////////////////////////////////////////////////////////////////////// | 20 | /////////////////////////////////////////////////////////////////////// |
21 | // Instance variables | 21 | // Instance variables |
22 | /////////////////////////////////////////////////////////////////////// | 22 | /////////////////////////////////////////////////////////////////////// |
23 | this._name = "TwistVertMaterial"; | 23 | this._name = "TwistVertMaterial"; |
24 | this._shaderName = "twistVert"; | 24 | this._shaderName = "twistVert"; |
25 | 25 | ||
26 | this._color = [1, 0, 0, 1]; | 26 | this._tex0 = 'assets/images/rocky-normal.jpg'; |
27 | 27 | this._tex1 = 'assets/images/metal.png'; | |
28 | this._tex0 = 'assets/images/rocky-normal.jpg'; | ||
29 | this._tex1 = 'assets/images/metal.png'; | ||
30 | 28 | ||
31 | this._glTex0; | 29 | this._glTex0; |
32 | this._glTex1; | 30 | this._glTex1; |
33 | 31 | ||
34 | this._angle = 0.0; | 32 | this._angle = 0.0; |
35 | this._deltaTime = 0.01; | 33 | this._deltaTime = 0.01; |
34 | this._speed = 1.0; | ||
36 | 35 | ||
37 | /////////////////////////////////////////////////////////////////////// | 36 | /////////////////////////////////////////////////////////////////////// |
38 | // Property Accessors | 37 | // Property Accessors |
39 | /////////////////////////////////////////////////////////////////////// | 38 | /////////////////////////////////////////////////////////////////////// |
40 | this.getColor = function () { return this._color; }; | 39 | this.getShaderName = function () { return this._shaderName; }; |
41 | this.getShaderName = function () { return this._shaderName; }; | ||
42 | 40 | ||
43 | this.isAnimated = function () { return true; }; | 41 | this.isAnimated = function () { return true; }; |
44 | 42 | ||
45 | this.hasVertexDeformation = function () { return this._hasVertexDeformation; }; | 43 | this.hasVertexDeformation = function () { return this._hasVertexDeformation; }; |
46 | this._hasVertexDeformation = true; | 44 | this._hasVertexDeformation = true; |
47 | this._vertexDeformationTolerance = 0.02; // should be a property | 45 | this._vertexDeformationTolerance = 0.02; // should be a property |
48 | 46 | ||
49 | /////////////////////////////////////////////////////////////////////// | 47 | /////////////////////////////////////////////////////////////////////// |
50 | // Methods | 48 | // Methods |
51 | /////////////////////////////////////////////////////////////////////// | 49 | /////////////////////////////////////////////////////////////////////// |
52 | // duplcate method requirde | 50 | // duplcate method requirde |
53 | this.dup = function() { | 51 | this.dup = function() { |
54 | // get the current values; | 52 | // get the current values; |
55 | var propNames = [], propValues = [], propTypes = [], propLabels = []; | 53 | var propNames = [], propValues = [], propTypes = [], propLabels = []; |
56 | this.getAllProperties(propNames, propValues, propTypes, propLabels); | 54 | this.getAllProperties(propNames, propValues, propTypes, propLabels); |
57 | 55 | ||
58 | // allocate a new material | 56 | // allocate a new material |
59 | var newMat = new TwistVertMaterial(); | 57 | var newMat = new TwistVertMaterial(); |
60 | 58 | ||
61 | // copy over the current values; | 59 | // copy over the current values; |
62 | var n = propNames.length; | 60 | var n = propNames.length; |
63 | for (var i = 0; i < n; i++) | 61 | for (var i = 0; i < n; i++) |
64 | newMat.setProperty(propNames[i], propValues[i]); | 62 | newMat.setProperty(propNames[i], propValues[i]); |
65 | 63 | ||
66 | return newMat; | 64 | return newMat; |
67 | }; | 65 | }; |
68 | 66 | ||
69 | this.init = function (world) | 67 | this.init = function (world) |
70 | { | 68 | { |
71 | this.setWorld(world); | 69 | this.setWorld(world); |
72 | |||
73 | // set up the shader | ||
74 | this._shader = new RDGE.jshader(); | ||
75 | this._shader.def = twistVertShaderDef; | ||
76 | this._shader.init(); | ||
77 | 70 | ||
78 | // set the defaults | 71 | // set up the shader |
79 | this._shader.twistMe.color.set(this.getColor()); | 72 | this._shader = new RDGE.jshader(); |
73 | this._shader.def = twistVertShaderDef; | ||
74 | this._shader.init(); | ||
80 | 75 | ||
81 | // set up the material node | 76 | // set up the material node |
82 | this._materialNode = RDGE.createMaterialNode("twistVertMaterial" + "_" + world.generateUniqueNodeID()); | 77 | this._materialNode = RDGE.createMaterialNode("twistVertMaterial" + "_" + world.generateUniqueNodeID()); |
83 | this._materialNode.setShader(this._shader); | 78 | this._materialNode.setShader(this._shader); |
84 | 79 | ||
85 | // set up the texture maps | 80 | // set up the texture maps |
86 | this.updateTextures(); | 81 | this.updateTextures(); |
87 | 82 | ||
88 | // initialize the twist vert properties | 83 | // initialize the twist vert properties |
89 | this.updateShaderValues(); | 84 | this.updateShaderValues(); |
90 | }; | 85 | }; |
91 | 86 | ||
92 | 87 | ||
93 | /////////////////////////////////////////////////////////////////////// | 88 | /////////////////////////////////////////////////////////////////////// |
94 | // Material Property Accessors | 89 | // Material Property Accessors |
95 | /////////////////////////////////////////////////////////////////////// | 90 | /////////////////////////////////////////////////////////////////////// |