@babylonjs/core 5.30.0 → 5.31.0
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.
- package/Cameras/cameraInputsManager.d.ts +2 -2
- package/Cameras/cameraInputsManager.js +5 -4
- package/Cameras/cameraInputsManager.js.map +1 -1
- package/Engines/Processors/iShaderProcessor.d.ts +4 -0
- package/Engines/Processors/iShaderProcessor.js.map +1 -1
- package/Engines/Processors/shaderCodeNode.js +11 -2
- package/Engines/Processors/shaderCodeNode.js.map +1 -1
- package/Engines/Processors/shaderProcessor.js +4 -1
- package/Engines/Processors/shaderProcessor.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.d.ts +6 -0
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +36 -8
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
- package/Engines/nativeEngine.js +1 -0
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Layers/effectLayer.js +1 -1
- package/Layers/effectLayer.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.d.ts +3 -1
- package/Lights/Shadows/cascadedShadowGenerator.js +19 -16
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.d.ts +6 -2
- package/Lights/Shadows/shadowGenerator.js +32 -7
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGeneratorSceneComponent.js +16 -8
- package/Lights/Shadows/shadowGeneratorSceneComponent.js.map +1 -1
- package/Lights/light.d.ts +10 -3
- package/Lights/light.js +28 -6
- package/Lights/light.js.map +1 -1
- package/Lights/pointLight.js +6 -2
- package/Lights/pointLight.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.d.ts +3 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +8 -2
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.d.ts +4 -0
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js +11 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.d.ts +1 -0
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js +7 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
- package/Materials/materialHelper.js +2 -1
- package/Materials/materialHelper.js.map +1 -1
- package/Materials/uniformBuffer.js +1 -1
- package/Materials/uniformBuffer.js.map +1 -1
- package/Maths/math.vector.d.ts +16 -0
- package/Maths/math.vector.js +16 -0
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/abstractMesh.js +11 -7
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +2 -2
- package/Meshes/mesh.js +26 -18
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/transformNode.d.ts +1 -1
- package/Meshes/transformNode.js +1 -1
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/sceneRecorder.js +10 -4
- package/Misc/sceneRecorder.js.map +1 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +3 -3
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/helperFunctions.js +2 -2
- package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/mrtFragmentDeclaration.js +1 -1
- package/Shaders/ShadersInclude/mrtFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/shadowsFragmentFunctions.js +3 -3
- package/Shaders/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
- package/Shaders/fxaa.fragment.js +1 -1
- package/Shaders/fxaa.fragment.js.map +1 -1
- package/Shaders/spriteMap.fragment.js +1 -1
- package/Shaders/spriteMap.fragment.js.map +1 -1
- package/package.json +1 -1
|
@@ -88,8 +88,8 @@ export declare class CameraInputsManager<TCamera extends Camera> {
|
|
|
88
88
|
constructor(camera: TCamera);
|
|
89
89
|
/**
|
|
90
90
|
* Add an input method to a camera
|
|
91
|
-
* @see https://doc.babylonjs.com/
|
|
92
|
-
* @param input
|
|
91
|
+
* @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs
|
|
92
|
+
* @param input Camera input method
|
|
93
93
|
*/
|
|
94
94
|
add(input: ICameraInput<TCamera>): void;
|
|
95
95
|
/**
|
|
@@ -30,8 +30,8 @@ export class CameraInputsManager {
|
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Add an input method to a camera
|
|
33
|
-
* @see https://doc.babylonjs.com/
|
|
34
|
-
* @param input
|
|
33
|
+
* @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs
|
|
34
|
+
* @param input Camera input method
|
|
35
35
|
*/
|
|
36
36
|
add(input) {
|
|
37
37
|
const type = input.getSimpleName();
|
|
@@ -41,8 +41,8 @@ export class CameraInputsManager {
|
|
|
41
41
|
}
|
|
42
42
|
this.attached[type] = input;
|
|
43
43
|
input.camera = this.camera;
|
|
44
|
-
//for checkInputs, we are dynamically creating a function
|
|
45
|
-
//the goal is to avoid the performance penalty of looping for inputs in the render loop
|
|
44
|
+
// for checkInputs, we are dynamically creating a function
|
|
45
|
+
// the goal is to avoid the performance penalty of looping for inputs in the render loop
|
|
46
46
|
if (input.checkInputs) {
|
|
47
47
|
this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
|
|
48
48
|
}
|
|
@@ -63,6 +63,7 @@ export class CameraInputsManager {
|
|
|
63
63
|
input.camera = null;
|
|
64
64
|
delete this.attached[cam];
|
|
65
65
|
this.rebuildInputCheck();
|
|
66
|
+
return;
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cameraInputsManager.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Cameras/camera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AC;gBAC3E,IAAI,SAAS,EAAE;oBACX,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,CACnC,GAAG,EAAE;wBACD,OAAO,IAAI,SAAS,EAAE,CAAC;oBAC3B,CAAC,EACD,YAAY,EACZ,IAAI,CACP,CAAC;oBACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC9B,IAAI,CAAC,GAAG,CAAC,KAAY,CAAC,CAAC;iBAC1B;aACJ;SACJ;IACL,CAAC;CACJ","sourcesContent":["import { Logger } from \"../Misc/logger\";\r\nimport { SerializationHelper } from \"../Misc/decorators\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Camera } from \"./camera\";\r\n/**\r\n * @ignore\r\n * This is a list of all the different input types that are available in the application.\r\n * Fo instance: ArcRotateCameraGamepadInput...\r\n */\r\n// eslint-disable-next-line no-var, @typescript-eslint/naming-convention\r\nexport var CameraInputTypes = {};\r\n\r\n/**\r\n * This is the contract to implement in order to create a new input class.\r\n * Inputs are dealing with listening to user actions and moving the camera accordingly.\r\n */\r\nexport interface ICameraInput<TCamera extends Camera> {\r\n /**\r\n * Defines the camera the input is attached to.\r\n */\r\n camera: Nullable<TCamera>;\r\n /**\r\n * Gets the class name of the current input.\r\n * @returns the class name\r\n */\r\n getClassName(): string;\r\n /**\r\n * Get the friendly name associated with the input class.\r\n * @returns the input friendly name\r\n */\r\n getSimpleName(): string;\r\n /**\r\n * Attach the input controls to a specific dom element to get the input from.\r\n * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)\r\n */\r\n attachControl(noPreventDefault?: boolean): void;\r\n /**\r\n * Detach the current controls from the specified dom element.\r\n */\r\n detachControl(): void;\r\n /**\r\n * Update the current camera state depending on the inputs that have been used this frame.\r\n * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.\r\n */\r\n checkInputs?: () => void;\r\n}\r\n\r\n/**\r\n * Represents a map of input types to input instance or input index to input instance.\r\n */\r\nexport interface CameraInputsMap<TCamera extends Camera> {\r\n /**\r\n * Accessor to the input by input type.\r\n */\r\n [name: string]: ICameraInput<TCamera>;\r\n /**\r\n * Accessor to the input by input index.\r\n */\r\n [idx: number]: ICameraInput<TCamera>;\r\n}\r\n\r\n/**\r\n * This represents the input manager used within a camera.\r\n * It helps dealing with all the different kind of input attached to a camera.\r\n * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs\r\n */\r\nexport class CameraInputsManager<TCamera extends Camera> {\r\n /**\r\n * Defines the list of inputs attached to the camera.\r\n */\r\n public attached: CameraInputsMap<TCamera>;\r\n\r\n /**\r\n * Defines the dom element the camera is collecting inputs from.\r\n * This is null if the controls have not been attached.\r\n */\r\n public attachedToElement: boolean = false;\r\n\r\n /**\r\n * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)\r\n */\r\n public noPreventDefault: boolean;\r\n\r\n /**\r\n * Defined the camera the input manager belongs to.\r\n */\r\n public camera: TCamera;\r\n\r\n /**\r\n * Update the current camera state depending on the inputs that have been used this frame.\r\n * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.\r\n */\r\n public checkInputs: () => void;\r\n\r\n /**\r\n * Instantiate a new Camera Input Manager.\r\n * @param camera Defines the camera the input manager belongs to\r\n */\r\n constructor(camera: TCamera) {\r\n this.attached = {};\r\n this.camera = camera;\r\n this.checkInputs = () => {};\r\n }\r\n\r\n /**\r\n * Add an input method to a camera\r\n * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs\r\n * @param input camera input method\r\n */\r\n public add(input: ICameraInput<TCamera>): void {\r\n const type = input.getSimpleName();\r\n if (this.attached[type]) {\r\n Logger.Warn(\"camera input of type \" + type + \" already exists on camera\");\r\n return;\r\n }\r\n\r\n this.attached[type] = input;\r\n\r\n input.camera = this.camera;\r\n\r\n //for checkInputs, we are dynamically creating a function\r\n //the goal is to avoid the performance penalty of looping for inputs in the render loop\r\n if (input.checkInputs) {\r\n this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));\r\n }\r\n\r\n if (this.attachedToElement) {\r\n input.attachControl(this.noPreventDefault);\r\n }\r\n }\r\n\r\n /**\r\n * Remove a specific input method from a camera\r\n * example: camera.inputs.remove(camera.inputs.attached.mouse);\r\n * @param inputToRemove camera input method\r\n */\r\n public remove(inputToRemove: ICameraInput<TCamera>): void {\r\n for (const cam in this.attached) {\r\n const input = this.attached[cam];\r\n if (input === inputToRemove) {\r\n input.detachControl();\r\n input.camera = null;\r\n delete this.attached[cam];\r\n this.rebuildInputCheck();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Remove a specific input type from a camera\r\n * example: camera.inputs.remove(\"ArcRotateCameraGamepadInput\");\r\n * @param inputType the type of the input to remove\r\n */\r\n public removeByType(inputType: string): void {\r\n for (const cam in this.attached) {\r\n const input = this.attached[cam];\r\n if (input.getClassName() === inputType) {\r\n input.detachControl();\r\n input.camera = null;\r\n delete this.attached[cam];\r\n this.rebuildInputCheck();\r\n }\r\n }\r\n }\r\n\r\n private _addCheckInputs(fn: () => void) {\r\n const current = this.checkInputs;\r\n return () => {\r\n current();\r\n fn();\r\n };\r\n }\r\n\r\n /**\r\n * Attach the input controls to the currently attached dom element to listen the events from.\r\n * @param input Defines the input to attach\r\n */\r\n public attachInput(input: ICameraInput<TCamera>): void {\r\n if (this.attachedToElement) {\r\n input.attachControl(this.noPreventDefault);\r\n }\r\n }\r\n\r\n /**\r\n * Attach the current manager inputs controls to a specific dom element to listen the events from.\r\n * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)\r\n */\r\n public attachElement(noPreventDefault: boolean = false): void {\r\n if (this.attachedToElement) {\r\n return;\r\n }\r\n\r\n noPreventDefault = Camera.ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;\r\n this.attachedToElement = true;\r\n this.noPreventDefault = noPreventDefault;\r\n\r\n for (const cam in this.attached) {\r\n this.attached[cam].attachControl(noPreventDefault);\r\n }\r\n }\r\n\r\n /**\r\n * Detach the current manager inputs controls from a specific dom element.\r\n * @param disconnect Defines whether the input should be removed from the current list of attached inputs\r\n */\r\n public detachElement(disconnect = false): void {\r\n for (const cam in this.attached) {\r\n this.attached[cam].detachControl();\r\n\r\n if (disconnect) {\r\n this.attached[cam].camera = null;\r\n }\r\n }\r\n this.attachedToElement = false;\r\n }\r\n\r\n /**\r\n * Rebuild the dynamic inputCheck function from the current list of\r\n * defined inputs in the manager.\r\n */\r\n public rebuildInputCheck(): void {\r\n this.checkInputs = () => {};\r\n\r\n for (const cam in this.attached) {\r\n const input = this.attached[cam];\r\n if (input.checkInputs) {\r\n this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Remove all attached input methods from a camera\r\n */\r\n public clear(): void {\r\n if (this.attachedToElement) {\r\n this.detachElement(true);\r\n }\r\n this.attached = {};\r\n this.attachedToElement = false;\r\n this.checkInputs = () => {};\r\n }\r\n\r\n /**\r\n * Serialize the current input manager attached to a camera.\r\n * This ensures than once parsed,\r\n * the input associated to the camera will be identical to the current ones\r\n * @param serializedCamera Defines the camera serialization JSON the input serialization should write to\r\n */\r\n public serialize(serializedCamera: any): void {\r\n const inputs: { [key: string]: any } = {};\r\n for (const cam in this.attached) {\r\n const input = this.attached[cam];\r\n const res = SerializationHelper.Serialize(input);\r\n inputs[input.getClassName()] = res;\r\n }\r\n\r\n serializedCamera.inputsmgr = inputs;\r\n }\r\n\r\n /**\r\n * Parses an input manager serialized JSON to restore the previous list of inputs\r\n * and states associated to a camera.\r\n * @param parsedCamera Defines the JSON to parse\r\n */\r\n public parse(parsedCamera: any): void {\r\n const parsedInputs = parsedCamera.inputsmgr;\r\n if (parsedInputs) {\r\n this.clear();\r\n\r\n for (const n in parsedInputs) {\r\n const construct = (<any>CameraInputTypes)[n];\r\n if (construct) {\r\n const parsedinput = parsedInputs[n];\r\n const input = SerializationHelper.Parse(\r\n () => {\r\n return new construct();\r\n },\r\n parsedinput,\r\n null\r\n );\r\n this.add(input as any);\r\n }\r\n }\r\n } else {\r\n //2016-03-08 this part is for managing backward compatibility\r\n for (const n in this.attached) {\r\n const construct = (<any>CameraInputTypes)[this.attached[n].getClassName()];\r\n if (construct) {\r\n const input = SerializationHelper.Parse(\r\n () => {\r\n return new construct();\r\n },\r\n parsedCamera,\r\n null\r\n );\r\n this.remove(this.attached[n]);\r\n this.add(input as any);\r\n }\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"cameraInputsManager.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Cameras/cameraInputsManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC;;;;GAIG;AACH,wEAAwE;AACxE,MAAM,CAAC,IAAI,gBAAgB,GAAG,EAAE,CAAC;AAmDjC;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IA4B5B;;;OAGG;IACH,YAAY,MAAe;QA1B3B;;;WAGG;QACI,sBAAiB,GAAY,KAAK,CAAC;QAuBtC,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACI,GAAG,CAAC,KAA4B;QACnC,MAAM,IAAI,GAAG,KAAK,CAAC,aAAa,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACrB,MAAM,CAAC,IAAI,CAAC,uBAAuB,GAAG,IAAI,GAAG,2BAA2B,CAAC,CAAC;YAC1E,OAAO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AI,SAAS,EAAE;oBACX,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;oBACpC,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,CACnC,GAAG,EAAE;wBACD,OAAO,IAAI,SAAS,EAAE,CAAC;oBAC3B,CAAC,EACD,WAAW,EACX,IAAI,CACP,CAAC;oBACF,IAAI,CAAC,GAAG,CAAC,KAAY,CAAC,CAAC;iBAC1B;aACJ;SACJ;aAAM;YACH,6DAA6D;YAC7D,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE;gBAC3B,MAAM,SAAS,GAAS,gBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC;gBAC3E,IAAI,SAAS,EAAE;oBACX,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,CACnC,GAAG,EAAE;wBACD,OAAO,IAAI,SAAS,EAAE,CAAC;oBAC3B,CAAC,EACD,YAAY,EACZ,IAAI,CACP,CAAC;oBACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC9B,IAAI,CAAC,GAAG,CAAC,KAAY,CAAC,CAAC;iBAC1B;aACJ;SACJ;IACL,CAAC;CACJ","sourcesContent":["import { Logger } from \"../Misc/logger\";\r\nimport { SerializationHelper } from \"../Misc/decorators\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Camera } from \"./camera\";\r\n/**\r\n * @ignore\r\n * This is a list of all the different input types that are available in the application.\r\n * Fo instance: ArcRotateCameraGamepadInput...\r\n */\r\n// eslint-disable-next-line no-var, @typescript-eslint/naming-convention\r\nexport var CameraInputTypes = {};\r\n\r\n/**\r\n * This is the contract to implement in order to create a new input class.\r\n * Inputs are dealing with listening to user actions and moving the camera accordingly.\r\n */\r\nexport interface ICameraInput<TCamera extends Camera> {\r\n /**\r\n * Defines the camera the input is attached to.\r\n */\r\n camera: Nullable<TCamera>;\r\n /**\r\n * Gets the class name of the current input.\r\n * @returns the class name\r\n */\r\n getClassName(): string;\r\n /**\r\n * Get the friendly name associated with the input class.\r\n * @returns the input friendly name\r\n */\r\n getSimpleName(): string;\r\n /**\r\n * Attach the input controls to a specific dom element to get the input from.\r\n * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)\r\n */\r\n attachControl(noPreventDefault?: boolean): void;\r\n /**\r\n * Detach the current controls from the specified dom element.\r\n */\r\n detachControl(): void;\r\n /**\r\n * Update the current camera state depending on the inputs that have been used this frame.\r\n * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.\r\n */\r\n checkInputs?: () => void;\r\n}\r\n\r\n/**\r\n * Represents a map of input types to input instance or input index to input instance.\r\n */\r\nexport interface CameraInputsMap<TCamera extends Camera> {\r\n /**\r\n * Accessor to the input by input type.\r\n */\r\n [name: string]: ICameraInput<TCamera>;\r\n /**\r\n * Accessor to the input by input index.\r\n */\r\n [idx: number]: ICameraInput<TCamera>;\r\n}\r\n\r\n/**\r\n * This represents the input manager used within a camera.\r\n * It helps dealing with all the different kind of input attached to a camera.\r\n * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs\r\n */\r\nexport class CameraInputsManager<TCamera extends Camera> {\r\n /**\r\n * Defines the list of inputs attached to the camera.\r\n */\r\n public attached: CameraInputsMap<TCamera>;\r\n\r\n /**\r\n * Defines the dom element the camera is collecting inputs from.\r\n * This is null if the controls have not been attached.\r\n */\r\n public attachedToElement: boolean = false;\r\n\r\n /**\r\n * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)\r\n */\r\n public noPreventDefault: boolean;\r\n\r\n /**\r\n * Defined the camera the input manager belongs to.\r\n */\r\n public camera: TCamera;\r\n\r\n /**\r\n * Update the current camera state depending on the inputs that have been used this frame.\r\n * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.\r\n */\r\n public checkInputs: () => void;\r\n\r\n /**\r\n * Instantiate a new Camera Input Manager.\r\n * @param camera Defines the camera the input manager belongs to\r\n */\r\n constructor(camera: TCamera) {\r\n this.attached = {};\r\n this.camera = camera;\r\n this.checkInputs = () => {};\r\n }\r\n\r\n /**\r\n * Add an input method to a camera\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs\r\n * @param input Camera input method\r\n */\r\n public add(input: ICameraInput<TCamera>): void {\r\n const type = input.getSimpleName();\r\n if (this.attached[type]) {\r\n Logger.Warn(\"camera input of type \" + type + \" already exists on camera\");\r\n return;\r\n }\r\n\r\n this.attached[type] = input;\r\n\r\n input.camera = this.camera;\r\n\r\n // for checkInputs, we are dynamically creating a function\r\n // the goal is to avoid the performance penalty of looping for inputs in the render loop\r\n if (input.checkInputs) {\r\n this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));\r\n }\r\n\r\n if (this.attachedToElement) {\r\n input.attachControl(this.noPreventDefault);\r\n }\r\n }\r\n\r\n /**\r\n * Remove a specific input method from a camera\r\n * example: camera.inputs.remove(camera.inputs.attached.mouse);\r\n * @param inputToRemove camera input method\r\n */\r\n public remove(inputToRemove: ICameraInput<TCamera>): void {\r\n for (const cam in this.attached) {\r\n const input = this.attached[cam];\r\n if (input === inputToRemove) {\r\n input.detachControl();\r\n input.camera = null;\r\n delete this.attached[cam];\r\n this.rebuildInputCheck();\r\n\r\n return;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Remove a specific input type from a camera\r\n * example: camera.inputs.remove(\"ArcRotateCameraGamepadInput\");\r\n * @param inputType the type of the input to remove\r\n */\r\n public removeByType(inputType: string): void {\r\n for (const cam in this.attached) {\r\n const input = this.attached[cam];\r\n if (input.getClassName() === inputType) {\r\n input.detachControl();\r\n input.camera = null;\r\n delete this.attached[cam];\r\n this.rebuildInputCheck();\r\n }\r\n }\r\n }\r\n\r\n private _addCheckInputs(fn: () => void) {\r\n const current = this.checkInputs;\r\n return () => {\r\n current();\r\n fn();\r\n };\r\n }\r\n\r\n /**\r\n * Attach the input controls to the currently attached dom element to listen the events from.\r\n * @param input Defines the input to attach\r\n */\r\n public attachInput(input: ICameraInput<TCamera>): void {\r\n if (this.attachedToElement) {\r\n input.attachControl(this.noPreventDefault);\r\n }\r\n }\r\n\r\n /**\r\n * Attach the current manager inputs controls to a specific dom element to listen the events from.\r\n * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)\r\n */\r\n public attachElement(noPreventDefault: boolean = false): void {\r\n if (this.attachedToElement) {\r\n return;\r\n }\r\n\r\n noPreventDefault = Camera.ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;\r\n this.attachedToElement = true;\r\n this.noPreventDefault = noPreventDefault;\r\n\r\n for (const cam in this.attached) {\r\n this.attached[cam].attachControl(noPreventDefault);\r\n }\r\n }\r\n\r\n /**\r\n * Detach the current manager inputs controls from a specific dom element.\r\n * @param disconnect Defines whether the input should be removed from the current list of attached inputs\r\n */\r\n public detachElement(disconnect = false): void {\r\n for (const cam in this.attached) {\r\n this.attached[cam].detachControl();\r\n\r\n if (disconnect) {\r\n this.attached[cam].camera = null;\r\n }\r\n }\r\n this.attachedToElement = false;\r\n }\r\n\r\n /**\r\n * Rebuild the dynamic inputCheck function from the current list of\r\n * defined inputs in the manager.\r\n */\r\n public rebuildInputCheck(): void {\r\n this.checkInputs = () => {};\r\n\r\n for (const cam in this.attached) {\r\n const input = this.attached[cam];\r\n if (input.checkInputs) {\r\n this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Remove all attached input methods from a camera\r\n */\r\n public clear(): void {\r\n if (this.attachedToElement) {\r\n this.detachElement(true);\r\n }\r\n this.attached = {};\r\n this.attachedToElement = false;\r\n this.checkInputs = () => {};\r\n }\r\n\r\n /**\r\n * Serialize the current input manager attached to a camera.\r\n * This ensures than once parsed,\r\n * the input associated to the camera will be identical to the current ones\r\n * @param serializedCamera Defines the camera serialization JSON the input serialization should write to\r\n */\r\n public serialize(serializedCamera: any): void {\r\n const inputs: { [key: string]: any } = {};\r\n for (const cam in this.attached) {\r\n const input = this.attached[cam];\r\n const res = SerializationHelper.Serialize(input);\r\n inputs[input.getClassName()] = res;\r\n }\r\n\r\n serializedCamera.inputsmgr = inputs;\r\n }\r\n\r\n /**\r\n * Parses an input manager serialized JSON to restore the previous list of inputs\r\n * and states associated to a camera.\r\n * @param parsedCamera Defines the JSON to parse\r\n */\r\n public parse(parsedCamera: any): void {\r\n const parsedInputs = parsedCamera.inputsmgr;\r\n if (parsedInputs) {\r\n this.clear();\r\n\r\n for (const n in parsedInputs) {\r\n const construct = (<any>CameraInputTypes)[n];\r\n if (construct) {\r\n const parsedinput = parsedInputs[n];\r\n const input = SerializationHelper.Parse(\r\n () => {\r\n return new construct();\r\n },\r\n parsedinput,\r\n null\r\n );\r\n this.add(input as any);\r\n }\r\n }\r\n } else {\r\n //2016-03-08 this part is for managing backward compatibility\r\n for (const n in this.attached) {\r\n const construct = (<any>CameraInputTypes)[this.attached[n].getClassName()];\r\n if (construct) {\r\n const input = SerializationHelper.Parse(\r\n () => {\r\n return new construct();\r\n },\r\n parsedCamera,\r\n null\r\n );\r\n this.remove(this.attached[n]);\r\n this.add(input as any);\r\n }\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -9,6 +9,10 @@ export interface IShaderProcessor {
|
|
|
9
9
|
uniformBufferRegexp?: RegExp;
|
|
10
10
|
textureRegexp?: RegExp;
|
|
11
11
|
noPrecision?: boolean;
|
|
12
|
+
parseGLES3?: boolean;
|
|
13
|
+
attributeKeywordName?: string;
|
|
14
|
+
varyingVertexKeywordName?: string;
|
|
15
|
+
varyingFragmentKeywordName?: string;
|
|
12
16
|
preProcessShaderCode?: (code: string, isFragment: boolean) => string;
|
|
13
17
|
attributeProcessor?: (attribute: string, preProcessors: {
|
|
14
18
|
[key: string]: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iShaderProcessor.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Engines/Processors/iShaderProcessor.ts"],"names":[],"mappings":"","sourcesContent":["import type { ShaderLanguage } from \"../../Materials/shaderLanguage\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { ShaderProcessingContext } from \"./shaderProcessingOptions\";\r\n\r\ndeclare type ThinEngine = import(\"../thinEngine\").ThinEngine;\r\n\r\n/** @internal */\r\nexport interface IShaderProcessor {\r\n shaderLanguage: ShaderLanguage;\r\n\r\n uniformRegexp?: RegExp;\r\n uniformBufferRegexp?: RegExp;\r\n textureRegexp?: RegExp;\r\n noPrecision?: boolean;\r\n\r\n preProcessShaderCode?: (code: string, isFragment: boolean) => string;\r\n attributeProcessor?: (attribute: string, preProcessors: { [key: string]: string }, processingContext: Nullable<ShaderProcessingContext>) => string;\r\n varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: { [key: string]: string }, processingContext: Nullable<ShaderProcessingContext>) => string;\r\n uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: { [key: string]: string }, processingContext: Nullable<ShaderProcessingContext>) => string;\r\n uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;\r\n textureProcessor?: (texture: string, isFragment: boolean, preProcessors: { [key: string]: string }, processingContext: Nullable<ShaderProcessingContext>) => string;\r\n endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;\r\n lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;\r\n preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;\r\n postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;\r\n initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;\r\n finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => { vertexCode: string; fragmentCode: string };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"iShaderProcessor.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Engines/Processors/iShaderProcessor.ts"],"names":[],"mappings":"","sourcesContent":["import type { ShaderLanguage } from \"../../Materials/shaderLanguage\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { ShaderProcessingContext } from \"./shaderProcessingOptions\";\r\n\r\ndeclare type ThinEngine = import(\"../thinEngine\").ThinEngine;\r\n\r\n/** @internal */\r\nexport interface IShaderProcessor {\r\n shaderLanguage: ShaderLanguage;\r\n\r\n uniformRegexp?: RegExp;\r\n uniformBufferRegexp?: RegExp;\r\n textureRegexp?: RegExp;\r\n noPrecision?: boolean;\r\n parseGLES3?: boolean;\r\n\r\n attributeKeywordName?: string;\r\n varyingVertexKeywordName?: string;\r\n varyingFragmentKeywordName?: string;\r\n\r\n preProcessShaderCode?: (code: string, isFragment: boolean) => string;\r\n attributeProcessor?: (attribute: string, preProcessors: { [key: string]: string }, processingContext: Nullable<ShaderProcessingContext>) => string;\r\n varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: { [key: string]: string }, processingContext: Nullable<ShaderProcessingContext>) => string;\r\n uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: { [key: string]: string }, processingContext: Nullable<ShaderProcessingContext>) => string;\r\n uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;\r\n textureProcessor?: (texture: string, isFragment: boolean, preProcessors: { [key: string]: string }, processingContext: Nullable<ShaderProcessingContext>) => string;\r\n endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;\r\n lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;\r\n preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;\r\n postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;\r\n initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;\r\n finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => { vertexCode: string; fragmentCode: string };\r\n}\r\n"]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const defaultAttributeKeywordName = "attribute";
|
|
2
|
+
const defaultVaryingKeywordName = "varying";
|
|
1
3
|
/** @internal */
|
|
2
4
|
export class ShaderCodeNode {
|
|
3
5
|
constructor() {
|
|
@@ -8,6 +10,7 @@ export class ShaderCodeNode {
|
|
|
8
10
|
return true;
|
|
9
11
|
}
|
|
10
12
|
process(preprocessors, options) {
|
|
13
|
+
var _a, _b, _c, _d, _e, _f;
|
|
11
14
|
let result = "";
|
|
12
15
|
if (this.line) {
|
|
13
16
|
let value = this.line;
|
|
@@ -17,10 +20,16 @@ export class ShaderCodeNode {
|
|
|
17
20
|
if (processor.lineProcessor) {
|
|
18
21
|
value = processor.lineProcessor(value, options.isFragment, options.processingContext);
|
|
19
22
|
}
|
|
20
|
-
|
|
23
|
+
const attributeKeyword = (_b = (_a = options.processor) === null || _a === void 0 ? void 0 : _a.attributeKeywordName) !== null && _b !== void 0 ? _b : defaultAttributeKeywordName;
|
|
24
|
+
const varyingKeyword = options.isFragment && ((_c = options.processor) === null || _c === void 0 ? void 0 : _c.varyingFragmentKeywordName)
|
|
25
|
+
? (_d = options.processor) === null || _d === void 0 ? void 0 : _d.varyingFragmentKeywordName
|
|
26
|
+
: !options.isFragment && ((_e = options.processor) === null || _e === void 0 ? void 0 : _e.varyingVertexKeywordName)
|
|
27
|
+
? (_f = options.processor) === null || _f === void 0 ? void 0 : _f.varyingVertexKeywordName
|
|
28
|
+
: defaultVaryingKeywordName;
|
|
29
|
+
if (!options.isFragment && processor.attributeProcessor && this.line.startsWith(attributeKeyword)) {
|
|
21
30
|
value = processor.attributeProcessor(this.line, preprocessors, options.processingContext);
|
|
22
31
|
}
|
|
23
|
-
else if (processor.varyingProcessor && this.line.startsWith(
|
|
32
|
+
else if (processor.varyingProcessor && this.line.startsWith(varyingKeyword)) {
|
|
24
33
|
value = processor.varyingProcessor(this.line, options.isFragment, preprocessors, options.processingContext);
|
|
25
34
|
}
|
|
26
35
|
else if (processor.uniformProcessor && processor.uniformRegexp && processor.uniformRegexp.test(this.line)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shaderCodeNode.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Engines/Processors/shaderCodeNode.ts"],"names":[],"mappings":"AAEA,gBAAgB;AAChB,MAAM,OAAO,cAAc;IAA3B;QAEI,aAAQ,GAAqB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"shaderCodeNode.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Engines/Processors/shaderCodeNode.ts"],"names":[],"mappings":"AAEA,MAAM,2BAA2B,GAAG,WAAW,CAAC;AAChD,MAAM,yBAAyB,GAAG,SAAS,CAAC;AAE5C,gBAAgB;AAChB,MAAM,OAAO,cAAc;IAA3B;QAEI,aAAQ,GAAqB,EAAE,CAAC;IAiFpC,CAAC;IA7EG,6DAA6D;IAC7D,OAAO,CAAC,aAAwC;QAC5C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,CAAC,aAAwC,EAAE,OAA0B;;QACxE,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,IAAI,CAAC,IAAI,EAAE;YACX,IAAI,KAAK,GAAW,IAAI,CAAC,IAAI,CAAC;YAC9B,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;YACpC,IAAI,SAAS,EAAE;gBACX,+GAA+G;gBAC/G,IAAI,SAAS,CAAC,aAAa,EAAE;oBACzB,KAAK,GAAG,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC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sBAAsB,EAAE;4BAClC,KAAK,GAAG,SAAS,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;4BACnG,OAAO,CAAC,qCAAqC,GAAG,IAAI,CAAC;yBACxD;qBACJ;iBACJ;gBAED,IAAI,OAAO,CAAC,qCAAqC,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;oBAChF,OAAO,CAAC,qCAAqC,GAAG,KAAK,CAAC;oBACtD,IAAI,SAAS,CAAC,2BAA2B,EAAE;wBACvC,KAAK,GAAG,SAAS,CAAC,2BAA2B,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;qBAC3G;iBACJ;aACJ;YAED,MAAM,IAAI,KAAK,GAAG,MAAM,CAAC;SAC5B;QAED,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,mBAAmB,EAAE;YAC1B,aAAa,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC,qBAAqB,IAAI,MAAM,CAAC;SAClF;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import type { ProcessingOptions } from \"./shaderProcessingOptions\";\r\n\r\nconst defaultAttributeKeywordName = \"attribute\";\r\nconst defaultVaryingKeywordName = \"varying\";\r\n\r\n/** @internal */\r\nexport class ShaderCodeNode {\r\n line: string;\r\n children: ShaderCodeNode[] = [];\r\n additionalDefineKey?: string;\r\n additionalDefineValue?: string;\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n isValid(preprocessors: { [key: string]: string }): boolean {\r\n return true;\r\n }\r\n\r\n process(preprocessors: { [key: string]: string }, options: ProcessingOptions): string {\r\n let result = \"\";\r\n if (this.line) {\r\n let value: string = this.line;\r\n const processor = options.processor;\r\n if (processor) {\r\n // This must be done before other replacements to avoid mistakenly changing something that was already changed.\r\n if (processor.lineProcessor) {\r\n value = processor.lineProcessor(value, options.isFragment, options.processingContext);\r\n }\r\n\r\n const attributeKeyword = options.processor?.attributeKeywordName ?? defaultAttributeKeywordName;\r\n const varyingKeyword =\r\n options.isFragment && options.processor?.varyingFragmentKeywordName\r\n ? options.processor?.varyingFragmentKeywordName\r\n : !options.isFragment && options.processor?.varyingVertexKeywordName\r\n ? options.processor?.varyingVertexKeywordName\r\n : defaultVaryingKeywordName;\r\n\r\n if (!options.isFragment && processor.attributeProcessor && this.line.startsWith(attributeKeyword)) {\r\n value = processor.attributeProcessor(this.line, preprocessors, options.processingContext);\r\n } else if (processor.varyingProcessor && this.line.startsWith(varyingKeyword)) {\r\n value = processor.varyingProcessor(this.line, options.isFragment, preprocessors, options.processingContext);\r\n } else if (processor.uniformProcessor && processor.uniformRegexp && processor.uniformRegexp.test(this.line)) {\r\n if (!options.lookForClosingBracketForUniformBuffer) {\r\n value = processor.uniformProcessor(this.line, options.isFragment, preprocessors, options.processingContext);\r\n }\r\n } else if (processor.uniformBufferProcessor && processor.uniformBufferRegexp && processor.uniformBufferRegexp.test(this.line)) {\r\n if (!options.lookForClosingBracketForUniformBuffer) {\r\n value = processor.uniformBufferProcessor(this.line, options.isFragment, options.processingContext);\r\n options.lookForClosingBracketForUniformBuffer = true;\r\n }\r\n } else if (processor.textureProcessor && processor.textureRegexp && processor.textureRegexp.test(this.line)) {\r\n value = processor.textureProcessor(this.line, options.isFragment, preprocessors, options.processingContext);\r\n } else if ((processor.uniformProcessor || processor.uniformBufferProcessor) && this.line.startsWith(\"uniform\") && !options.lookForClosingBracketForUniformBuffer) {\r\n const regex = /uniform\\s+(?:(?:highp)?|(?:lowp)?)\\s*(\\S+)\\s+(\\S+)\\s*;/;\r\n\r\n if (regex.test(this.line)) {\r\n // uniform\r\n if (processor.uniformProcessor) {\r\n value = processor.uniformProcessor(this.line, options.isFragment, preprocessors, options.processingContext);\r\n }\r\n } else {\r\n // Uniform buffer\r\n if (processor.uniformBufferProcessor) {\r\n value = processor.uniformBufferProcessor(this.line, options.isFragment, options.processingContext);\r\n options.lookForClosingBracketForUniformBuffer = true;\r\n }\r\n }\r\n }\r\n\r\n if (options.lookForClosingBracketForUniformBuffer && this.line.indexOf(\"}\") !== -1) {\r\n options.lookForClosingBracketForUniformBuffer = false;\r\n if (processor.endOfUniformBufferProcessor) {\r\n value = processor.endOfUniformBufferProcessor(this.line, options.isFragment, options.processingContext);\r\n }\r\n }\r\n }\r\n\r\n result += value + \"\\r\\n\";\r\n }\r\n\r\n this.children.forEach((child) => {\r\n result += child.process(preprocessors, options);\r\n });\r\n\r\n if (this.additionalDefineKey) {\r\n preprocessors[this.additionalDefineKey] = this.additionalDefineValue || \"true\";\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n"]}
|
|
@@ -250,7 +250,10 @@ export class ShaderProcessor {
|
|
|
250
250
|
}
|
|
251
251
|
// Already converted
|
|
252
252
|
if (options.processor.shaderLanguage === ShaderLanguage.GLSL && preparedSourceCode.indexOf("#version 3") !== -1) {
|
|
253
|
-
|
|
253
|
+
preparedSourceCode = preparedSourceCode.replace("#version 300 es", "");
|
|
254
|
+
if (!options.processor.parseGLES3) {
|
|
255
|
+
return preparedSourceCode;
|
|
256
|
+
}
|
|
254
257
|
}
|
|
255
258
|
const defines = options.defines;
|
|
256
259
|
const preprocessors = this._PreparePreProcessors(options, engine);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shaderProcessor.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Engines/Processors/shaderProcessor.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAA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\nimport { ShaderCodeNode } from \"./shaderCodeNode\";\r\nimport { ShaderCodeCursor } from \"./shaderCodeCursor\";\r\nimport { ShaderCodeConditionNode } from \"./shaderCodeConditionNode\";\r\nimport { ShaderCodeTestNode } from \"./shaderCodeTestNode\";\r\nimport { ShaderDefineIsDefinedOperator } from \"./Expressions/Operators/shaderDefineIsDefinedOperator\";\r\nimport { ShaderDefineOrOperator } from \"./Expressions/Operators/shaderDefineOrOperator\";\r\nimport { ShaderDefineAndOperator } from \"./Expressions/Operators/shaderDefineAndOperator\";\r\nimport { ShaderDefineExpression } from \"./Expressions/shaderDefineExpression\";\r\nimport { ShaderDefineArithmeticOperator } from \"./Expressions/Operators/shaderDefineArithmeticOperator\";\r\nimport type { ProcessingOptions } from \"./shaderProcessingOptions\";\r\nimport { _WarnImport } from \"../../Misc/devTools\";\r\nimport { ShaderLanguage } from \"../../Materials/shaderLanguage\";\r\n\r\ndeclare type WebRequest = import(\"../../Misc/webRequest\").WebRequest;\r\ndeclare type LoadFileError = import(\"../../Misc/fileTools\").LoadFileError;\r\ndeclare type IOfflineProvider = import(\"../../Offline/IOfflineProvider\").IOfflineProvider;\r\ndeclare type IFileRequest = import(\"../../Misc/fileRequest\").IFileRequest;\r\ndeclare type ThinEngine = import(\"../thinEngine\").ThinEngine;\r\n\r\nconst regexSE = /defined\\s*?\\((.+?)\\)/g;\r\nconst regexSERevert = /defined\\s*?\\[(.+?)\\]/g;\r\nconst regexShaderInclude = /#include\\s?<(.+)>(\\((.*)\\))*(\\[(.*)\\])*/g;\r\n\r\n/** @internal */\r\nexport class ShaderProcessor {\r\n public static Initialize(options: ProcessingOptions): void {\r\n if (options.processor && options.processor.initializeShaders) {\r\n options.processor.initializeShaders(options.processingContext);\r\n }\r\n }\r\n\r\n public static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine) {\r\n if (options.processor?.preProcessShaderCode) {\r\n sourceCode = options.processor.preProcessShaderCode(sourceCode, options.isFragment);\r\n }\r\n this._ProcessIncludes(sourceCode, options, (codeWithIncludes) => {\r\n if (options.processCodeAfterIncludes) {\r\n codeWithIncludes = options.processCodeAfterIncludes(options.isFragment ? \"fragment\" : \"vertex\", codeWithIncludes);\r\n }\r\n const migratedCode = this._ProcessShaderConversion(codeWithIncludes, options, engine);\r\n callback(migratedCode);\r\n });\r\n }\r\n\r\n public static PreProcess(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine) {\r\n if (options.processor?.preProcessShaderCode) {\r\n sourceCode = options.processor.preProcessShaderCode(sourceCode, options.isFragment);\r\n }\r\n this._ProcessIncludes(sourceCode, options, (codeWithIncludes) => {\r\n if (options.processCodeAfterIncludes) {\r\n codeWithIncludes = options.processCodeAfterIncludes(options.isFragment ? \"fragment\" : \"vertex\", codeWithIncludes);\r\n }\r\n const migratedCode = this._ApplyPreProcessing(codeWithIncludes, options, engine);\r\n callback(migratedCode);\r\n });\r\n }\r\n\r\n public static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): { vertexCode: string; fragmentCode: string } {\r\n if (!options.processor || !options.processor.finalizeShaders) {\r\n return { vertexCode, fragmentCode };\r\n }\r\n\r\n return options.processor.finalizeShaders(vertexCode, fragmentCode, options.processingContext);\r\n }\r\n\r\n private static _ProcessPrecision(source: string, options: ProcessingOptions): string {\r\n if (options.processor?.noPrecision) {\r\n return source;\r\n }\r\n\r\n const shouldUseHighPrecisionShader = options.shouldUseHighPrecisionShader;\r\n\r\n if (source.indexOf(\"precision highp float\") === -1) {\r\n if (!shouldUseHighPrecisionShader) {\r\n source = \"precision mediump float;\\n\" + source;\r\n } else {\r\n source = \"precision highp float;\\n\" + source;\r\n }\r\n } else {\r\n if (!shouldUseHighPrecisionShader) {\r\n // Moving highp to mediump\r\n source = source.replace(\"precision highp float\", \"precision mediump float\");\r\n }\r\n }\r\n\r\n return source;\r\n }\r\n\r\n private static _ExtractOperation(expression: string) {\r\n const regex = /defined\\((.+)\\)/;\r\n\r\n const match = regex.exec(expression);\r\n\r\n if (match && match.length) {\r\n return new ShaderDefineIsDefinedOperator(match[1].trim(), expression[0] === \"!\");\r\n }\r\n\r\n const operators = [\"==\", \">=\", \"<=\", \"<\", \">\"];\r\n let operator = \"\";\r\n let indexOperator = 0;\r\n\r\n for (operator of operators) {\r\n indexOperator = expression.indexOf(operator);\r\n\r\n if (indexOperator > -1) {\r\n break;\r\n }\r\n }\r\n\r\n if (indexOperator === -1) {\r\n return new ShaderDefineIsDefinedOperator(expression);\r\n }\r\n\r\n const define = expression.substring(0, indexOperator).trim();\r\n const value = expression.substring(indexOperator + operator.length).trim();\r\n\r\n return new ShaderDefineArithmeticOperator(define, operator, value);\r\n }\r\n\r\n private static _BuildSubExpression(expression: string): ShaderDefineExpression {\r\n expression = expression.replace(regexSE, \"defined[$1]\");\r\n\r\n const postfix = ShaderDefineExpression.infixToPostfix(expression);\r\n\r\n const stack: (string | ShaderDefineExpression)[] = [];\r\n\r\n for (const c of postfix) {\r\n if (c !== \"||\" && c !== \"&&\") {\r\n stack.push(c);\r\n } else if (stack.length >= 2) {\r\n let v1 = stack[stack.length - 1],\r\n v2 = stack[stack.length - 2];\r\n\r\n stack.length -= 2;\r\n\r\n const operator = c == \"&&\" ? new ShaderDefineAndOperator() : new ShaderDefineOrOperator();\r\n\r\n if (typeof v1 === \"string\") {\r\n v1 = v1.replace(regexSERevert, \"defined($1)\");\r\n }\r\n\r\n if (typeof v2 === \"string\") {\r\n v2 = v2.replace(regexSERevert, \"defined($1)\");\r\n }\r\n\r\n operator.leftOperand = typeof v2 === \"string\" ? this._ExtractOperation(v2) : v2;\r\n operator.rightOperand = typeof v1 === \"string\" ? this._ExtractOperation(v1) : v1;\r\n\r\n stack.push(operator);\r\n }\r\n }\r\n\r\n let result = stack[stack.length - 1];\r\n\r\n if (typeof result === \"string\") {\r\n result = result.replace(regexSERevert, \"defined($1)\");\r\n }\r\n\r\n // note: stack.length !== 1 if there was an error in the parsing\r\n\r\n return typeof result === \"string\" ? this._ExtractOperation(result) : result;\r\n }\r\n\r\n private static _BuildExpression(line: string, start: number): ShaderCodeTestNode {\r\n const node = new ShaderCodeTestNode();\r\n const command = line.substring(0, start);\r\n let expression = line.substring(start);\r\n\r\n expression = expression.substring(0, (expression.indexOf(\"//\") + 1 || expression.length + 1) - 1).trim();\r\n\r\n if (command === \"#ifdef\") {\r\n node.testExpression = new ShaderDefineIsDefinedOperator(expression);\r\n } else if (command === \"#ifndef\") {\r\n node.testExpression = new ShaderDefineIsDefinedOperator(expression, true);\r\n } else {\r\n node.testExpression = this._BuildSubExpression(expression);\r\n }\r\n\r\n return node;\r\n }\r\n\r\n private static _MoveCursorWithinIf(cursor: ShaderCodeCursor, rootNode: ShaderCodeConditionNode, ifNode: ShaderCodeNode) {\r\n let line = cursor.currentLine;\r\n while (this._MoveCursor(cursor, ifNode)) {\r\n line = cursor.currentLine;\r\n const first5 = line.substring(0, 5).toLowerCase();\r\n\r\n if (first5 === \"#else\") {\r\n const elseNode = new ShaderCodeNode();\r\n rootNode.children.push(elseNode);\r\n this._MoveCursor(cursor, elseNode);\r\n return;\r\n } else if (first5 === \"#elif\") {\r\n const elifNode = this._BuildExpression(line, 5);\r\n\r\n rootNode.children.push(elifNode);\r\n ifNode = elifNode;\r\n }\r\n }\r\n }\r\n\r\n private static _MoveCursor(cursor: ShaderCodeCursor, rootNode: ShaderCodeNode): boolean {\r\n while (cursor.canRead) {\r\n cursor.lineIndex++;\r\n const line = cursor.currentLine;\r\n const keywords = /(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/;\r\n const matches = keywords.exec(line);\r\n\r\n if (matches && matches.length) {\r\n const keyword = matches[0];\r\n\r\n switch (keyword) {\r\n case \"#ifdef\": {\r\n const newRootNode = new ShaderCodeConditionNode();\r\n rootNode.children.push(newRootNode);\r\n\r\n const ifNode = this._BuildExpression(line, 6);\r\n newRootNode.children.push(ifNode);\r\n this._MoveCursorWithinIf(cursor, newRootNode, ifNode);\r\n break;\r\n }\r\n case \"#else\":\r\n case \"#elif\":\r\n return true;\r\n case \"#endif\":\r\n return false;\r\n case \"#ifndef\": {\r\n const newRootNode = new ShaderCodeConditionNode();\r\n rootNode.children.push(newRootNode);\r\n\r\n const ifNode = this._BuildExpression(line, 7);\r\n newRootNode.children.push(ifNode);\r\n this._MoveCursorWithinIf(cursor, newRootNode, ifNode);\r\n break;\r\n }\r\n case \"#if\": {\r\n const newRootNode = new ShaderCodeConditionNode();\r\n const ifNode = this._BuildExpression(line, 3);\r\n rootNode.children.push(newRootNode);\r\n\r\n newRootNode.children.push(ifNode);\r\n this._MoveCursorWithinIf(cursor, newRootNode, ifNode);\r\n break;\r\n }\r\n }\r\n } else {\r\n const newNode = new ShaderCodeNode();\r\n newNode.line = line;\r\n rootNode.children.push(newNode);\r\n\r\n // Detect additional defines\r\n if (line[0] === \"#\" && line[1] === \"d\") {\r\n const split = line.replace(\";\", \"\").split(\" \");\r\n newNode.additionalDefineKey = split[1];\r\n\r\n if (split.length === 3) {\r\n newNode.additionalDefineValue = split[2];\r\n }\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n private static _EvaluatePreProcessors(sourceCode: string, preprocessors: { [key: string]: string }, options: ProcessingOptions): string {\r\n const rootNode = new ShaderCodeNode();\r\n const cursor = new ShaderCodeCursor();\r\n\r\n cursor.lineIndex = -1;\r\n cursor.lines = sourceCode.split(\"\\n\");\r\n\r\n // Decompose (We keep it in 2 steps so it is easier to maintain and perf hit is insignificant)\r\n this._MoveCursor(cursor, rootNode);\r\n\r\n // Recompose\r\n return rootNode.process(preprocessors, options);\r\n }\r\n\r\n private static _PreparePreProcessors(options: ProcessingOptions, engine: ThinEngine): { [key: string]: string } {\r\n const defines = options.defines;\r\n const preprocessors: { [key: string]: string } = {};\r\n\r\n for (const define of defines) {\r\n const keyValue = define.replace(\"#define\", \"\").replace(\";\", \"\").trim();\r\n const split = keyValue.split(\" \");\r\n preprocessors[split[0]] = split.length > 1 ? split[1] : \"\";\r\n }\r\n\r\n if (options.processor?.shaderLanguage === ShaderLanguage.GLSL) {\r\n preprocessors[\"GL_ES\"] = \"true\";\r\n }\r\n preprocessors[\"__VERSION__\"] = options.version;\r\n preprocessors[options.platformName] = \"true\";\r\n\r\n engine._getGlobalDefines(preprocessors);\r\n\r\n return preprocessors;\r\n }\r\n\r\n private static _ProcessShaderConversion(sourceCode: string, options: ProcessingOptions, engine: ThinEngine): string {\r\n let preparedSourceCode = this._ProcessPrecision(sourceCode, options);\r\n\r\n if (!options.processor) {\r\n return preparedSourceCode;\r\n }\r\n\r\n // Already converted\r\n if (options.processor.shaderLanguage === ShaderLanguage.GLSL && preparedSourceCode.indexOf(\"#version 3\") !== -1) {\r\n return preparedSourceCode.replace(\"#version 300 es\", \"\");\r\n }\r\n\r\n const defines = options.defines;\r\n\r\n const preprocessors = this._PreparePreProcessors(options, engine);\r\n\r\n // General pre processing\r\n if (options.processor.preProcessor) {\r\n preparedSourceCode = options.processor.preProcessor(preparedSourceCode, defines, options.isFragment, options.processingContext);\r\n }\r\n\r\n preparedSourceCode = this._EvaluatePreProcessors(preparedSourceCode, preprocessors, options);\r\n\r\n // Post processing\r\n if (options.processor.postProcessor) {\r\n preparedSourceCode = options.processor.postProcessor(preparedSourceCode, defines, options.isFragment, options.processingContext, engine);\r\n }\r\n\r\n // Inline functions tagged with #define inline\r\n if (engine._features.needShaderCodeInlining) {\r\n preparedSourceCode = engine.inlineShaderCode(preparedSourceCode);\r\n }\r\n\r\n return preparedSourceCode;\r\n }\r\n\r\n private static _ApplyPreProcessing(sourceCode: string, options: ProcessingOptions, engine: ThinEngine): string {\r\n let preparedSourceCode = sourceCode;\r\n\r\n const defines = options.defines;\r\n\r\n const preprocessors = this._PreparePreProcessors(options, engine);\r\n\r\n // General pre processing\r\n if (options.processor?.preProcessor) {\r\n preparedSourceCode = options.processor.preProcessor(preparedSourceCode, defines, options.isFragment, options.processingContext);\r\n }\r\n\r\n preparedSourceCode = this._EvaluatePreProcessors(preparedSourceCode, preprocessors, options);\r\n\r\n // Post processing\r\n if (options.processor?.postProcessor) {\r\n preparedSourceCode = options.processor.postProcessor(preparedSourceCode, defines, options.isFragment, options.processingContext, engine);\r\n }\r\n\r\n // Inline functions tagged with #define inline\r\n if (engine._features.needShaderCodeInlining) {\r\n preparedSourceCode = engine.inlineShaderCode(preparedSourceCode);\r\n }\r\n\r\n return preparedSourceCode;\r\n }\r\n\r\n private static _ProcessIncludes(sourceCode: string, options: ProcessingOptions, callback: (data: any) => void): void {\r\n let match = regexShaderInclude.exec(sourceCode);\r\n\r\n let returnValue = new String(sourceCode);\r\n let keepProcessing = false;\r\n\r\n while (match != null) {\r\n let includeFile = match[1];\r\n\r\n // Uniform declaration\r\n if (includeFile.indexOf(\"__decl__\") !== -1) {\r\n includeFile = includeFile.replace(/__decl__/, \"\");\r\n if (options.supportsUniformBuffers) {\r\n includeFile = includeFile.replace(/Vertex/, \"Ubo\");\r\n includeFile = includeFile.replace(/Fragment/, \"Ubo\");\r\n }\r\n includeFile = includeFile + \"Declaration\";\r\n }\r\n\r\n if (options.includesShadersStore[includeFile]) {\r\n // Substitution\r\n let includeContent = options.includesShadersStore[includeFile];\r\n if (match[2]) {\r\n const splits = match[3].split(\",\");\r\n\r\n for (let index = 0; index < splits.length; index += 2) {\r\n const source = new RegExp(splits[index], \"g\");\r\n const dest = splits[index + 1];\r\n\r\n includeContent = includeContent.replace(source, dest);\r\n }\r\n }\r\n\r\n if (match[4]) {\r\n const indexString = match[5];\r\n\r\n if (indexString.indexOf(\"..\") !== -1) {\r\n const indexSplits = indexString.split(\"..\");\r\n const minIndex = parseInt(indexSplits[0]);\r\n let maxIndex = parseInt(indexSplits[1]);\r\n let sourceIncludeContent = includeContent.slice(0);\r\n includeContent = \"\";\r\n\r\n if (isNaN(maxIndex)) {\r\n maxIndex = options.indexParameters[indexSplits[1]];\r\n }\r\n\r\n for (let i = minIndex; i < maxIndex; i++) {\r\n if (!options.supportsUniformBuffers) {\r\n // Ubo replacement\r\n sourceIncludeContent = sourceIncludeContent.replace(/light\\{X\\}.(\\w*)/g, (str: string, p1: string) => {\r\n return p1 + \"{X}\";\r\n });\r\n }\r\n includeContent += sourceIncludeContent.replace(/\\{X\\}/g, i.toString()) + \"\\n\";\r\n }\r\n } else {\r\n if (!options.supportsUniformBuffers) {\r\n // Ubo replacement\r\n includeContent = includeContent.replace(/light\\{X\\}.(\\w*)/g, (str: string, p1: string) => {\r\n return p1 + \"{X}\";\r\n });\r\n }\r\n includeContent = includeContent.replace(/\\{X\\}/g, indexString);\r\n }\r\n }\r\n\r\n // Replace\r\n returnValue = returnValue.replace(match[0], includeContent);\r\n\r\n keepProcessing = keepProcessing || includeContent.indexOf(\"#include<\") >= 0 || includeContent.indexOf(\"#include <\") >= 0;\r\n } else {\r\n const includeShaderUrl = options.shadersRepository + \"ShadersInclude/\" + includeFile + \".fx\";\r\n\r\n ShaderProcessor._FileToolsLoadFile(includeShaderUrl, (fileContent) => {\r\n options.includesShadersStore[includeFile] = fileContent as string;\r\n this._ProcessIncludes(<string>returnValue, options, callback);\r\n });\r\n return;\r\n }\r\n\r\n match = regexShaderInclude.exec(sourceCode);\r\n }\r\n\r\n if (keepProcessing) {\r\n this._ProcessIncludes(returnValue.toString(), options, callback);\r\n } else {\r\n callback(returnValue);\r\n }\r\n }\r\n\r\n /**\r\n * Loads a file from a url\r\n * @param url url to load\r\n * @param onSuccess callback called when the file successfully loads\r\n * @param onProgress callback called while file is loading (if the server supports this mode)\r\n * @param offlineProvider defines the offline provider for caching\r\n * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer\r\n * @param onError callback called when the file fails to load\r\n * @returns a file request object\r\n * @internal\r\n */\r\n public static _FileToolsLoadFile(\r\n url: string,\r\n onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void,\r\n onProgress?: (ev: ProgressEvent) => void,\r\n offlineProvider?: IOfflineProvider,\r\n useArrayBuffer?: boolean,\r\n onError?: (request?: WebRequest, exception?: LoadFileError) => void\r\n ): IFileRequest {\r\n throw _WarnImport(\"FileTools\");\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"shaderProcessor.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Engines/Processors/shaderProcessor.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,uDAAuD,CAAC;AACtG,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,uBAAuB,EAAE,MAAM,iDAAiD,CAAC;AAC1F,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,8BAA8B,EAAE,MAAM,wDAAwD,CAAC;AAExG,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAQhE,MAAM,OAAO,GAAG,uBAAuB,CAAC;AACxC,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAC9C,MAAM,kBAAkB,GAAG,0CAA0C,CAAC;AAEtE,gBAAgB;AAChB,MAAM,OAAO,eAAe;IACjB,MAAM,CAAC,UAAU,CAAC,OAA0B;QAC/C,IAAI,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,iBAAiB,EAAE;YAC1D,OAAO,CAAC,SAAS,CAAC,iBAAiB,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;SAClE;IACL,CAAC;IAEM,MAAM,CAAC,OAAO,CAAC,UAAkB,EAAE,OAA0B,EAAE,QAAwC,EAAE,MAAkB;;QAC9H,IAAI,MAAA,O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QAAQ,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;SACpE;aAAM;YACH,QAAQ,CAAC,WAAW,CAAC,CAAC;SACzB;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACI,MAAM,CAAC,kBAAkB,CAC5B,GAAW,EACX,SAAqE,EACrE,UAAwC,EACxC,eAAkC,EAClC,cAAwB,EACxB,OAAmE;QAEnE,MAAM,WAAW,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;CACJ","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport { ShaderCodeNode } from \"./shaderCodeNode\";\r\nimport { ShaderCodeCursor } from \"./shaderCodeCursor\";\r\nimport { ShaderCodeConditionNode } from \"./shaderCodeConditionNode\";\r\nimport { ShaderCodeTestNode } from \"./shaderCodeTestNode\";\r\nimport { ShaderDefineIsDefinedOperator } from \"./Expressions/Operators/shaderDefineIsDefinedOperator\";\r\nimport { ShaderDefineOrOperator } from \"./Expressions/Operators/shaderDefineOrOperator\";\r\nimport { ShaderDefineAndOperator } from \"./Expressions/Operators/shaderDefineAndOperator\";\r\nimport { ShaderDefineExpression } from \"./Expressions/shaderDefineExpression\";\r\nimport { ShaderDefineArithmeticOperator } from \"./Expressions/Operators/shaderDefineArithmeticOperator\";\r\nimport type { ProcessingOptions } from \"./shaderProcessingOptions\";\r\nimport { _WarnImport } from \"../../Misc/devTools\";\r\nimport { ShaderLanguage } from \"../../Materials/shaderLanguage\";\r\n\r\ndeclare type WebRequest = import(\"../../Misc/webRequest\").WebRequest;\r\ndeclare type LoadFileError = import(\"../../Misc/fileTools\").LoadFileError;\r\ndeclare type IOfflineProvider = import(\"../../Offline/IOfflineProvider\").IOfflineProvider;\r\ndeclare type IFileRequest = import(\"../../Misc/fileRequest\").IFileRequest;\r\ndeclare type ThinEngine = import(\"../thinEngine\").ThinEngine;\r\n\r\nconst regexSE = /defined\\s*?\\((.+?)\\)/g;\r\nconst regexSERevert = /defined\\s*?\\[(.+?)\\]/g;\r\nconst regexShaderInclude = /#include\\s?<(.+)>(\\((.*)\\))*(\\[(.*)\\])*/g;\r\n\r\n/** @internal */\r\nexport class ShaderProcessor {\r\n public static Initialize(options: ProcessingOptions): void {\r\n if (options.processor && options.processor.initializeShaders) {\r\n options.processor.initializeShaders(options.processingContext);\r\n }\r\n }\r\n\r\n public static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine) {\r\n if (options.processor?.preProcessShaderCode) {\r\n sourceCode = options.processor.preProcessShaderCode(sourceCode, options.isFragment);\r\n }\r\n this._ProcessIncludes(sourceCode, options, (codeWithIncludes) => {\r\n if (options.processCodeAfterIncludes) {\r\n codeWithIncludes = options.processCodeAfterIncludes(options.isFragment ? \"fragment\" : \"vertex\", codeWithIncludes);\r\n }\r\n const migratedCode = this._ProcessShaderConversion(codeWithIncludes, options, engine);\r\n callback(migratedCode);\r\n });\r\n }\r\n\r\n public static PreProcess(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine) {\r\n if (options.processor?.preProcessShaderCode) {\r\n sourceCode = options.processor.preProcessShaderCode(sourceCode, options.isFragment);\r\n }\r\n this._ProcessIncludes(sourceCode, options, (codeWithIncludes) => {\r\n if (options.processCodeAfterIncludes) {\r\n codeWithIncludes = options.processCodeAfterIncludes(options.isFragment ? \"fragment\" : \"vertex\", codeWithIncludes);\r\n }\r\n const migratedCode = this._ApplyPreProcessing(codeWithIncludes, options, engine);\r\n callback(migratedCode);\r\n });\r\n }\r\n\r\n public static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): { vertexCode: string; fragmentCode: string } {\r\n if (!options.processor || !options.processor.finalizeShaders) {\r\n return { vertexCode, fragmentCode };\r\n }\r\n\r\n return options.processor.finalizeShaders(vertexCode, fragmentCode, options.processingContext);\r\n }\r\n\r\n private static _ProcessPrecision(source: string, options: ProcessingOptions): string {\r\n if (options.processor?.noPrecision) {\r\n return source;\r\n }\r\n\r\n const shouldUseHighPrecisionShader = options.shouldUseHighPrecisionShader;\r\n\r\n if (source.indexOf(\"precision highp float\") === -1) {\r\n if (!shouldUseHighPrecisionShader) {\r\n source = \"precision mediump float;\\n\" + source;\r\n } else {\r\n source = \"precision highp float;\\n\" + source;\r\n }\r\n } else {\r\n if (!shouldUseHighPrecisionShader) {\r\n // Moving highp to mediump\r\n source = source.replace(\"precision highp float\", \"precision mediump float\");\r\n }\r\n }\r\n\r\n return source;\r\n }\r\n\r\n private static _ExtractOperation(expression: string) {\r\n const regex = /defined\\((.+)\\)/;\r\n\r\n const match = regex.exec(expression);\r\n\r\n if (match && match.length) {\r\n return new ShaderDefineIsDefinedOperator(match[1].trim(), expression[0] === \"!\");\r\n }\r\n\r\n const operators = [\"==\", \">=\", \"<=\", \"<\", \">\"];\r\n let operator = \"\";\r\n let indexOperator = 0;\r\n\r\n for (operator of operators) {\r\n indexOperator = expression.indexOf(operator);\r\n\r\n if (indexOperator > -1) {\r\n break;\r\n }\r\n }\r\n\r\n if (indexOperator === -1) {\r\n return new ShaderDefineIsDefinedOperator(expression);\r\n }\r\n\r\n const define = expression.substring(0, indexOperator).trim();\r\n const value = expression.substring(indexOperator + operator.length).trim();\r\n\r\n return new ShaderDefineArithmeticOperator(define, operator, value);\r\n }\r\n\r\n private static _BuildSubExpression(expression: string): ShaderDefineExpression {\r\n expression = expression.replace(regexSE, \"defined[$1]\");\r\n\r\n const postfix = ShaderDefineExpression.infixToPostfix(expression);\r\n\r\n const stack: (string | ShaderDefineExpression)[] = [];\r\n\r\n for (const c of postfix) {\r\n if (c !== \"||\" && c !== \"&&\") {\r\n stack.push(c);\r\n } else if (stack.length >= 2) {\r\n let v1 = stack[stack.length - 1],\r\n v2 = stack[stack.length - 2];\r\n\r\n stack.length -= 2;\r\n\r\n const operator = c == \"&&\" ? new ShaderDefineAndOperator() : new ShaderDefineOrOperator();\r\n\r\n if (typeof v1 === \"string\") {\r\n v1 = v1.replace(regexSERevert, \"defined($1)\");\r\n }\r\n\r\n if (typeof v2 === \"string\") {\r\n v2 = v2.replace(regexSERevert, \"defined($1)\");\r\n }\r\n\r\n operator.leftOperand = typeof v2 === \"string\" ? this._ExtractOperation(v2) : v2;\r\n operator.rightOperand = typeof v1 === \"string\" ? this._ExtractOperation(v1) : v1;\r\n\r\n stack.push(operator);\r\n }\r\n }\r\n\r\n let result = stack[stack.length - 1];\r\n\r\n if (typeof result === \"string\") {\r\n result = result.replace(regexSERevert, \"defined($1)\");\r\n }\r\n\r\n // note: stack.length !== 1 if there was an error in the parsing\r\n\r\n return typeof result === \"string\" ? this._ExtractOperation(result) : result;\r\n }\r\n\r\n private static _BuildExpression(line: string, start: number): ShaderCodeTestNode {\r\n const node = new ShaderCodeTestNode();\r\n const command = line.substring(0, start);\r\n let expression = line.substring(start);\r\n\r\n expression = expression.substring(0, (expression.indexOf(\"//\") + 1 || expression.length + 1) - 1).trim();\r\n\r\n if (command === \"#ifdef\") {\r\n node.testExpression = new ShaderDefineIsDefinedOperator(expression);\r\n } else if (command === \"#ifndef\") {\r\n node.testExpression = new ShaderDefineIsDefinedOperator(expression, true);\r\n } else {\r\n node.testExpression = this._BuildSubExpression(expression);\r\n }\r\n\r\n return node;\r\n }\r\n\r\n private static _MoveCursorWithinIf(cursor: ShaderCodeCursor, rootNode: ShaderCodeConditionNode, ifNode: ShaderCodeNode) {\r\n let line = cursor.currentLine;\r\n while (this._MoveCursor(cursor, ifNode)) {\r\n line = cursor.currentLine;\r\n const first5 = line.substring(0, 5).toLowerCase();\r\n\r\n if (first5 === \"#else\") {\r\n const elseNode = new ShaderCodeNode();\r\n rootNode.children.push(elseNode);\r\n this._MoveCursor(cursor, elseNode);\r\n return;\r\n } else if (first5 === \"#elif\") {\r\n const elifNode = this._BuildExpression(line, 5);\r\n\r\n rootNode.children.push(elifNode);\r\n ifNode = elifNode;\r\n }\r\n }\r\n }\r\n\r\n private static _MoveCursor(cursor: ShaderCodeCursor, rootNode: ShaderCodeNode): boolean {\r\n while (cursor.canRead) {\r\n cursor.lineIndex++;\r\n const line = cursor.currentLine;\r\n const keywords = /(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/;\r\n const matches = keywords.exec(line);\r\n\r\n if (matches && matches.length) {\r\n const keyword = matches[0];\r\n\r\n switch (keyword) {\r\n case \"#ifdef\": {\r\n const newRootNode = new ShaderCodeConditionNode();\r\n rootNode.children.push(newRootNode);\r\n\r\n const ifNode = this._BuildExpression(line, 6);\r\n newRootNode.children.push(ifNode);\r\n this._MoveCursorWithinIf(cursor, newRootNode, ifNode);\r\n break;\r\n }\r\n case \"#else\":\r\n case \"#elif\":\r\n return true;\r\n case \"#endif\":\r\n return false;\r\n case \"#ifndef\": {\r\n const newRootNode = new ShaderCodeConditionNode();\r\n rootNode.children.push(newRootNode);\r\n\r\n const ifNode = this._BuildExpression(line, 7);\r\n newRootNode.children.push(ifNode);\r\n this._MoveCursorWithinIf(cursor, newRootNode, ifNode);\r\n break;\r\n }\r\n case \"#if\": {\r\n const newRootNode = new ShaderCodeConditionNode();\r\n const ifNode = this._BuildExpression(line, 3);\r\n rootNode.children.push(newRootNode);\r\n\r\n newRootNode.children.push(ifNode);\r\n this._MoveCursorWithinIf(cursor, newRootNode, ifNode);\r\n break;\r\n }\r\n }\r\n } else {\r\n const newNode = new ShaderCodeNode();\r\n newNode.line = line;\r\n rootNode.children.push(newNode);\r\n\r\n // Detect additional defines\r\n if (line[0] === \"#\" && line[1] === \"d\") {\r\n const split = line.replace(\";\", \"\").split(\" \");\r\n newNode.additionalDefineKey = split[1];\r\n\r\n if (split.length === 3) {\r\n newNode.additionalDefineValue = split[2];\r\n }\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n private static _EvaluatePreProcessors(sourceCode: string, preprocessors: { [key: string]: string }, options: ProcessingOptions): string {\r\n const rootNode = new ShaderCodeNode();\r\n const cursor = new ShaderCodeCursor();\r\n\r\n cursor.lineIndex = -1;\r\n cursor.lines = sourceCode.split(\"\\n\");\r\n\r\n // Decompose (We keep it in 2 steps so it is easier to maintain and perf hit is insignificant)\r\n this._MoveCursor(cursor, rootNode);\r\n\r\n // Recompose\r\n return rootNode.process(preprocessors, options);\r\n }\r\n\r\n private static _PreparePreProcessors(options: ProcessingOptions, engine: ThinEngine): { [key: string]: string } {\r\n const defines = options.defines;\r\n const preprocessors: { [key: string]: string } = {};\r\n\r\n for (const define of defines) {\r\n const keyValue = define.replace(\"#define\", \"\").replace(\";\", \"\").trim();\r\n const split = keyValue.split(\" \");\r\n preprocessors[split[0]] = split.length > 1 ? split[1] : \"\";\r\n }\r\n\r\n if (options.processor?.shaderLanguage === ShaderLanguage.GLSL) {\r\n preprocessors[\"GL_ES\"] = \"true\";\r\n }\r\n preprocessors[\"__VERSION__\"] = options.version;\r\n preprocessors[options.platformName] = \"true\";\r\n\r\n engine._getGlobalDefines(preprocessors);\r\n\r\n return preprocessors;\r\n }\r\n\r\n private static _ProcessShaderConversion(sourceCode: string, options: ProcessingOptions, engine: ThinEngine): string {\r\n let preparedSourceCode = this._ProcessPrecision(sourceCode, options);\r\n\r\n if (!options.processor) {\r\n return preparedSourceCode;\r\n }\r\n\r\n // Already converted\r\n if (options.processor.shaderLanguage === ShaderLanguage.GLSL && preparedSourceCode.indexOf(\"#version 3\") !== -1) {\r\n preparedSourceCode = preparedSourceCode.replace(\"#version 300 es\", \"\");\r\n if (!options.processor.parseGLES3) {\r\n return preparedSourceCode;\r\n }\r\n }\r\n\r\n const defines = options.defines;\r\n\r\n const preprocessors = this._PreparePreProcessors(options, engine);\r\n\r\n // General pre processing\r\n if (options.processor.preProcessor) {\r\n preparedSourceCode = options.processor.preProcessor(preparedSourceCode, defines, options.isFragment, options.processingContext);\r\n }\r\n\r\n preparedSourceCode = this._EvaluatePreProcessors(preparedSourceCode, preprocessors, options);\r\n\r\n // Post processing\r\n if (options.processor.postProcessor) {\r\n preparedSourceCode = options.processor.postProcessor(preparedSourceCode, defines, options.isFragment, options.processingContext, engine);\r\n }\r\n\r\n // Inline functions tagged with #define inline\r\n if (engine._features.needShaderCodeInlining) {\r\n preparedSourceCode = engine.inlineShaderCode(preparedSourceCode);\r\n }\r\n\r\n return preparedSourceCode;\r\n }\r\n\r\n private static _ApplyPreProcessing(sourceCode: string, options: ProcessingOptions, engine: ThinEngine): string {\r\n let preparedSourceCode = sourceCode;\r\n\r\n const defines = options.defines;\r\n\r\n const preprocessors = this._PreparePreProcessors(options, engine);\r\n\r\n // General pre processing\r\n if (options.processor?.preProcessor) {\r\n preparedSourceCode = options.processor.preProcessor(preparedSourceCode, defines, options.isFragment, options.processingContext);\r\n }\r\n\r\n preparedSourceCode = this._EvaluatePreProcessors(preparedSourceCode, preprocessors, options);\r\n\r\n // Post processing\r\n if (options.processor?.postProcessor) {\r\n preparedSourceCode = options.processor.postProcessor(preparedSourceCode, defines, options.isFragment, options.processingContext, engine);\r\n }\r\n\r\n // Inline functions tagged with #define inline\r\n if (engine._features.needShaderCodeInlining) {\r\n preparedSourceCode = engine.inlineShaderCode(preparedSourceCode);\r\n }\r\n\r\n return preparedSourceCode;\r\n }\r\n\r\n private static _ProcessIncludes(sourceCode: string, options: ProcessingOptions, callback: (data: any) => void): void {\r\n let match = regexShaderInclude.exec(sourceCode);\r\n\r\n let returnValue = new String(sourceCode);\r\n let keepProcessing = false;\r\n\r\n while (match != null) {\r\n let includeFile = match[1];\r\n\r\n // Uniform declaration\r\n if (includeFile.indexOf(\"__decl__\") !== -1) {\r\n includeFile = includeFile.replace(/__decl__/, \"\");\r\n if (options.supportsUniformBuffers) {\r\n includeFile = includeFile.replace(/Vertex/, \"Ubo\");\r\n includeFile = includeFile.replace(/Fragment/, \"Ubo\");\r\n }\r\n includeFile = includeFile + \"Declaration\";\r\n }\r\n\r\n if (options.includesShadersStore[includeFile]) {\r\n // Substitution\r\n let includeContent = options.includesShadersStore[includeFile];\r\n if (match[2]) {\r\n const splits = match[3].split(\",\");\r\n\r\n for (let index = 0; index < splits.length; index += 2) {\r\n const source = new RegExp(splits[index], \"g\");\r\n const dest = splits[index + 1];\r\n\r\n includeContent = includeContent.replace(source, dest);\r\n }\r\n }\r\n\r\n if (match[4]) {\r\n const indexString = match[5];\r\n\r\n if (indexString.indexOf(\"..\") !== -1) {\r\n const indexSplits = indexString.split(\"..\");\r\n const minIndex = parseInt(indexSplits[0]);\r\n let maxIndex = parseInt(indexSplits[1]);\r\n let sourceIncludeContent = includeContent.slice(0);\r\n includeContent = \"\";\r\n\r\n if (isNaN(maxIndex)) {\r\n maxIndex = options.indexParameters[indexSplits[1]];\r\n }\r\n\r\n for (let i = minIndex; i < maxIndex; i++) {\r\n if (!options.supportsUniformBuffers) {\r\n // Ubo replacement\r\n sourceIncludeContent = sourceIncludeContent.replace(/light\\{X\\}.(\\w*)/g, (str: string, p1: string) => {\r\n return p1 + \"{X}\";\r\n });\r\n }\r\n includeContent += sourceIncludeContent.replace(/\\{X\\}/g, i.toString()) + \"\\n\";\r\n }\r\n } else {\r\n if (!options.supportsUniformBuffers) {\r\n // Ubo replacement\r\n includeContent = includeContent.replace(/light\\{X\\}.(\\w*)/g, (str: string, p1: string) => {\r\n return p1 + \"{X}\";\r\n });\r\n }\r\n includeContent = includeContent.replace(/\\{X\\}/g, indexString);\r\n }\r\n }\r\n\r\n // Replace\r\n returnValue = returnValue.replace(match[0], includeContent);\r\n\r\n keepProcessing = keepProcessing || includeContent.indexOf(\"#include<\") >= 0 || includeContent.indexOf(\"#include <\") >= 0;\r\n } else {\r\n const includeShaderUrl = options.shadersRepository + \"ShadersInclude/\" + includeFile + \".fx\";\r\n\r\n ShaderProcessor._FileToolsLoadFile(includeShaderUrl, (fileContent) => {\r\n options.includesShadersStore[includeFile] = fileContent as string;\r\n this._ProcessIncludes(<string>returnValue, options, callback);\r\n });\r\n return;\r\n }\r\n\r\n match = regexShaderInclude.exec(sourceCode);\r\n }\r\n\r\n if (keepProcessing) {\r\n this._ProcessIncludes(returnValue.toString(), options, callback);\r\n } else {\r\n callback(returnValue);\r\n }\r\n }\r\n\r\n /**\r\n * Loads a file from a url\r\n * @param url url to load\r\n * @param onSuccess callback called when the file successfully loads\r\n * @param onProgress callback called while file is loading (if the server supports this mode)\r\n * @param offlineProvider defines the offline provider for caching\r\n * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer\r\n * @param onError callback called when the file fails to load\r\n * @returns a file request object\r\n * @internal\r\n */\r\n public static _FileToolsLoadFile(\r\n url: string,\r\n onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void,\r\n onProgress?: (ev: ProgressEvent) => void,\r\n offlineProvider?: IOfflineProvider,\r\n useArrayBuffer?: boolean,\r\n onError?: (request?: WebRequest, exception?: LoadFileError) => void\r\n ): IFileRequest {\r\n throw _WarnImport(\"FileTools\");\r\n }\r\n}\r\n"]}
|
|
@@ -11,7 +11,13 @@ export declare class WebGPUShaderProcessorGLSL extends WebGPUShaderProcessor {
|
|
|
11
11
|
protected _preProcessors: {
|
|
12
12
|
[key: string]: string;
|
|
13
13
|
};
|
|
14
|
+
protected _vertexIsGLES3: boolean;
|
|
15
|
+
protected _fragmentIsGLES3: boolean;
|
|
14
16
|
shaderLanguage: ShaderLanguage;
|
|
17
|
+
parseGLES3: boolean;
|
|
18
|
+
attributeKeywordName: string | undefined;
|
|
19
|
+
varyingVertexKeywordName: string | undefined;
|
|
20
|
+
varyingFragmentKeywordName: string | undefined;
|
|
15
21
|
protected _getArraySize(name: string, type: string, preProcessors: {
|
|
16
22
|
[key: string]: string;
|
|
17
23
|
}): [string, string, number];
|
|
@@ -9,7 +9,10 @@ export class WebGPUShaderProcessorGLSL extends WebGPUShaderProcessor {
|
|
|
9
9
|
super(...arguments);
|
|
10
10
|
this._missingVaryings = [];
|
|
11
11
|
this._textureArrayProcessing = [];
|
|
12
|
+
this._vertexIsGLES3 = false;
|
|
13
|
+
this._fragmentIsGLES3 = false;
|
|
12
14
|
this.shaderLanguage = ShaderLanguage.GLSL;
|
|
15
|
+
this.parseGLES3 = true;
|
|
13
16
|
}
|
|
14
17
|
_getArraySize(name, type, preProcessors) {
|
|
15
18
|
let length = 0;
|
|
@@ -29,19 +32,34 @@ export class WebGPUShaderProcessorGLSL extends WebGPUShaderProcessor {
|
|
|
29
32
|
this._webgpuProcessingContext = processingContext;
|
|
30
33
|
this._missingVaryings.length = 0;
|
|
31
34
|
this._textureArrayProcessing.length = 0;
|
|
35
|
+
this.attributeKeywordName = undefined;
|
|
36
|
+
this.varyingVertexKeywordName = undefined;
|
|
37
|
+
this.varyingFragmentKeywordName = undefined;
|
|
32
38
|
}
|
|
33
39
|
preProcessShaderCode(code, isFragment) {
|
|
34
40
|
const ubDeclaration = `uniform ${WebGPUShaderProcessor.InternalsUBOName} {\nfloat yFactor_;\nfloat textureOutputHeight_;\n};\n`;
|
|
35
41
|
if (isFragment) {
|
|
42
|
+
this._fragmentIsGLES3 = code.indexOf("#version 3") !== -1;
|
|
43
|
+
if (this._fragmentIsGLES3) {
|
|
44
|
+
this.varyingFragmentKeywordName = "in";
|
|
45
|
+
}
|
|
36
46
|
return ubDeclaration + "##INJECTCODE##\n" + code;
|
|
37
47
|
}
|
|
48
|
+
this._vertexIsGLES3 = code.indexOf("#version 3") !== -1;
|
|
49
|
+
if (this._vertexIsGLES3) {
|
|
50
|
+
this.attributeKeywordName = "in";
|
|
51
|
+
this.varyingVertexKeywordName = "out";
|
|
52
|
+
}
|
|
38
53
|
return ubDeclaration + code;
|
|
39
54
|
}
|
|
40
55
|
varyingProcessor(varying, isFragment, preProcessors) {
|
|
41
56
|
this._preProcessors = preProcessors;
|
|
57
|
+
const outRegex = /\s*out\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm;
|
|
58
|
+
const inRegex = /\s*in\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm;
|
|
42
59
|
const varyingRegex = /\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm;
|
|
43
|
-
const
|
|
44
|
-
|
|
60
|
+
const regex = isFragment && this._fragmentIsGLES3 ? inRegex : !isFragment && this._vertexIsGLES3 ? outRegex : varyingRegex;
|
|
61
|
+
const match = regex.exec(varying);
|
|
62
|
+
if (match !== null) {
|
|
45
63
|
const varyingType = match[1];
|
|
46
64
|
const name = match[2];
|
|
47
65
|
let location;
|
|
@@ -63,9 +81,11 @@ export class WebGPUShaderProcessorGLSL extends WebGPUShaderProcessor {
|
|
|
63
81
|
}
|
|
64
82
|
attributeProcessor(attribute, preProcessors) {
|
|
65
83
|
this._preProcessors = preProcessors;
|
|
84
|
+
const inRegex = /\s*in\s+(\S+)\s+(\S+)\s*;/gm;
|
|
66
85
|
const attribRegex = /\s*attribute\s+(\S+)\s+(\S+)\s*;/gm;
|
|
67
|
-
const
|
|
68
|
-
|
|
86
|
+
const regex = this._vertexIsGLES3 ? inRegex : attribRegex;
|
|
87
|
+
const match = regex.exec(attribute);
|
|
88
|
+
if (match !== null) {
|
|
69
89
|
const attributeType = match[1];
|
|
70
90
|
const name = match[2];
|
|
71
91
|
const location = this._webgpuProcessingContext.getAttributeNextLocation(attributeType, this._getArraySize(name, attributeType, preProcessors)[2]);
|
|
@@ -80,7 +100,7 @@ export class WebGPUShaderProcessorGLSL extends WebGPUShaderProcessor {
|
|
|
80
100
|
this._preProcessors = preProcessors;
|
|
81
101
|
const uniformRegex = /\s*uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm;
|
|
82
102
|
const match = uniformRegex.exec(uniform);
|
|
83
|
-
if (match
|
|
103
|
+
if (match !== null) {
|
|
84
104
|
let uniformType = match[1];
|
|
85
105
|
let name = match[2];
|
|
86
106
|
if (uniformType.indexOf("sampler") === 0 || uniformType.indexOf("sampler") === 1) {
|
|
@@ -165,7 +185,7 @@ export class WebGPUShaderProcessorGLSL extends WebGPUShaderProcessor {
|
|
|
165
185
|
uniformBufferProcessor(uniformBuffer, isFragment) {
|
|
166
186
|
const uboRegex = /uniform\s+(\w+)/gm;
|
|
167
187
|
const match = uboRegex.exec(uniformBuffer);
|
|
168
|
-
if (match
|
|
188
|
+
if (match !== null) {
|
|
169
189
|
const name = match[1];
|
|
170
190
|
let uniformBufferInfo = this._webgpuProcessingContext.availableBuffers[name];
|
|
171
191
|
if (!uniformBufferInfo) {
|
|
@@ -208,7 +228,15 @@ export class WebGPUShaderProcessorGLSL extends WebGPUShaderProcessor {
|
|
|
208
228
|
code = code.replace(/gl_FragColor/g, "glFragColor");
|
|
209
229
|
code = code.replace(/gl_FragData/g, "glFragData");
|
|
210
230
|
code = code.replace(/gl_FragCoord/g, "glFragCoord_");
|
|
211
|
-
|
|
231
|
+
if (!this._fragmentIsGLES3) {
|
|
232
|
+
code = code.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "layout(location = 0) out vec4 glFragColor;\n") + "void main(");
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
const match = /^\s*out\s+\S+\s+\S+\s*;/gm.exec(code);
|
|
236
|
+
if (match !== null) {
|
|
237
|
+
code = code.substring(0, match.index) + "layout(location = 0) " + code.substring(match.index);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
212
240
|
code = code.replace(/dFdy/g, "(-yFactor_)*dFdy"); // will also handle dFdyCoarse and dFdyFine
|
|
213
241
|
code = code.replace("##INJECTCODE##", injectCode);
|
|
214
242
|
if (hasFragCoord) {
|
|
@@ -239,7 +267,7 @@ export class WebGPUShaderProcessorGLSL extends WebGPUShaderProcessor {
|
|
|
239
267
|
// Replaces the occurrences of name[XX] by nameXX
|
|
240
268
|
const regex = new RegExp(name + "\\s*\\[(.+)?\\]", "gm");
|
|
241
269
|
let match = regex.exec(code);
|
|
242
|
-
while (match
|
|
270
|
+
while (match !== null) {
|
|
243
271
|
const index = match[1];
|
|
244
272
|
let iindex = +index;
|
|
245
273
|
if (this._preProcessors && isNaN(iindex)) {
|