-
Notifications
You must be signed in to change notification settings - Fork 250
Description
Hello guys
first of all thanks for your efforts , but to be honest it is not enough , like the last bug you replied to it was a month ago , the slack URL is not working , half of the learning lessons in the website are incomplete or broken , there is no way of any kind of communication with you guys , how the hell you want to people to use famous !!
anyway i tried to add materials to my webGL content , but i faced an error related to the time line
var time = Material.time();
compile error: ERROR: 0:98: 'time' : undeclared identifier
bundle.js:16106
compileShader bundle.js:16106
resetProgram bundle.js:15926
registerMaterial bundle.js:15837
handleMaterialInput bundle.js:16916
materialInput bundle.js:10138
receive bundle.js:9962
handleWith bundle.js:9539
drawCommands bundle.js:9597
update bundle.js:10391
step bundle.js:9341
loop bundle.js:9357
RequestAnimationFrameLoop._looper
1: precision mediump float;
2: uniform sampler2D u_textures[7];
3: uniform mat4 u_perspective;
4: uniform mat4 u_view;
5: uniform vec3 u_resolution;
6: uniform mat4 u_transform;
7: uniform vec3 u_size;
8: uniform float u_time;
9: uniform float u_opacity;
10: uniform float u_metalness;
11: uniform vec4 u_glossiness;
12: uniform vec4 u_baseColor;
13: uniform vec3 u_normals;
14: uniform vec3 u_positionOffset;
15: uniform mat4 u_lightPosition;
16: uniform mat4 u_lightColor;
17: uniform vec3 u_ambientLight;
18: uniform float u_flatShading;
19: uniform float u_numLights;
20: varying vec2 v_textureCoordinate;
21: varying vec3 v_normal;
22: varying vec3 v_position;
23: varying vec3 v_eyeVector;
24: #define GLSLIFY 1
25: /**
26: * The MIT License (MIT)
27: *
28: * Copyright (c) 2015 Famous Industries Inc.
29: *
30: * Permission is hereby granted, free of charge, to any person obtaining a copy
31: * of this software and associated documentation files (the "Software"), to deal
32: * in the Software without restriction, including without limitation the rights
33: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
34: * copies of the Software, and to permit persons to whom the Software is
35: * furnished to do so, subject to the following conditions:
36: *
37: * The above copyright notice and this permission notice shall be included in
38: * all copies or substantial portions of the Software.
39: *
40: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
41: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
42: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
43: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
44: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
45: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
46: * THE SOFTWARE.
47: /
48:
49: /*
50: * The MIT License (MIT)
51: *
52: * Copyright (c) 2015 Famous Industries Inc.
53: *
54: * Permission is hereby granted, free of charge, to any person obtaining a copy
55: * of this software and associated documentation files (the "Software"), to deal
56: * in the Software without restriction, including without limitation the rights
57: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
58: * copies of the Software, and to permit persons to whom the Software is
59: * furnished to do so, subject to the following conditions:
60: *
61: * The above copyright notice and this permission notice shall be included in
62: * all copies or substantial portions of the Software.
63: *
64: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
65: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
66: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
67: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
68: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
69: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
70: * THE SOFTWARE.
71: /
72:
73: /*
74: * Placeholder for fragmentShader chunks to be templated in.
75: * Used for normal mapping, gloss mapping and colors.
76: *
77: * @method applyMaterial
78: * @Private
79: *
80: *
81: /
82:
83:
84: float applyMaterial_1_0(float ID) {
85:
86: return 1.;
87: }
88:
89:
90: vec3 applyMaterial_1_0(vec3 ID) {
91:
92: return vec3(0);
93: }
94:
95:
96: vec4 fa_4() {
97: vec4 fa_2 = texture2D(u_textures[0], v_textureCoordinate);
98: float fa_3 = time;
99: vec4 fa_4 = mix(fa_2, vec4(1,1,0,1), fa_3);
100: return fa_4;
101: }
102: vec4 applyMaterial_1_0(vec4 ID) {
103: if (int(abs(ID.x)) == 4) return fa_4();
104:
105: return vec4(0);
106: }
107:
108:
109:
110: /*
111: * The MIT License (MIT)
112: *
113: * Copyright (c) 2015 Famous Industries Inc.
114: *
115: * Permission is hereby granted, free of charge, to any person obtaining a copy
116: * of this software and associated documentation files (the "Software"), to deal
117: * in the Software without restriction, including without limitation the rights
118: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
119: * copies of the Software, and to permit persons to whom the Software is
120: * furnished to do so, subject to the following conditions:
121: *
122: * The above copyright notice and this permission notice shall be included in
123: * all copies or substantial portions of the Software.
124: *
125: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
126: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
127: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
128: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
129: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
130: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
131: * THE SOFTWARE.
132: /
133:
134: /*
135: * Calculates the intensity of light on a surface.
136: *
137: * @method applyLight
138: * @Private
139: *
140: /
141: vec4 applyLight_2_1(in vec4 baseColor, in vec3 normal, in vec4 glossiness, int numLights, vec3 ambientColor, vec3 eyeVector, mat4 lightPosition, mat4 lightColor, vec3 v_position) {
142: vec3 diffuse = vec3(0.0);
143: bool hasGlossiness = glossiness.a > 0.0;
144: bool hasSpecularColor = length(glossiness.rgb) > 0.0;
145:
146: for(int i = 0; i < 4; i++) {
147: if (i >= numLights) break;
148: vec3 lightDirection = normalize(lightPosition[i].xyz - v_position);
149: float lambertian = max(dot(lightDirection, normal), 0.0);
150:
151: if (lambertian > 0.0) {
152: diffuse += lightColor[i].rgb * baseColor.rgb * lambertian;
153: if (hasGlossiness) {
154: vec3 halfVector = normalize(lightDirection + eyeVector);
155: float specularWeight = pow(max(dot(halfVector, normal), 0.0), glossiness.a);
156: vec3 specularColor = hasSpecularColor ? glossiness.rgb : lightColor[i].rgb;
157: diffuse += specularColor * specularWeight * lambertian;
158: }
159: }
160:
161: }
162:
163: return vec4(ambientColor + diffuse, baseColor.a);
164: }
165:
166:
167:
168:
169:
170: /*
171: * Writes the color of the pixel onto the screen
172: *
173: * @method main
174: * @Private
175: *
176: *
177: /
178: void main() {
179: vec4 material = u_baseColor.r >= 0.0 ? u_baseColor : applyMaterial_1_0(u_baseColor);
180:
181: /*
182: * Apply lights only if flat shading is false
183: * and at least one light is added to the scene
184: */
185: bool lightsEnabled = (u_flatShading == 0.0) && (u_numLights > 0.0 || length(u_ambientLight) > 0.0);
186:
187: vec3 normal = normalize(v_normal);
188: vec4 glossiness = u_glossiness.x < 0.0 ? applyMaterial_1_0(u_glossiness) : u_glossiness;
189:
190: vec4 color = lightsEnabled ?
191: applyLight_2_1(material, normalize(v_normal), glossiness,
192: int(u_numLights),
193: u_ambientLight * u_baseColor.rgb,
194: normalize(v_eyeVector),
195: u_lightPosition,
196: u_lightColor,
197: v_position)
198: : material;
199:
200: gl_FragColor = color;
201: gl_FragColor.a *= u_opacity;
202: }
203:
Any ideas ?