@triforge/shader-core 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/bundle.js +148 -8
  2. package/dist/core/CompileContext.d.ts +17 -0
  3. package/dist/core/CompileContext.d.ts.map +1 -1
  4. package/dist/core/CompileContext.js +26 -2
  5. package/dist/core/ShaderNode.d.ts.map +1 -1
  6. package/dist/core/ShaderNode.js +16 -0
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +1 -0
  10. package/dist/nodes/process/AddShader.js +3 -3
  11. package/dist/nodes/process/Bump.d.ts +25 -2
  12. package/dist/nodes/process/Bump.d.ts.map +1 -1
  13. package/dist/nodes/process/Bump.js +114 -32
  14. package/dist/nodes/process/DiffuseBSDF.js +7 -7
  15. package/dist/nodes/process/Emission.js +3 -3
  16. package/dist/nodes/process/GlassBSDF.js +13 -13
  17. package/dist/nodes/process/GlossyBSDF.js +14 -14
  18. package/dist/nodes/process/MixShader.js +3 -3
  19. package/dist/nodes/process/PrincipledBSDF.js +39 -39
  20. package/dist/nodes/process/PrincipledHair.js +70 -70
  21. package/dist/nodes/process/PrincipledVolume.js +21 -21
  22. package/dist/nodes/process/RefractionBSDF.js +7 -7
  23. package/dist/nodes/process/SheenBSDF.js +12 -12
  24. package/dist/nodes/process/SpecularBSDF.js +15 -15
  25. package/dist/nodes/process/SubsurfaceScattering.js +7 -7
  26. package/dist/nodes/process/ToonBSDF.js +6 -6
  27. package/dist/nodes/process/TranslucentBSDF.js +5 -5
  28. package/dist/nodes/process/TransparentBSDF.d.ts +26 -0
  29. package/dist/nodes/process/TransparentBSDF.d.ts.map +1 -0
  30. package/dist/nodes/process/TransparentBSDF.js +29 -0
  31. package/dist/nodes/process/VolumeAbsorption.js +3 -3
  32. package/dist/nodes/process/VolumeScatter.js +7 -7
  33. package/package.json +1 -1
@@ -36,11 +36,11 @@ export class SubsurfaceScattering extends ProcessNode {
36
36
  }
37
37
  }
38
38
  SubsurfaceScattering.instanceSpecificDef = false;
39
- SubsurfaceScattering.glslFunction = `
40
- vec3 _st_sss(vec3 color, float scale, vec3 radius, vec3 N) {
41
- vec3 L = normalize(vec3(1.0, 2.0, 1.0));
42
- float wrap = max(dot(N, L) * 0.5 + 0.5, 0.0);
43
- vec3 scatter = color * radius * wrap * scale;
44
- float back = max(-dot(N, L), 0.0) * scale * 0.3;
45
- return color * (0.04 + wrap * 0.5) + scatter + color * back;
39
+ SubsurfaceScattering.glslFunction = `
40
+ vec3 _st_sss(vec3 color, float scale, vec3 radius, vec3 N) {
41
+ vec3 L = normalize(vec3(1.0, 2.0, 1.0));
42
+ float wrap = max(dot(N, L) * 0.5 + 0.5, 0.0);
43
+ vec3 scatter = color * radius * wrap * scale;
44
+ float back = max(-dot(N, L), 0.0) * scale * 0.3;
45
+ return color * (0.04 + wrap * 0.5) + scatter + color * back;
46
46
  }`;
@@ -35,10 +35,10 @@ export class ToonBSDF extends ProcessNode {
35
35
  }
36
36
  }
37
37
  ToonBSDF.instanceSpecificDef = false;
38
- ToonBSDF.glslFunction = `
39
- vec3 _st_toonBSDF(vec3 color, float size, float smoothWidth, vec3 N) {
40
- vec3 L = normalize(vec3(1.0, 2.0, 1.0));
41
- float NdotL = dot(N, L) * 0.5 + 0.5;
42
- float band = smoothstep(size - smoothWidth, size + smoothWidth, NdotL);
43
- return color * band + color * 0.1;
38
+ ToonBSDF.glslFunction = `
39
+ vec3 _st_toonBSDF(vec3 color, float size, float smoothWidth, vec3 N) {
40
+ vec3 L = normalize(vec3(1.0, 2.0, 1.0));
41
+ float NdotL = dot(N, L) * 0.5 + 0.5;
42
+ float band = smoothstep(size - smoothWidth, size + smoothWidth, NdotL);
43
+ return color * band + color * 0.1;
44
44
  }`;
@@ -31,9 +31,9 @@ export class TranslucentBSDF extends ProcessNode {
31
31
  }
32
32
  }
33
33
  TranslucentBSDF.instanceSpecificDef = false;
