Skip to content

Commit 000212c

Browse files
committed
sub and simple input ops added
1 parent 932ce4f commit 000212c

File tree

14 files changed

+104
-25
lines changed

14 files changed

+104
-25
lines changed

shader-nodes/shader-nodes/add.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ add.gen = function ( argTypes, options ) {
1818
return flexOp.gen(argTypes, opt );
1919
};
2020

21-
// export { add };
22-
export default add;
21+
export { add };

shader-nodes/shader-nodes/cross.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,4 @@ cross.gen = function ( argTypes, options ) {
3434
return code;
3535
};
3636

37-
// export { cross };
38-
export default cross;
37+
export { cross };

shader-nodes/shader-nodes/flexOp.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,3 @@ flexOp.gen = function ( argTypes, options ) {
9595
};
9696

9797
export { flexOp };
98-
export default flexOp;

shader-nodes/shader-nodes/join.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,4 @@ join.gen = function ( argTypes, options ) {
3838
return code;
3939
};
4040

41-
// export { join };
42-
export default join;
41+
export { join };

shader-nodes/shader-nodes/mul.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import flexOp from './flexOp.js';
1+
import { flexOp } from './flexOp.js';
22

33
// node
44
var mul = {
@@ -18,5 +18,4 @@ mul.gen = function ( argTypes, options ) {
1818
return flexOp.gen(argTypes, opt );
1919
};
2020

21-
// export { mul };
22-
export default mul;
21+
export { mul };

shader-nodes/shader-nodes/select.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,4 @@ select.gen = function ( argTypes, options ) {
6868
return code;
6969
};
7070

71-
// export { cross };
72-
export default select;
71+
export { select };
Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
1-
import add from './add.js';
2-
import cross from './cross.js';
3-
import mul from './mul.js';
4-
import join from './join.js';
5-
import uv0 from './uv0.js';
6-
import texSample from './texSample.js';
7-
import select from './select.js';
1+
import { add } from './add.js';
2+
import { mul } from './mul.js';
3+
import { sub } from './sub.js';
4+
import { cross } from './cross.js';
5+
import { join } from './join.js';
6+
import { uv0 } from './uv0.js';
7+
import { worldPos } from './worldPos.js';
8+
import { worldNorm } from './worldNorm.js';
9+
import { texSample } from './texSample.js';
10+
import { select } from './select.js';
11+
import { stdAlpha, stdNormalMap, stdGlossiness, stdSpecularity, stdAlbedo, stdEmission } from './stdInputs.js';
812

913
// Object containing all default shader nodes used by shader graphs
1014
var shaderNodes = {
1115
add: add,
12-
cross: cross,
1316
mul: mul,
17+
sub: sub,
18+
cross: cross,
1419
join: join,
1520
uv0: uv0,
21+
worldPos: worldPos,
22+
worldNorm: worldNorm,
1623
texSample: texSample,
17-
select: select
24+
select: select,
25+
stdAlpha: stdAlpha,
26+
stdNormalMap: stdNormalMap,
27+
stdGlossiness: stdGlossiness,
28+
stdSpecularity: stdSpecularity,
29+
stdAlbedo: stdAlbedo,
30+
stdEmission: stdEmission
1831
};
1932

2033
export { shaderNodes };

shader-nodes/shader-nodes/simpleOp.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var simpleOp = {};
2+
3+
simpleOp.genOp = function ( retType, opName, retName, metaLabel ) {
4+
var op = {};
5+
6+
op.code = retType + " " + opName + "(){\n return " + retName + ";\n}\n";
7+
op.meta = { label: metaLabel };
8+
op.gen = function ( argTypes, options ) {
9+
var code = this.code;
10+
if (options && options.precision) {
11+
// precision - alter name to create variant
12+
code = code.replace(' ' + opName, ' ' + opName + '_' + options.precision);
13+
// precision - tmp: useful comment
14+
code = code.replace( '{\n', '{\n// precision ' + options.precision + ' float;\n');
15+
}
16+
return code;
17+
};
18+
19+
return op;
20+
};
21+
22+
export { simpleOp };
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { simpleOp } from "./simpleOp";
2+
3+
var stdAlpha = simpleOp.genOp('float', 'stdAlpha', 'dAlpha', 'STD MAT ALPHA');
4+
var stdNormalMap = simpleOp.genOp('vec3', 'stdNormalMap', 'dNormalMap', 'STD MAT NORMALMAP');
5+
var stdGlossiness = simpleOp.genOp('float', 'stdGlossiness', 'dGlossiness', 'STD MAT GLOSSINESS');
6+
var stdSpecularity = simpleOp.genOp('vec3', 'stdSpecularity', 'dSpecularity', 'STD MAT SPECULARITY');
7+
var stdAlbedo = simpleOp.genOp('vec3', 'stdAlbedo', 'dAlbedo', 'STD MAT ALBEDO');
8+
var stdEmission = simpleOp.genOp('vec3', 'stdEmission', 'dEmission', 'STD MAT EMISSION');
9+
10+
export { stdAlpha, stdNormalMap, stdGlossiness, stdSpecularity, stdAlbedo, stdEmission };

shader-nodes/shader-nodes/sub.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { flexOp } from './flexOp.js';
2+
3+
// node
4+
var sub = {
5+
// placeholder meta data - structure will be finalized in MVP S3
6+
meta: flexOp.meta.ports,
7+
// placeholder editor data - structure will be finalized in MVP S3
8+
editor: {
9+
label: "SUB",
10+
ports: flexOp.editor.ports
11+
}
12+
};
13+
14+
// generator
15+
sub.gen = function ( argTypes, options ) {
16+
var opt = { opName: 'sub', opCode: '-' };
17+
Object.assign(opt, options);
18+
return flexOp.gen(argTypes, opt );
19+
};
20+
21+
export { sub };

0 commit comments

Comments
 (0)