ShaderNodeElements.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // accessors
  2. import CubeTextureNode from '../accessors/CubeTextureNode.js';
  3. import InstanceNode from '../accessors/InstanceNode.js';
  4. import ReflectVectorNode from '../accessors/ReflectVectorNode.js';
  5. import SkinningNode from '../accessors/SkinningNode.js';
  6. // display
  7. import ColorAdjustmentNode from '../display/ColorAdjustmentNode.js';
  8. import ColorSpaceNode from '../display/ColorSpaceNode.js';
  9. import NormalMapNode from '../display/NormalMapNode.js';
  10. import ToneMappingNode from '../display/ToneMappingNode.js';
  11. // lighting
  12. import LightsNode from '../lighting/LightsNode.js';
  13. //import LightingNode from '../lighting/LightingNode.js';
  14. import LightingContextNode from '../lighting/LightingContextNode.js';
  15. // utils
  16. import MatcapUVNode from '../utils/MatcapUVNode.js';
  17. import MaxMipLevelNode from '../utils/MaxMipLevelNode.js';
  18. import OscNode from '../utils/OscNode.js';
  19. import RotateUVNode from '../utils/RotateUVNode.js';
  20. import SpriteSheetUVNode from '../utils/SpriteSheetUVNode.js';
  21. import TimerNode from '../utils/TimerNode.js';
  22. // geometry
  23. import RangeNode from '../geometry/RangeNode.js';
  24. // procedural
  25. import CheckerNode from '../procedural/CheckerNode.js';
  26. // fog
  27. import FogNode from '../fog/FogNode.js';
  28. import FogRangeNode from '../fog/FogRangeNode.js';
  29. // shader node utils
  30. import { nodeObject, nodeProxy, nodeImmutable } from './ShaderNode.js';
  31. //
  32. // Node Material Shader Syntax
  33. //
  34. // shader node base
  35. export * from './ShaderNodeBaseElements.js';
  36. // functions
  37. export { default as BRDF_GGX } from '../functions/BSDF/BRDF_GGX.js'; // see https://github.com/tc39/proposal-export-default-from
  38. export { default as BRDF_Lambert } from '../functions/BSDF/BRDF_Lambert.js';
  39. export { default as D_GGX } from '../functions/BSDF/D_GGX.js';
  40. export { default as DFGApprox } from '../functions/BSDF/DFGApprox.js';
  41. export { default as F_Schlick } from '../functions/BSDF/F_Schlick.js';
  42. export { default as V_GGX_SmithCorrelated } from '../functions/BSDF/V_GGX_SmithCorrelated.js';
  43. export { default as getDistanceAttenuation } from '../functions/light/getDistanceAttenuation.js';
  44. export { default as getGeometryRoughness } from '../functions/material/getGeometryRoughness.js';
  45. export { default as getRoughness } from '../functions/material/getRoughness.js';
  46. export { default as PhysicalLightingModel } from '../functions/PhysicalLightingModel.js';
  47. // accessors
  48. export const cubeTexture = nodeProxy( CubeTextureNode );
  49. export const instance = nodeProxy( InstanceNode );
  50. export const reflectVector = nodeImmutable( ReflectVectorNode );
  51. export const skinning = nodeProxy( SkinningNode );
  52. // display
  53. export const saturation = nodeProxy( ColorAdjustmentNode, ColorAdjustmentNode.SATURATION );
  54. export const vibrance = nodeProxy( ColorAdjustmentNode, ColorAdjustmentNode.VIBRANCE );
  55. export const hue = nodeProxy( ColorAdjustmentNode, ColorAdjustmentNode.HUE );
  56. export const colorSpace = ( node, encoding ) => nodeObject( new ColorSpaceNode( null, nodeObject( node ) ).fromEncoding( encoding ) );
  57. export const normalMap = nodeProxy( NormalMapNode );
  58. export const toneMapping = ( mapping, exposure, color ) => nodeObject( new ToneMappingNode( mapping, nodeObject( exposure ), nodeObject( color ) ) );
  59. // lighting
  60. //export const lighting = nodeProxy( LightingNode ); // abstract
  61. //export const light; // still needs to be added
  62. export const lights = ( lights ) => nodeObject( new LightsNode().fromLights( lights ) );
  63. export const lightingContext = nodeProxy( LightingContextNode );
  64. // utils
  65. export const matcapUV = nodeImmutable( MatcapUVNode );
  66. export const maxMipLevel = nodeProxy( MaxMipLevelNode );
  67. export const oscSine = nodeProxy( OscNode, OscNode.SINE );
  68. export const oscSquare = nodeProxy( OscNode, OscNode.SQUARE );
  69. export const oscTriangle = nodeProxy( OscNode, OscNode.TRIANGLE );
  70. export const oscSawtooth = nodeProxy( OscNode, OscNode.SAWTOOTH );
  71. export const rotateUV = nodeProxy( RotateUVNode );
  72. export const spritesheetUV = nodeProxy( SpriteSheetUVNode );
  73. // @TODO: add supports to use node in timeScale
  74. export const timerLocal = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.LOCAL, timeScale, value ) );
  75. export const timerGlobal = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.GLOBAL, timeScale, value ) );
  76. export const timerDelta = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.DELTA, timeScale, value ) );
  77. // geometry
  78. export const range = ( min, max ) => nodeObject( new RangeNode( min, max ) );
  79. // procedural
  80. export const checker = nodeProxy( CheckerNode );
  81. // fog
  82. export const fog = nodeProxy( FogNode );
  83. export const rangeFog = nodeProxy( FogRangeNode );