diff options
Diffstat (limited to 'js/lib/rdge')
27 files changed, 2630 insertions, 2630 deletions
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js index 97efe441..044dc59b 100755 --- a/js/lib/rdge/materials/bump-metal-material.js +++ b/js/lib/rdge/materials/bump-metal-material.js | |||
@@ -40,63 +40,63 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
40 | /////////////////////////////////////////////////////////////////////// | 40 | /////////////////////////////////////////////////////////////////////// |
41 | // Instance variables | 41 | // Instance variables |
42 | /////////////////////////////////////////////////////////////////////// | 42 | /////////////////////////////////////////////////////////////////////// |
43 | this._name = "Bump Metal"; | 43 | this._name = "Bump Metal"; |
44 | this._shaderName = "bumpMetal"; | 44 | this._shaderName = "bumpMetal"; |
45 | 45 | ||
46 | 46 | ||
47 | this._defaultLightDiff = [0.3, 0.3, 0.3, 1.0]; | 47 | this._defaultLightDiff = [0.3, 0.3, 0.3, 1.0]; |
48 | this._defaultDiffuseTexture = "assets/images/metal.png"; | 48 | this._defaultDiffuseTexture = "assets/images/metal.png"; |
49 | this._defaultSpecularTexture = "assets/images/silver.png"; | 49 | this._defaultSpecularTexture = "assets/images/silver.png"; |
50 | this._defaultNormalTexture = "assets/images/normalMap.png"; | 50 | this._defaultNormalTexture = "assets/images/normalMap.png"; |
51 | 51 | ||
52 | // array textures indexed by shader uniform name | 52 | // array textures indexed by shader uniform name |
53 | this._glTextures = []; | 53 | this._glTextures = []; |
54 | 54 | ||
55 | this._speed = 1.0; | 55 | this._speed = 1.0; |
56 | 56 | ||
57 | /////////////////////////////////////////////////////////////////////// | 57 | /////////////////////////////////////////////////////////////////////// |
58 | // Property Accessors | 58 | // Property Accessors |
59 | /////////////////////////////////////////////////////////////////////// | 59 | /////////////////////////////////////////////////////////////////////// |
60 | this.isAnimated = function() { return true; }; | 60 | this.isAnimated = function() { return true; }; |
61 | this.getShaderDef = function() { return bumpMetalMaterialDef; }; | 61 | this.getShaderDef = function() { return bumpMetalMaterialDef; }; |
62 | 62 | ||
63 | /////////////////////////////////////////////////////////////////////// | 63 | /////////////////////////////////////////////////////////////////////// |
64 | // Material Property Accessors | 64 | // Material Property Accessors |
65 | /////////////////////////////////////////////////////////////////////// | 65 | /////////////////////////////////////////////////////////////////////// |
66 | this._propNames = ["u_light0Diff", "u_colMap", "u_normalMap", "u_glowMap" ]; | 66 | this._propNames = ["u_light0Diff", "u_colMap", "u_normalMap", "u_glowMap" ]; |
67 | this._propLabels = ["Diffuse Color", "Diffuse Map", "Bump Map", "Specular Map" ]; | 67 | this._propLabels = ["Diffuse Color", "Diffuse Map", "Bump Map", "Specular Map" ]; |
68 | this._propTypes = ["color", "file", "file", "file" ]; | 68 | this._propTypes = ["color", "file", "file", "file" ]; |
69 | this._propValues = []; | 69 | this._propValues = []; |
70 | 70 | ||
71 | this._propValues[ this._propNames[0] ] = this._defaultLightDiff; | 71 | this._propValues[ this._propNames[0] ] = this._defaultLightDiff; |
72 | this._propValues[ this._propNames[1] ] = this._defaultDiffuseTexture.slice(0); | 72 | this._propValues[ this._propNames[1] ] = this._defaultDiffuseTexture.slice(0); |
73 | this._propValues[ this._propNames[2] ] = this._defaultNormalTexture.slice(0); | 73 | this._propValues[ this._propNames[2] ] = this._defaultNormalTexture.slice(0); |
74 | this._propValues[ this._propNames[3] ] = this._defaultSpecularTexture.slice(0); | 74 | this._propValues[ this._propNames[3] ] = this._defaultSpecularTexture.slice(0); |
75 | 75 | ||
76 | 76 | ||
77 | /////////////////////////////////////////////////////////////////////// | 77 | /////////////////////////////////////////////////////////////////////// |
78 | // Methods | 78 | // Methods |
79 | /////////////////////////////////////////////////////////////////////// | 79 | /////////////////////////////////////////////////////////////////////// |
80 | 80 | ||
81 | this.init = function( world ) | 81 | this.init = function( world ) |
82 | { | 82 | { |
83 | // save the world | 83 | // save the world |
84 | if (world) { | 84 | if (world) { |
85 | this.setWorld( world ); | 85 | this.setWorld( world ); |
86 | } | 86 | } |
87 | 87 | ||
88 | // set up the shader | 88 | // set up the shader |
89 | this._shader = new RDGE.jshader(); | 89 | this._shader = new RDGE.jshader(); |
90 | this._shader.def = bumpMetalMaterialDef; | 90 | this._shader.def = bumpMetalMaterialDef; |
91 | this._shader.init(); | 91 | this._shader.init(); |
92 | 92 | ||
93 | // set up the material node | 93 | // set up the material node |
94 | this._materialNode = RDGE.createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() ); | 94 | this._materialNode = RDGE.createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() ); |
95 | this._materialNode.setShader(this._shader); | 95 | this._materialNode.setShader(this._shader); |
96 | 96 | ||
97 | this.setShaderValues(); | 97 | this.setShaderValues(); |
98 | this.update(0); | 98 | this.update(0); |
99 | }; | 99 | }; |
100 | 100 | ||
101 | this.resetToDefault = function() | 101 | this.resetToDefault = function() |
102 | { | 102 | { |
@@ -106,38 +106,38 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
106 | this._propValues[ this._propNames[3] ] = this._defaultSpecularTexture.slice(0); | 106 | this._propValues[ this._propNames[3] ] = this._defaultSpecularTexture.slice(0); |
107 | for (var i=0; i<4; i++) | 107 | for (var i=0; i<4; i++) |
108 | this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] ); | 108 | this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] ); |
109 | }; | 109 | }; |
110 | }; | 110 | }; |
111 | 111 | ||
112 | 112 | ||
113 | /////////////////////////////////////////////////////////////////////////////////////// | 113 | /////////////////////////////////////////////////////////////////////////////////////// |
114 | // RDGE shader | 114 | // RDGE shader |
115 | 115 | ||
116 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) | 116 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) |
117 | var bumpMetalMaterialDef = bumpMetalShaderDef = | 117 | var bumpMetalMaterialDef = bumpMetalShaderDef = |
118 | { | 118 | { |
119 | 'shaders': | 119 | 'shaders': |
120 | { | 120 | { |
121 | // this shader is being referenced by file | 121 | // this shader is being referenced by file |
122 | 'defaultVShader':"assets/shaders/test_vshader.glsl", | 122 | 'defaultVShader':"assets/shaders/test_vshader.glsl", |
123 | 'defaultFShader':"assets/shaders/test_fshader.glsl", | 123 | 'defaultFShader':"assets/shaders/test_fshader.glsl", |
124 | 124 | ||
125 | // this shader is inline | 125 | // this shader is inline |
126 | 'dirLightVShader': "\ | 126 | 'dirLightVShader': "\ |
127 | uniform mat4 u_mvMatrix;\ | 127 | uniform mat4 u_mvMatrix;\ |
128 | uniform mat4 u_normalMatrix;\ | 128 | uniform mat4 u_normalMatrix;\ |
129 | uniform mat4 u_projMatrix;\ | 129 | uniform mat4 u_projMatrix;\ |
130 | uniform mat4 u_worldMatrix;\ | 130 | uniform mat4 u_worldMatrix;\ |
131 | attribute vec3 a_pos;\ | 131 | attribute vec3 a_pos;\ |
132 | attribute vec3 a_nrm;\ | 132 | attribute vec3 a_nrm;\ |
133 | varying vec3 vNormal;\ | 133 | varying vec3 vNormal;\ |
134 | varying vec3 vPos;\ | 134 | varying vec3 vPos;\ |
135 | void main() {\ | 135 | void main() {\ |
136 | vNormal.xyz = (u_normalMatrix*vec4(a_nrm, 0.0)).xyz;\ | 136 | vNormal.xyz = (u_normalMatrix*vec4(a_nrm, 0.0)).xyz;\ |
137 | gl_Position = u_projMatrix * u_mvMatrix * vec4(a_pos,1.0);\ | 137 | gl_Position = u_projMatrix * u_mvMatrix * vec4(a_pos,1.0);\ |
138 | vPos = (u_worldMatrix * vec4(a_pos,1.0)).xyz;\ | 138 | vPos = (u_worldMatrix * vec4(a_pos,1.0)).xyz;\ |
139 | }", | 139 | }", |
140 | 'dirLightFShader': "\ | 140 | 'dirLightFShader': "\ |
141 | precision highp float;\ | 141 | precision highp float;\ |
142 | uniform vec4 u_light1Diff;\ | 142 | uniform vec4 u_light1Diff;\ |
143 | uniform vec3 u_light1Pos;\ | 143 | uniform vec3 u_light1Pos;\ |
@@ -154,37 +154,37 @@ var bumpMetalMaterialDef = bumpMetalShaderDef = | |||
154 | float alpha2 = max(0.0, 1.0 - ( (light2.x*light2.x)/range + (light2.y*light2.y)/range + (light2.z*light2.z)/range));\ | 154 | float alpha2 = max(0.0, 1.0 - ( (light2.x*light2.x)/range + (light2.y*light2.y)/range + (light2.z*light2.z)/range));\ |
155 | gl_FragColor = vec4((u_light2Diff*alpha2 + u_light1Diff*alpha1).rgb, 1.0);\ | 155 | gl_FragColor = vec4((u_light2Diff*alpha2 + u_light1Diff*alpha1).rgb, 1.0);\ |
156 | }" | 156 | }" |
157 | }, | 157 | }, |
158 | 'techniques': | 158 | 'techniques': |
159 | { |