bec0c90a2539a3fc4be77c5704492edfaadd48e77a29f808b358e873d79e2687.json 16 KB

1
  1. {"ast":null,"code":"import { NodeMaterialBlock } from \"../nodeMaterialBlock.js\";\nimport { NodeMaterialBlockConnectionPointTypes } from \"../Enums/nodeMaterialBlockConnectionPointTypes.js\";\nimport { NodeMaterialBlockTargets } from \"../Enums/nodeMaterialBlockTargets.js\";\nimport { RegisterClass } from \"../../../Misc/typeStore.js\";\n/**\n * block used to Generate a Simplex Perlin 3d Noise Pattern\n */\n//\n// Wombat\n// An efficient texture-free GLSL procedural noise library\n// Source: https://github.com/BrianSharpe/Wombat\n// Derived from: https://github.com/BrianSharpe/GPU-Noise-Lib\n//\n// I'm not one for copyrights. Use the code however you wish.\n// All I ask is that credit be given back to the blog or myself when appropriate.\n// And also to let me know if you come up with any changes, improvements, thoughts or interesting uses for this stuff. :)\n// Thanks!\n//\n// Brian Sharpe\n// brisharpe CIRCLE_A yahoo DOT com\n// http://briansharpe.wordpress.com\n// https://github.com/BrianSharpe\n//\n//\n// This is a modified version of Stefan Gustavson's and Ian McEwan's work at http://github.com/ashima/webgl-noise\n// Modifications are...\n// - faster random number generation\n// - analytical final normalization\n// - space scaled can have an approx feature size of 1.0\n// - filter kernel changed to fix discontinuities at tetrahedron boundaries\n//\n// Converted to BJS by Pryme8\n//\n// Simplex Perlin Noise 3D\n// Return value range of -1.0->1.0\n//\nexport class SimplexPerlin3DBlock extends NodeMaterialBlock {\n /**\n * Creates a new SimplexPerlin3DBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Neutral);\n this.registerInput(\"seed\", NodeMaterialBlockConnectionPointTypes.Vector3);\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Float);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"SimplexPerlin3DBlock\";\n }\n /**\n * Gets the seed operand input component\n */\n get seed() {\n return this._inputs[0];\n }\n /**\n * Gets the output component\n */\n get output() {\n return this._outputs[0];\n }\n _buildBlock(state) {\n super._buildBlock(state);\n if (!this.seed.isConnected) {\n return;\n }\n if (!this._outputs[0].hasEndpoints) {\n return;\n }\n let functionString = `const float SKEWFACTOR = 1.0/3.0;\\n`;\n functionString += `const float UNSKEWFACTOR = 1.0/6.0;\\n`;\n functionString += `const float SIMPLEX_CORNER_POS = 0.5;\\n`;\n functionString += `const float SIMPLEX_TETRAHADRON_HEIGHT = 0.70710678118654752440084436210485;\\n`;\n functionString += `float SimplexPerlin3D( vec3 source ){\\n`;\n functionString += ` vec3 P = source;\\n`;\n functionString += ` P.x = [P.x == 0. && P.y == 0. && P.z == 0. ? 0.00001 : P.x];\\n`;\n functionString += ` P *= SIMPLEX_TETRAHADRON_HEIGHT;\\n`;\n functionString += ` vec3 Pi = floor( P + dot( P, vec3( SKEWFACTOR) ) );`;\n functionString += ` vec3 x0 = P - Pi + dot(Pi, vec3( UNSKEWFACTOR ) );\\n`;\n functionString += ` vec3 g = step(x0.yzx, x0.xyz);\\n`;\n functionString += ` vec3 l = 1.0 - g;\\n`;\n functionString += ` vec3 Pi_1 = min( g.xyz, l.zxy );\\n`;\n functionString += ` vec3 Pi_2 = max( g.xyz, l.zxy );\\n`;\n functionString += ` vec3 x1 = x0 - Pi_1 + UNSKEWFACTOR;\\n`;\n functionString += ` vec3 x2 = x0 - Pi_2 + SKEWFACTOR;\\n`;\n functionString += ` vec3 x3 = x0 - SIMPLEX_CORNER_POS;\\n`;\n functionString += ` vec4 v1234_x = vec4( x0.x, x1.x, x2.x, x3.x );\\n`;\n functionString += ` vec4 v1234_y = vec4( x0.y, x1.y, x2.y, x3.y );\\n`;\n functionString += ` vec4 v1234_z = vec4( x0.z, x1.z, x2.z, x3.z );\\n`;\n functionString += ` Pi = Pi.xyz - floor(Pi.xyz * ( 1.0 / 69.0 )) * 69.0;\\n`;\n functionString += ` vec3 Pi_inc1 = step( Pi, vec3( 69.0 - 1.5 ) ) * ( Pi + 1.0 );\\n`;\n functionString += ` vec4 Pt = vec4( Pi.xy, Pi_inc1.xy ) + vec2( 50.0, 161.0 ).xyxy;\\n`;\n functionString += ` Pt *= Pt;\\n`;\n functionString += ` vec4 V1xy_V2xy = mix( Pt.xyxy, Pt.zwzw, vec4( Pi_1.xy, Pi_2.xy ) );\\n`;\n functionString += ` Pt = vec4( Pt.x, V1xy_V2xy.xz, Pt.z ) * vec4( Pt.y, V1xy_V2xy.yw, Pt.w );\\n`;\n functionString += ` const vec3 SOMELARGEFLOATS = vec3( 635.298681, 682.357502, 668.926525 );\\n`;\n functionString += ` const vec3 ZINC = vec3( 48.500388, 65.294118, 63.934599 );\\n`;\n functionString += ` vec3 lowz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi.zzz * ZINC.xyz ) );\\n`;\n functionString += ` vec3 highz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi_inc1.zzz * ZINC.xyz ) );\\n`;\n functionString += ` Pi_1 = [( Pi_1.z < 0.5 ) ? lowz_mods : highz_mods];\\n`;\n functionString += ` Pi_2 = [( Pi_2.z < 0.5 ) ? lowz_mods : highz_mods];\\n`;\n functionString += ` vec4 hash_0 = fract( Pt * vec4( lowz_mods.x, Pi_1.x, Pi_2.x, highz_mods.x ) ) - 0.49999;\\n`;\n functionString += ` vec4 hash_1 = fract( Pt * vec4( lowz_mods.y, Pi_1.y, Pi_2.y, highz_mods.y ) ) - 0.49999;\\n`;\n functionString += ` vec4 hash_2 = fract( Pt * vec4( lowz_mods.z, Pi_1.z, Pi_2.z, highz_mods.z ) ) - 0.49999;\\n`;\n functionString += ` vec4 grad_results = inversesqrt( hash_0 * hash_0 + hash_1 * hash_1 + hash_2 * hash_2 ) * ( hash_0 * v1234_x + hash_1 * v1234_y + hash_2 * v1234_z );\\n`;\n functionString += ` const float FINAL_NORMALIZATION = 37.837227241611314102871574478976;\\n`;\n functionString += ` vec4 kernel_weights = v1234_x * v1234_x + v1234_y * v1234_y + v1234_z * v1234_z;\\n`;\n functionString += ` kernel_weights = max(0.5 - kernel_weights, vec4(0.));\\n`;\n functionString += ` kernel_weights = kernel_weights*kernel_weights*kernel_weights;\\n`;\n functionString += ` return dot( kernel_weights, grad_results ) * FINAL_NORMALIZATION;\\n`;\n functionString += `}\\n`;\n if (state.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n functionString = state._babylonSLtoWGSL(functionString);\n } else {\n functionString = state._babylonSLtoGLSL(functionString);\n }\n state._emitFunction(\"SimplexPerlin3D\", functionString, \"// SimplexPerlin3D\");\n state.compilationString += state._declareOutput(this._outputs[0]) + ` = SimplexPerlin3D(${this.seed.associatedVariableName});\\n`;\n return this;\n }\n}\nRegisterClass(\"BABYLON.SimplexPerlin3DBlock\", SimplexPerlin3DBlock);","map":{"version":3,"names":["NodeMaterialBlock","NodeMaterialBlockConnectionPointTypes","NodeMaterialBlockTargets","RegisterClass","SimplexPerlin3DBlock","constructor","name","Neutral","registerInput","Vector3","registerOutput","Float","getClassName","seed","_inputs","output","_outputs","_buildBlock","state","isConnected","hasEndpoints","functionString","shaderLanguage","_babylonSLtoWGSL","_babylonSLtoGLSL","_emitFunction","compilationString","_declareOutput","associatedVariableName"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/Node/Blocks/simplexPerlin3DBlock.js"],"sourcesContent":["import { NodeMaterialBlock } from \"../nodeMaterialBlock.js\";\nimport { NodeMaterialBlockConnectionPointTypes } from \"../Enums/nodeMaterialBlockConnectionPointTypes.js\";\nimport { NodeMaterialBlockTargets } from \"../Enums/nodeMaterialBlockTargets.js\";\nimport { RegisterClass } from \"../../../Misc/typeStore.js\";\n/**\n * block used to Generate a Simplex Perlin 3d Noise Pattern\n */\n//\n// Wombat\n// An efficient texture-free GLSL procedural noise library\n// Source: https://github.com/BrianSharpe/Wombat\n// Derived from: https://github.com/BrianSharpe/GPU-Noise-Lib\n//\n// I'm not one for copyrights. Use the code however you wish.\n// All I ask is that credit be given back to the blog or myself when appropriate.\n// And also to let me know if you come up with any changes, improvements, thoughts or interesting uses for this stuff. :)\n// Thanks!\n//\n// Brian Sharpe\n// brisharpe CIRCLE_A yahoo DOT com\n// http://briansharpe.wordpress.com\n// https://github.com/BrianSharpe\n//\n//\n// This is a modified version of Stefan Gustavson's and Ian McEwan's work at http://github.com/ashima/webgl-noise\n// Modifications are...\n// - faster random number generation\n// - analytical final normalization\n// - space scaled can have an approx feature size of 1.0\n// - filter kernel changed to fix discontinuities at tetrahedron boundaries\n//\n// Converted to BJS by Pryme8\n//\n// Simplex Perlin Noise 3D\n// Return value range of -1.0->1.0\n//\nexport class SimplexPerlin3DBlock extends NodeMaterialBlock {\n /**\n * Creates a new SimplexPerlin3DBlock\n * @param name defines the block name\n */\n constructor(name) {\n super(name, NodeMaterialBlockTargets.Neutral);\n this.registerInput(\"seed\", NodeMaterialBlockConnectionPointTypes.Vector3);\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Float);\n }\n /**\n * Gets the current class name\n * @returns the class name\n */\n getClassName() {\n return \"SimplexPerlin3DBlock\";\n }\n /**\n * Gets the seed operand input component\n */\n get seed() {\n return this._inputs[0];\n }\n /**\n * Gets the output component\n */\n get output() {\n return this._outputs[0];\n }\n _buildBlock(state) {\n super._buildBlock(state);\n if (!this.seed.isConnected) {\n return;\n }\n if (!this._outputs[0].hasEndpoints) {\n return;\n }\n let functionString = `const float SKEWFACTOR = 1.0/3.0;\\n`;\n functionString += `const float UNSKEWFACTOR = 1.0/6.0;\\n`;\n functionString += `const float SIMPLEX_CORNER_POS = 0.5;\\n`;\n functionString += `const float SIMPLEX_TETRAHADRON_HEIGHT = 0.70710678118654752440084436210485;\\n`;\n functionString += `float SimplexPerlin3D( vec3 source ){\\n`;\n functionString += ` vec3 P = source;\\n`;\n functionString += ` P.x = [P.x == 0. && P.y == 0. && P.z == 0. ? 0.00001 : P.x];\\n`;\n functionString += ` P *= SIMPLEX_TETRAHADRON_HEIGHT;\\n`;\n functionString += ` vec3 Pi = floor( P + dot( P, vec3( SKEWFACTOR) ) );`;\n functionString += ` vec3 x0 = P - Pi + dot(Pi, vec3( UNSKEWFACTOR ) );\\n`;\n functionString += ` vec3 g = step(x0.yzx, x0.xyz);\\n`;\n functionString += ` vec3 l = 1.0 - g;\\n`;\n functionString += ` vec3 Pi_1 = min( g.xyz, l.zxy );\\n`;\n functionString += ` vec3 Pi_2 = max( g.xyz, l.zxy );\\n`;\n functionString += ` vec3 x1 = x0 - Pi_1 + UNSKEWFACTOR;\\n`;\n functionString += ` vec3 x2 = x0 - Pi_2 + SKEWFACTOR;\\n`;\n functionString += ` vec3 x3 = x0 - SIMPLEX_CORNER_POS;\\n`;\n functionString += ` vec4 v1234_x = vec4( x0.x, x1.x, x2.x, x3.x );\\n`;\n functionString += ` vec4 v1234_y = vec4( x0.y, x1.y, x2.y, x3.y );\\n`;\n functionString += ` vec4 v1234_z = vec4( x0.z, x1.z, x2.z, x3.z );\\n`;\n functionString += ` Pi = Pi.xyz - floor(Pi.xyz * ( 1.0 / 69.0 )) * 69.0;\\n`;\n functionString += ` vec3 Pi_inc1 = step( Pi, vec3( 69.0 - 1.5 ) ) * ( Pi + 1.0 );\\n`;\n functionString += ` vec4 Pt = vec4( Pi.xy, Pi_inc1.xy ) + vec2( 50.0, 161.0 ).xyxy;\\n`;\n functionString += ` Pt *= Pt;\\n`;\n functionString += ` vec4 V1xy_V2xy = mix( Pt.xyxy, Pt.zwzw, vec4( Pi_1.xy, Pi_2.xy ) );\\n`;\n functionString += ` Pt = vec4( Pt.x, V1xy_V2xy.xz, Pt.z ) * vec4( Pt.y, V1xy_V2xy.yw, Pt.w );\\n`;\n functionString += ` const vec3 SOMELARGEFLOATS = vec3( 635.298681, 682.357502, 668.926525 );\\n`;\n functionString += ` const vec3 ZINC = vec3( 48.500388, 65.294118, 63.934599 );\\n`;\n functionString += ` vec3 lowz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi.zzz * ZINC.xyz ) );\\n`;\n functionString += ` vec3 highz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi_inc1.zzz * ZINC.xyz ) );\\n`;\n functionString += ` Pi_1 = [( Pi_1.z < 0.5 ) ? lowz_mods : highz_mods];\\n`;\n functionString += ` Pi_2 = [( Pi_2.z < 0.5 ) ? lowz_mods : highz_mods];\\n`;\n functionString += ` vec4 hash_0 = fract( Pt * vec4( lowz_mods.x, Pi_1.x, Pi_2.x, highz_mods.x ) ) - 0.49999;\\n`;\n functionString += ` vec4 hash_1 = fract( Pt * vec4( lowz_mods.y, Pi_1.y, Pi_2.y, highz_mods.y ) ) - 0.49999;\\n`;\n functionString += ` vec4 hash_2 = fract( Pt * vec4( lowz_mods.z, Pi_1.z, Pi_2.z, highz_mods.z ) ) - 0.49999;\\n`;\n functionString += ` vec4 grad_results = inversesqrt( hash_0 * hash_0 + hash_1 * hash_1 + hash_2 * hash_2 ) * ( hash_0 * v1234_x + hash_1 * v1234_y + hash_2 * v1234_z );\\n`;\n functionString += ` const float FINAL_NORMALIZATION = 37.837227241611314102871574478976;\\n`;\n functionString += ` vec4 kernel_weights = v1234_x * v1234_x + v1234_y * v1234_y + v1234_z * v1234_z;\\n`;\n functionString += ` kernel_weights = max(0.5 - kernel_weights, vec4(0.));\\n`;\n functionString += ` kernel_weights = kernel_weights*kernel_weights*kernel_weights;\\n`;\n functionString += ` return dot( kernel_weights, grad_results ) * FINAL_NORMALIZATION;\\n`;\n functionString += `}\\n`;\n if (state.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {\n functionString = state._babylonSLtoWGSL(functionString);\n }\n else {\n functionString = state._babylonSLtoGLSL(functionString);\n }\n state._emitFunction(\"SimplexPerlin3D\", functionString, \"// SimplexPerlin3D\");\n state.compilationString += state._declareOutput(this._outputs[0]) + ` = SimplexPerlin3D(${this.seed.associatedVariableName});\\n`;\n return this;\n }\n}\nRegisterClass(\"BABYLON.SimplexPerlin3DBlock\", SimplexPerlin3DBlock);\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,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