From 628cfac62d0a184fdfb30f2e1e055bc3a6806d2d Mon Sep 17 00:00:00 2001 From: Michael Musset Date: Fri, 22 Nov 2024 14:57:30 +0100 Subject: [PATCH] add the option vertexShaderCommon to prepend the custom vertexshader with the PolylineCommon.glsl file --- CONTRIBUTORS.md | 1 + packages/engine/Source/Scene/PolylineMaterialAppearance.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 46b59573acfd..adb639ec3012 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -418,3 +418,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu - [Kirn Kim](https://github.com/squrki) - [Emanuele Mastaglia](https://github.com/Masty88) - [Connor Manning](https://github.com/connormanning) +- [Michael Musset](https://github.com/mickae1) diff --git a/packages/engine/Source/Scene/PolylineMaterialAppearance.js b/packages/engine/Source/Scene/PolylineMaterialAppearance.js index d47e73d2bb6c..3f86ff3134ff 100644 --- a/packages/engine/Source/Scene/PolylineMaterialAppearance.js +++ b/packages/engine/Source/Scene/PolylineMaterialAppearance.js @@ -24,6 +24,7 @@ if (!FeatureDetection.isInternetExplorer()) { * @param {object} [options] Object with the following properties: * @param {boolean} [options.translucent=true] When true, the geometry is expected to appear translucent so {@link PolylineMaterialAppearance#renderState} has alpha blending enabled. * @param {Material} [options.material=Material.ColorType] The material used to determine the fragment color. + * @param {boolean} [options.vertexShaderCommon] prepend PolylineCommon.glsl to vertexShaderSource * @param {string} [options.vertexShaderSource] Optional GLSL vertex shader source to override the default vertex shader. * @param {string} [options.fragmentShaderSource] Optional GLSL fragment shader source to override the default fragment shader. * @param {object} [options.renderState] Optional render state to override the default render state. @@ -50,6 +51,7 @@ if (!FeatureDetection.isInternetExplorer()) { function PolylineMaterialAppearance(options) { options = defaultValue(options, defaultValue.EMPTY_OBJECT); + const vertexShaderCommon = defaultValue(options.vertexShaderCommon, false); const translucent = defaultValue(options.translucent, true); const closed = false; const vertexFormat = PolylineMaterialAppearance.VERTEX_FORMAT; @@ -78,6 +80,9 @@ function PolylineMaterialAppearance(options) { */ this.translucent = translucent; + if(vertexShaderCommon && options.vertexShaderSource) { + options.vertexShaderSource = `${PolylineCommon}\n${options.vertexShaderSource}` + } this._vertexShaderSource = defaultValue( options.vertexShaderSource, defaultVertexShaderSource,