34
- TranslucentBSDF.glslFunction = `
35
- vec3 _st_translucentBSDF(vec3 color, vec3 N) {
36
- vec3 L = normalize(vec3(1.0, 2.0, 1.0));
37
- float backDot = max(dot(-N, L), 0.0);
38
- return color * backDot / 3.14159265 + color * 0.02;
34
+ TranslucentBSDF.glslFunction = `
35
+ vec3 _st_translucentBSDF(vec3 color, vec3 N) {
36
+ vec3 L = normalize(vec3(1.0, 2.0, 1.0));
37
+ float backDot = max(dot(-N, L), 0.0);
38
+ return color * backDot / 3.14159265 + color * 0.02;
39
39
  }`;
@@ -0,0 +1,26 @@
1
+ import { ProcessNode } from '../../core/ProcessNode.js';
2
+ import type { NodeMetadata } from '../../core/ShaderNode.js';
3
+ import type { CompileContext } from '../../core/CompileContext.js';
4
+ /**
5
+ * Transparent BSDF — Blender "Transparent BSDF" node equivalent.
6
+ * Passes light through unfiltered — full transparency, colorless, no inputs.
7
+ * Combine with MixShader/AddShader to build cutout, fresnel-fade, or
8
+ * rim-light materials without a hand-written GLSL output node.
9
+ *
10
+ * Outputs: BSDF (shader) — always vec4(0.0, 0.0, 0.0, 0.0)
11
+ */
12
+ export declare class TransparentBSDF extends ProcessNode {
13
+ get nodeType(): string;
14
+ static instanceSpecificDef: boolean;
15
+ get metadata(): NodeMetadata;
16
+ private readonly _inputs;
17
+ private readonly _outputs;
18
+ constructor();
19
+ getInputSockets(): Record<string, import("../../index.js").InputSocket<unknown>>;
20
+ getOutputSockets(): Record<string, import("../../index.js").OutputSocket>;
21
+ compileDefs(): string;
22
+ /** Always fully transparent — a constant, not a dynamic value, so this always requests transparent:true. */
23
+ wantsTransparency(): boolean;
24
+ compileCall(ctx: CompileContext): string;
25
+ }
26
+ //# sourceMappingURL=TransparentBSDF.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransparentBSDF.d.ts","sourceRoot":"","sources":["../../../src/nodes/process/TransparentBSDF.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAElE;;;;;;;GAOG;AACH,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,IAAI,QAAQ,WAA+B;IAC3C,MAAM,CAAC,mBAAmB,UAAQ;IAElC,IAAI,QAAQ,IAAI,YAAY,CAE3B;IAED,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2E;IACnG,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmE;;IAQ5F,eAAe;IACf,gBAAgB;IAChB,WAAW;IAEX,4GAA4G;IAC5G,iBAAiB,IAAI,OAAO;IAE5B,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM;CAGzC"}
@@ -0,0 +1,29 @@
1
+ import { ProcessNode } from '../../core/ProcessNode.js';
2
+ /**
3
+ * Transparent BSDF — Blender "Transparent BSDF" node equivalent.
4
+ * Passes light through unfiltered — full transparency, colorless, no inputs.
5
+ * Combine with MixShader/AddShader to build cutout, fresnel-fade, or
6
+ * rim-light materials without a hand-written GLSL output node.
7
+ *
8
+ * Outputs: BSDF (shader) — always vec4(0.0, 0.0, 0.0, 0.0)
9
+ */
10
+ export class TransparentBSDF extends ProcessNode {
11
+ get nodeType() { return 'TransparentBSDF'; }
12
+ get metadata() {
13
+ return { label: 'Transparent BSDF', category: 'Shader', color: '#336699', cost: 'low' };
14
+ }
15
+ constructor() {
16
+ super('TransparentBSDF');
17
+ this._inputs = this.createInputs({}, {});
18
+ this._outputs = this.createOutputs({ BSDF: 'shader' });
19
+ }
20
+ getInputSockets() { return this._inputs; }
21
+ getOutputSockets() { return this._outputs; }
22
+ compileDefs() { return ''; }
23
+ /** Always fully transparent — a constant, not a dynamic value, so this always requests transparent:true. */
24
+ wantsTransparency() { return true; }
25
+ compileCall(ctx) {
26
+ return `vec4 ${ctx.outputVar(this, 'BSDF')} = vec4(0.0, 0.0, 0.0, 0.0);`;
27
+ }
28
+ }
29
+ TransparentBSDF.instanceSpecificDef = false;
@@ -30,7 +30,7 @@ export class VolumeAbsorption extends ProcessNode {
30
30
  }
31
31
  }
32
32
  VolumeAbsorption.instanceSpecificDef = false;
33
- VolumeAbsorption.glslFunction = `
34
- vec3 _st_volumeAbsorption(vec3 color, float density) {
35
- return color * density;
33
+ VolumeAbsorption.glslFunction = `
34
+ vec3 _st_volumeAbsorption(vec3 color, float density) {
35
+ return color * density;
36
36
  }`;
@@ -32,11 +32,11 @@ export class VolumeScatter extends ProcessNode {
32
32
  }
33
33
  }
34
34
  VolumeScatter.instanceSpecificDef = false;
35
- VolumeScatter.glslFunction = `
36
- vec3 _st_volumeScatter(vec3 color, float density, float anisotropy) {
37
- float g = clamp(anisotropy, -0.9999, 0.9999);
38
- float g2 = g * g;
39
- // HG phase at cosTheta=0 (isotropic approximation for surface shading context)
40
- float phase = (1.0 - g2) / pow(1.0 + g2, 1.5);
41
- return color * density * phase;
35
+ VolumeScatter.glslFunction = `
36
+ vec3 _st_volumeScatter(vec3 color, float density, float anisotropy) {
37
+ float g = clamp(anisotropy, -0.9999, 0.9999);
38
+ float g2 = g * g;
39
+ // HG phase at cosTheta=0 (isotropic approximation for surface shading context)
40
+ float phase = (1.0 - g2) / pow(1.0 + g2, 1.5);
41
+ return color * density * phase;
42
42
  }`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triforge/shader-core",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "GLSL shader library for Three.js with Blender workflow",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",