@babylonjs/post-processes 7.32.5 → 7.33.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -62,6 +62,12 @@ export class EdgeDetectionPostProcess extends PostProcess {
|
|
62
62
|
Logger.Error("Geometry Buffer Renderer support is required for this post-process.");
|
63
63
|
}
|
64
64
|
else {
|
65
|
+
const h1 = new RenderTargetTexture("h1", { width: this.width, height: this.height }, scene, {
|
66
|
+
samplingMode: Constants.TEXTURE_NEAREST_NEAREST,
|
67
|
+
generateMipMaps: false,
|
68
|
+
generateDepthBuffer: false,
|
69
|
+
type: Constants.TEXTURETYPE_HALF_FLOAT,
|
70
|
+
});
|
65
71
|
// Geometry buffer renderer is supported.
|
66
72
|
this.onApply = (effect) => {
|
67
73
|
effect.setFloat("width", this.width);
|
@@ -73,12 +79,6 @@ export class EdgeDetectionPostProcess extends PostProcess {
|
|
73
79
|
const depthTexture = this._geometryBufferRenderer.getGBuffer().textures[0];
|
74
80
|
effect.setTexture("normalSampler", normalTexture);
|
75
81
|
effect.setTexture("depthSampler", depthTexture);
|
76
|
-
const h1 = new RenderTargetTexture("h1", { width: this.width, height: this.height }, scene, {
|
77
|
-
samplingMode: Constants.TEXTURE_NEAREST_NEAREST,
|
78
|
-
generateMipMaps: false,
|
79
|
-
generateDepthBuffer: false,
|
80
|
-
type: Constants.TEXTURETYPE_HALF_FLOAT,
|
81
|
-
});
|
82
82
|
switch (this.renderMode) {
|
83
83
|
case 0:
|
84
84
|
break;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"edgeDetectionPostProcess.js","sourceRoot":"","sources":["../../../../dev/postProcesses/src/edgeDetection/edgeDetectionPostProcess.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAI1C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAC7D,OAAO,EAAE,SAAS,EAAE,6CAA+B;AACnD,2EAA6D;AAE7D,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAC/C,OAAO,EAAE,SAAS,EAAE,2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AE,wBAAwB,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport type { Camera } from \"core/Cameras/camera\";\r\nimport type { Effect } from \"core/Materials/effect\";\r\nimport type { PostProcessOptions } from \"core/PostProcesses/postProcess\";\r\nimport { PostProcess } from \"core/PostProcesses/postProcess\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport \"core/Rendering/geometryBufferRendererSceneComponent\";\r\nimport type { GeometryBufferRenderer } from \"core/Rendering/geometryBufferRenderer\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport { SerializationHelper } from \"core/Misc/decorators.serialization\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { EngineStore } from \"core/Engines/engineStore\";\r\nimport { RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\r\nimport type { Scene } from \"core/scene\";\r\nimport \"./edgeDetection.fragment\";\r\n\r\n/**\r\n * The Edge Detection effect highlights the edges of objects in the scene like a toon.\r\n * This can be used for stylized rendering, outlining, or visual effects that require edge enhancement.\r\n */\r\nexport class EdgeDetectionPostProcess extends PostProcess {\r\n /**\r\n * Defines the color of the detected edges.\r\n */\r\n @serialize()\r\n public edgeColor: Color3 = new Color3(0, 0, 0);\r\n\r\n /**\r\n * Defines the intensity of the detected edges.\r\n * Higher values result in more pronounced edges.\r\n * default: 0.2 (min:0, max:1)\r\n */\r\n @serialize()\r\n public edgeIntensity: number = 0.2;\r\n\r\n /**\r\n * Defines the width of the detected edges.\r\n * Higher values result in thicker edges.\r\n * default: 0.2 (min:0.125, max:1)\r\n */\r\n @serialize()\r\n public edgeWidth: number = 0.2;\r\n\r\n /**\r\n * Defines the render mode.\r\n * default: 0\r\n * 0: general, 1: normal, 2: depth, 3: outline only\r\n */\r\n @serialize()\r\n public renderMode: number = 0;\r\n\r\n private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;\r\n\r\n /**\r\n * Get the current class name of the current effect\r\n * @returns \"EdgeDetectionPostProcess\"\r\n */\r\n public override getClassName(): string {\r\n return \"EdgeDetectionPostProcess\";\r\n }\r\n\r\n /**\r\n * Creates a new instance of EdgeDetectionPostProcess.\r\n * @param name The name of the effect.\r\n * @param scene The scene where the edge detection post-process will be applied.\r\n * @param options The required width/height ratio or specific options for the post-process.\r\n * @param camera The camera to apply the post-process to.\r\n * @param samplingMode The sampling mode to be used when computing the pass. (default: TEXTURE_NEAREST_NEAREST)\r\n * @param reusable If the post-process can be reused on the same frame. (default: false)\r\n * @param textureType The type of textures used when performing the post-process. (default: TEXTURETYPE_HALF_FLOAT)\r\n */\r\n constructor(\r\n name: string,\r\n scene: Scene,\r\n options: number | PostProcessOptions,\r\n camera: Nullable<Camera>,\r\n samplingMode?: number,\r\n reusable?: boolean,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT\r\n ) {\r\n super(\r\n name,\r\n \"edgeDetection\",\r\n [\"width\", \"height\", \"edgeColor\", \"edgeIntensity\", \"edgeWidth\", \"renderMode\"],\r\n [\"normalSampler\", \"depthSampler\"],\r\n options,\r\n camera,\r\n samplingMode,\r\n scene.getEngine(),\r\n reusable,\r\n null,\r\n textureType\r\n );\r\n\r\n this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();\r\n\r\n if (!this._geometryBufferRenderer) {\r\n // Geometry buffer renderer is not supported. So, work as a passthrough.\r\n Logger.Error(\"Geometry Buffer Renderer support is required for this post-process.\");\r\n } else {\r\n // Geometry buffer renderer is supported.\r\n this.onApply = (effect: Effect) => {\r\n effect.setFloat(\"width\", this.width);\r\n effect.setFloat(\"height\", this.height);\r\n effect.setFloat(\"edgeIntensity\", this.edgeIntensity);\r\n effect.setFloat(\"edgeWidth\", this.edgeWidth);\r\n effect.setColor3(\"edgeColor\", this.edgeColor);\r\n\r\n const normalTexture = this._geometryBufferRenderer!.getGBuffer().textures[1];\r\n const depthTexture = this._geometryBufferRenderer!.getGBuffer().textures[0];\r\n\r\n effect.setTexture(\"normalSampler\", normalTexture);\r\n effect.setTexture(\"depthSampler\", depthTexture);\r\n\r\n const h1 = new RenderTargetTexture(\"h1\", { width: this.width, height: this.height }, scene, {\r\n samplingMode: Constants.TEXTURE_NEAREST_NEAREST,\r\n generateMipMaps: false,\r\n generateDepthBuffer: false,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n });\r\n\r\n switch (this.renderMode) {\r\n case 0:\r\n break;\r\n case 1:\r\n effect.setTexture(\"textureSampler\", this._geometryBufferRenderer!.getGBuffer().textures[1]);\r\n effect.setFloat(\"edgeWidth\", 0);\r\n break;\r\n case 2:\r\n effect.setTexture(\"textureSampler\", this._geometryBufferRenderer!.getGBuffer().textures[0]);\r\n effect.setFloat(\"edgeWidth\", 0);\r\n break;\r\n case 3:\r\n effect.setTexture(\"textureSampler\", h1);\r\n break;\r\n }\r\n effect.setInt(\"renderMode\", this.renderMode);\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Support test.\r\n */\r\n public static get IsSupported(): boolean {\r\n const engine = EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n return false;\r\n }\r\n\r\n return engine.getCaps().drawBuffersExtension;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static override _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string) {\r\n return SerializationHelper.Parse(\r\n () =>\r\n new EdgeDetectionPostProcess(\r\n parsedPostProcess.name,\r\n scene,\r\n parsedPostProcess.options,\r\n targetCamera,\r\n parsedPostProcess.renderTargetSamplingMode,\r\n parsedPostProcess.textureType,\r\n parsedPostProcess.reusable\r\n ),\r\n parsedPostProcess,\r\n scene,\r\n rootUrl\r\n );\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.EdgeDetectionPostProcess\", EdgeDetectionPostProcess);\r\n"]}
|
1
|
+
{"version":3,"file":"edgeDetectionPostProcess.js","sourceRoot":"","sources":["../../../../dev/postProcesses/src/edgeDetection/edgeDetectionPost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7B,EACL,iBAAiB,EACjB,KAAK,EACL,OAAO,CACV,CAAC;IACN,CAAC;CACJ;AApJU;IADN,SAAS,EAAE;2DACmC;AAQxC;IADN,SAAS,EAAE;+DACuB;AAQ5B;IADN,SAAS,EAAE;2DACmB;AAQxB;IADN,SAAS,EAAE;4DACkB;AA8HlC,aAAa,CAAC,kCAAkC,EAAE,wBAAwB,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport type { Camera } from \"core/Cameras/camera\";\r\nimport type { Effect } from \"core/Materials/effect\";\r\nimport type { PostProcessOptions } from \"core/PostProcesses/postProcess\";\r\nimport { PostProcess } from \"core/PostProcesses/postProcess\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport \"core/Rendering/geometryBufferRendererSceneComponent\";\r\nimport type { GeometryBufferRenderer } from \"core/Rendering/geometryBufferRenderer\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { serialize } from \"core/Misc/decorators\";\r\nimport { SerializationHelper } from \"core/Misc/decorators.serialization\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { EngineStore } from \"core/Engines/engineStore\";\r\nimport { RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\r\nimport type { Scene } from \"core/scene\";\r\nimport \"./edgeDetection.fragment\";\r\n\r\n/**\r\n * The Edge Detection effect highlights the edges of objects in the scene like a toon.\r\n * This can be used for stylized rendering, outlining, or visual effects that require edge enhancement.\r\n */\r\nexport class EdgeDetectionPostProcess extends PostProcess {\r\n /**\r\n * Defines the color of the detected edges.\r\n */\r\n @serialize()\r\n public edgeColor: Color3 = new Color3(0, 0, 0);\r\n\r\n /**\r\n * Defines the intensity of the detected edges.\r\n * Higher values result in more pronounced edges.\r\n * default: 0.2 (min:0, max:1)\r\n */\r\n @serialize()\r\n public edgeIntensity: number = 0.2;\r\n\r\n /**\r\n * Defines the width of the detected edges.\r\n * Higher values result in thicker edges.\r\n * default: 0.2 (min:0.125, max:1)\r\n */\r\n @serialize()\r\n public edgeWidth: number = 0.2;\r\n\r\n /**\r\n * Defines the render mode.\r\n * default: 0\r\n * 0: general, 1: normal, 2: depth, 3: outline only\r\n */\r\n @serialize()\r\n public renderMode: number = 0;\r\n\r\n private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;\r\n\r\n /**\r\n * Get the current class name of the current effect\r\n * @returns \"EdgeDetectionPostProcess\"\r\n */\r\n public override getClassName(): string {\r\n return \"EdgeDetectionPostProcess\";\r\n }\r\n\r\n /**\r\n * Creates a new instance of EdgeDetectionPostProcess.\r\n * @param name The name of the effect.\r\n * @param scene The scene where the edge detection post-process will be applied.\r\n * @param options The required width/height ratio or specific options for the post-process.\r\n * @param camera The camera to apply the post-process to.\r\n * @param samplingMode The sampling mode to be used when computing the pass. (default: TEXTURE_NEAREST_NEAREST)\r\n * @param reusable If the post-process can be reused on the same frame. (default: false)\r\n * @param textureType The type of textures used when performing the post-process. (default: TEXTURETYPE_HALF_FLOAT)\r\n */\r\n constructor(\r\n name: string,\r\n scene: Scene,\r\n options: number | PostProcessOptions,\r\n camera: Nullable<Camera>,\r\n samplingMode?: number,\r\n reusable?: boolean,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT\r\n ) {\r\n super(\r\n name,\r\n \"edgeDetection\",\r\n [\"width\", \"height\", \"edgeColor\", \"edgeIntensity\", \"edgeWidth\", \"renderMode\"],\r\n [\"normalSampler\", \"depthSampler\"],\r\n options,\r\n camera,\r\n samplingMode,\r\n scene.getEngine(),\r\n reusable,\r\n null,\r\n textureType\r\n );\r\n\r\n this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();\r\n\r\n if (!this._geometryBufferRenderer) {\r\n // Geometry buffer renderer is not supported. So, work as a passthrough.\r\n Logger.Error(\"Geometry Buffer Renderer support is required for this post-process.\");\r\n } else {\r\n const h1 = new RenderTargetTexture(\"h1\", { width: this.width, height: this.height }, scene, {\r\n samplingMode: Constants.TEXTURE_NEAREST_NEAREST,\r\n generateMipMaps: false,\r\n generateDepthBuffer: false,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n });\r\n\r\n // Geometry buffer renderer is supported.\r\n this.onApply = (effect: Effect) => {\r\n effect.setFloat(\"width\", this.width);\r\n effect.setFloat(\"height\", this.height);\r\n effect.setFloat(\"edgeIntensity\", this.edgeIntensity);\r\n effect.setFloat(\"edgeWidth\", this.edgeWidth);\r\n effect.setColor3(\"edgeColor\", this.edgeColor);\r\n\r\n const normalTexture = this._geometryBufferRenderer!.getGBuffer().textures[1];\r\n const depthTexture = this._geometryBufferRenderer!.getGBuffer().textures[0];\r\n\r\n effect.setTexture(\"normalSampler\", normalTexture);\r\n effect.setTexture(\"depthSampler\", depthTexture);\r\n\r\n switch (this.renderMode) {\r\n case 0:\r\n break;\r\n case 1:\r\n effect.setTexture(\"textureSampler\", this._geometryBufferRenderer!.getGBuffer().textures[1]);\r\n effect.setFloat(\"edgeWidth\", 0);\r\n break;\r\n case 2:\r\n effect.setTexture(\"textureSampler\", this._geometryBufferRenderer!.getGBuffer().textures[0]);\r\n effect.setFloat(\"edgeWidth\", 0);\r\n break;\r\n case 3:\r\n effect.setTexture(\"textureSampler\", h1);\r\n break;\r\n }\r\n effect.setInt(\"renderMode\", this.renderMode);\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Support test.\r\n */\r\n public static get IsSupported(): boolean {\r\n const engine = EngineStore.LastCreatedEngine;\r\n if (!engine) {\r\n return false;\r\n }\r\n\r\n return engine.getCaps().drawBuffersExtension;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static override _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string) {\r\n return SerializationHelper.Parse(\r\n () =>\r\n new EdgeDetectionPostProcess(\r\n parsedPostProcess.name,\r\n scene,\r\n parsedPostProcess.options,\r\n targetCamera,\r\n parsedPostProcess.renderTargetSamplingMode,\r\n parsedPostProcess.textureType,\r\n parsedPostProcess.reusable\r\n ),\r\n parsedPostProcess,\r\n scene,\r\n rootUrl\r\n );\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.EdgeDetectionPostProcess\", EdgeDetectionPostProcess);\r\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babylonjs/post-processes",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.33.0",
|
4
4
|
"main": "index.js",
|
5
5
|
"module": "index.js",
|
6
6
|
"types": "index.d.ts",
|
@@ -18,7 +18,7 @@
|
|
18
18
|
"postcompile": "build-tools -c add-js-to-es6"
|
19
19
|
},
|
20
20
|
"devDependencies": {
|
21
|
-
"@babylonjs/core": "^7.
|
21
|
+
"@babylonjs/core": "^7.33.0",
|
22
22
|
"@dev/build-tools": "^1.0.0",
|
23
23
|
"@lts/post-processes": "^1.0.0"
|
24
24
|
},
|