aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/Materials/StitchMaterial.js
diff options
context:
space:
mode:
authorEric Guzman2012-02-13 10:30:26 -0800
committerEric Guzman2012-02-13 10:30:26 -0800
commit672e6f61647b1b8a5f6f5831284fa44bcb7be883 (patch)
tree0c15656f1f82f194bfcab68634a88f68fd3d42cb /js/helper-classes/RDGE/Materials/StitchMaterial.js
parent586c3f7bbea04e62638e5ed8cdce9933e88c0b67 (diff)
parente142611e22718b1f1d1696902ad9161ec5f33f98 (diff)
downloadninja-672e6f61647b1b8a5f6f5831284fa44bcb7be883.tar.gz
Merge branch 'refs/heads/master' into PresetsPanel
Diffstat (limited to 'js/helper-classes/RDGE/Materials/StitchMaterial.js')
-rw-r--r--js/helper-classes/RDGE/Materials/StitchMaterial.js119
1 files changed, 0 insertions, 119 deletions
diff --git a/js/helper-classes/RDGE/Materials/StitchMaterial.js b/js/helper-classes/RDGE/Materials/StitchMaterial.js
deleted file mode 100644
index 44ff3ee7..00000000
--- a/js/helper-classes/RDGE/Materials/StitchMaterial.js
+++ /dev/null
@@ -1,119 +0,0 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6
7
8///////////////////////////////////////////////////////////////////////
9// Class GLMaterial
10// GL representation of a material.
11///////////////////////////////////////////////////////////////////////
12function StitchMaterial()
13{
14 // initialize the inherited members
15 this.inheritedFrom = GLMaterial;
16 this.inheritedFrom();
17
18 ///////////////////////////////////////////////////////////////////////
19 // Instance variables
20 ///////////////////////////////////////////////////////////////////////
21 this._name = "StitchMaterial";
22 this._shaderName = "stitch";
23
24 ///////////////////////////////////////////////////////////////////////
25 // Property Accessors
26 ///////////////////////////////////////////////////////////////////////
27 this.getShaderName = function() { return this._shaderName; }
28
29 ///////////////////////////////////////////////////////////////////////
30 // Methods
31 ///////////////////////////////////////////////////////////////////////
32 this.dup = function() { return new StitchMaterial(); }
33
34 this.init = function()
35 {
36
37 // set up the material node
38 this._materialNode = createMaterialNode("stitchMaterial")
39 this._materialNode.setDiffuseTexture("stitchStroke");
40 this._materialNode.setSpecTexture("quilt02_E");
41 this._materialNode.setNormalTexture("stitchStroke_N");
42
43 // set up the shader
44 this._shader = new jshader();
45 this._shader.def = stitchShaderDef;
46 this._shader.init();
47 this._materialNode.setShader(this._shader);
48 }
49}
50
51///////////////////////////////////////////////////////////////////////////////////////
52// RDGE shaders
53/*
54 * The main shader for the scene
55 */
56var stitchShaderDef = {'shaders': {
57 // this shader is being referenced by file
58 'defaultVShader':"assets/shaders/quilt_vshader.glsl",
59 'defaultFShader':"assets/shaders/quilt_fshader.glsl",
60
61 // this shader is inline
62 'dirLightVShader': "\
63 uniform mat4 u_mvMatrix;\
64 uniform mat4 u_normalMatrix;\
65 uniform mat4 u_projMatrix;\
66 uniform mat4 u_worldMatrix;\
67 attribute vec3 a_pos;\
68 attribute vec3 a_nrm;\
69 varying vec3 vNormal;\
70 varying vec3 vPos;\
71 void main() {\
72 vNormal.xyz = (u_normalMatrix*vec4(a_nrm, 0.0)).xyz;\
73 gl_Position = u_projMatrix * u_mvMatrix * vec4(a_pos,1.0);\
74 vPos = (u_worldMatrix * vec4(a_pos,1.0)).xyz;\
75 }",
76 'dirLightFShader': "\
77 precision highp float;\
78 uniform vec4 u_light1Diff;\
79 uniform vec3 u_light1Pos;\
80 uniform vec4 u_light2Diff;\
81 uniform vec3 u_light2Pos;\
82 varying vec3 vNormal;\
83 varying vec3 vPos;\
84 void main() {\
85 vec3 light1 = vec3(u_light1Pos.x - vPos.x, u_light1Pos.y - vPos.y, u_light1Pos.z - vPos.z);\
86 vec3 light2 = vec3(u_light2Pos.x - vPos.x, u_light2Pos.y - vPos.y, u_light2Pos.z - vPos.z);\
87 float t = 0.75;\
88 float range = t*t;\
89 float alpha1 = max(0.0, 1.0 - ( (light1.x*light1.x)/range + (light1.y*light1.y)/range + (light1.z*light1.z)/range));\
90 float alpha2 = max(0.0, 1.0 - ( (light2.x*light2.x)/range + (light2.y*light2.y)/range + (light2.z*light2.z)/range));\
91 gl_FragColor = vec4((u_light2Diff*alpha2 + u_light1Diff*alpha1).rgb, 1.0);\
92 }",
93 },
94 'techniques': {
95 'default':[{
96 'vshader' : 'defaultVShader',
97 'fshader' : 'defaultFShader',
98 // attributes
99 'attributes' :
100 {
101 'vert' : { 'type' : 'vec3' },
102 'normal' : { 'type' : 'vec3' },
103 'texcoord' : { 'type' : 'vec2' },
104 },
105 // parameters
106 'params' :
107 {
108 //'u_light0Diff' : { 'type' : 'vec4' },
109 //'u_matDiffuse' : { 'type' : 'vec4' }
110 },
111
112 // render states
113 'states' :
114 {
115 'depthEnable' : true,
116 'offset':[1.0, 0.1]
117 },
118 }]
119 }};