@onerjs/core 8.27.6 → 8.27.8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"copyTextureToTexture.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/copyTextureToTexture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5E,OAAO,EAAE,SAAS,EAAE,gCAA+B;AAKnD;;GAEG;AACH,MAAM,CAAN,IAAkB,cAIjB;AAJD,WAAkB,cAAc;IAC5B,mDAAQ,CAAA;IACR,qEAAiB,CAAA;IACjB,mEAAgB,CAAA;AACpB,CAAC,EAJiB,cAAc,KAAd,cAAc,QAI/B;AAED;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAW7B;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAEO,kBAAkB,CAAC,OAAsC;QAC7D,OAAQ,OAAuB,CAAC,kBAAkB,KAAK,SAAS,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACH,YAAY,MAAsB,EAAE,cAAc,GAAG,KAAK;QAnB1D,2BAA2B;QACjB,oBAAe,+BAAuB;QA4BxC,mBAAc,GAAG,KAAK,CAAC;QAT3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QAEtC,IAAI,CAAC,SAAS,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;QAE5C,mEAAmE;QACnE,IAAI,CAAC,sBAAsB,CAAC,cAAc,CAAC,CAAC;IAChD,CAAC;IAGO,KAAK,CAAC,sBAAsB,CAAC,cAAuB;QACxD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;QAE5B,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,eAAe,8BAAsB,CAAC;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port type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport type { IRenderTargetTexture, RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport type { ThinTexture } from \"../Materials/Textures/thinTexture\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Conversion modes available when copying a texture into another one\r\n */\r\nexport const enum ConversionMode {\r\n None = 0,\r\n ToLinearSpace = 1,\r\n ToGammaSpace = 2,\r\n}\r\n\r\n/**\r\n * Class used for fast copy from one texture to another\r\n */\r\nexport class CopyTextureToTexture {\r\n private _engine: AbstractEngine;\r\n private _isDepthTexture: boolean;\r\n private _renderer: EffectRenderer;\r\n private _effectWrapper: EffectWrapper;\r\n private _source: InternalTexture | ThinTexture;\r\n private _conversion: number;\r\n\r\n /** Shader language used */\r\n protected _shaderLanguage = ShaderLanguage.GLSL;\r\n\r\n /**\r\n * Gets the shader language\r\n */\r\n public get shaderLanguage(): ShaderLanguage {\r\n return this._shaderLanguage;\r\n }\r\n\r\n private _textureIsInternal(texture: InternalTexture | ThinTexture): texture is InternalTexture {\r\n return (texture as ThinTexture).getInternalTexture === undefined;\r\n }\r\n\r\n /**\r\n * Constructs a new instance of the class\r\n * @param engine The engine to use for the copy\r\n * @param isDepthTexture True means that we should write (using gl_FragDepth) into the depth texture attached to the destination (default: false)\r\n */\r\n constructor(engine: AbstractEngine, isDepthTexture = false) {\r\n this._engine = engine;\r\n this._isDepthTexture = isDepthTexture;\r\n\r\n this._renderer = new EffectRenderer(engine);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._initShaderSourceAsync(isDepthTexture);\r\n }\r\n\r\n private _shadersLoaded = false;\r\n private async _initShaderSourceAsync(isDepthTexture: boolean) {\r\n const engine = this._engine;\r\n\r\n if (engine.isWebGPU) {\r\n this._shaderLanguage = ShaderLanguage.WGSL;\r\n\r\n await import(\"../ShadersWGSL/copyTextureToTexture.fragment\");\r\n } else {\r\n await import(\"../Shaders/copyTextureToTexture.fragment\");\r\n }\r\n\r\n this._shadersLoaded = true;\r\n\r\n this._effectWrapper = new EffectWrapper({\r\n engine: engine,\r\n name: \"CopyTextureToTexture\",\r\n fragmentShader: \"copyTextureToTexture\",\r\n useShaderStore: true,\r\n uniformNames: [\"conversion\"],\r\n samplerNames: [\"textureSampler\"],\r\n defines: isDepthTexture ? [\"#define DEPTH_TEXTURE\"] : [],\r\n shaderLanguage: this._shaderLanguage,\r\n });\r\n\r\n this._effectWrapper.onApplyObservable.add(() => {\r\n if (isDepthTexture) {\r\n engine.setState(false);\r\n engine.setDepthBuffer(true);\r\n engine.depthCullingState.depthMask = true;\r\n engine.depthCullingState.depthFunc = Constants.ALWAYS;\r\n } else {\r\n engine.depthCullingState.depthMask = false;\r\n // other states are already set by EffectRenderer.applyEffectWrapper\r\n }\r\n\r\n if (this._textureIsInternal(this._source)) {\r\n this._effectWrapper.effect._bindTexture(\"textureSampler\", this._source);\r\n } else {\r\n this._effectWrapper.effect.setTexture(\"textureSampler\", this._source);\r\n }\r\n this._effectWrapper.effect.setFloat(\"conversion\", this._conversion);\r\n });\r\n }\r\n\r\n /**\r\n * Indicates if the effect is ready to be used for the copy\r\n * @returns true if \"copy\" can be called without delay, else false\r\n */\r\n public isReady(): boolean {\r\n return this._shadersLoaded && !!this._effectWrapper?.effect?.isReady();\r\n }\r\n\r\n /**\r\n * Copy one texture into another\r\n * @param source The source texture\r\n * @param destination The destination texture. If null, copy the source to the currently bound framebuffer\r\n * @param conversion The conversion mode that should be applied when copying\r\n * @returns\r\n */\r\n public copy(source: InternalTexture | ThinTexture, destination: Nullable<RenderTargetWrapper | IRenderTargetTexture> = null, conversion = ConversionMode.None): boolean {\r\n if (!this.isReady()) {\r\n return false;\r\n }\r\n\r\n this._source = source;\r\n this._conversion = conversion;\r\n\r\n const engineDepthFunc = this._engine.getDepthFunction();\r\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\r\n\r\n this._renderer.render(this._effectWrapper, destination);\r\n\r\n this._engine.setDepthWrite(engineDepthMask);\r\n\r\n if (this._isDepthTexture && engineDepthFunc) {\r\n this._engine.setDepthFunction(engineDepthFunc);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Releases all the resources used by the class\r\n */\r\n public dispose(): void {\r\n this._effectWrapper?.dispose();\r\n this._renderer.dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"copyTextureToTexture.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/copyTextureToTexture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5E,OAAO,EAAE,SAAS,EAAE,gCAA+B;AAKnD;;GAEG;AACH,MAAM,CAAN,IAAkB,cAIjB;AAJD,WAAkB,cAAc;IAC5B,mDAAQ,CAAA;IACR,qEAAiB,CAAA;IACjB,mEAAgB,CAAA;AACpB,CAAC,EAJiB,cAAc,KAAd,cAAc,QAI/B;AAED;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAW7B;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAEO,kBAAkB,CAAC,OAAsC;QAC7D,OAAQ,OAAuB,CAAC,kBAAkB,KAAK,SAAS,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACH,YAAY,MAAsB,EAAE,cAAc,GAAG,KAAK,EAAE,YAAY,GAAG,KAAK;QApBhF,2BAA2B;QACjB,oBAAe,+BAAuB;QA6BxC,mBAAc,GAAG,KAAK,CAAC;QAT3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QAEtC,IAAI,CAAC,SAAS,GAAG,IAAI,cAAc,CA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AAc,EAAE,WAAW,CAAC,CAAC;QAExD,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QAE5C,IAAI,IAAI,CAAC,eAAe,IAAI,eAAe,EAAE,CAAC;YAC1C,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["import type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport type { IRenderTargetTexture, RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport type { ThinTexture } from \"../Materials/Textures/thinTexture\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Conversion modes available when copying a texture into another one\r\n */\r\nexport const enum ConversionMode {\r\n None = 0,\r\n ToLinearSpace = 1,\r\n ToGammaSpace = 2,\r\n}\r\n\r\n/**\r\n * Class used for fast copy from one texture to another\r\n */\r\nexport class CopyTextureToTexture {\r\n private _engine: AbstractEngine;\r\n private _isDepthTexture: boolean;\r\n private _renderer: EffectRenderer;\r\n private _effectWrapper: EffectWrapper;\r\n private _source: InternalTexture | ThinTexture;\r\n private _conversion: number;\r\n\r\n /** Shader language used */\r\n protected _shaderLanguage = ShaderLanguage.GLSL;\r\n\r\n /**\r\n * Gets the shader language\r\n */\r\n public get shaderLanguage(): ShaderLanguage {\r\n return this._shaderLanguage;\r\n }\r\n\r\n private _textureIsInternal(texture: InternalTexture | ThinTexture): texture is InternalTexture {\r\n return (texture as ThinTexture).getInternalTexture === undefined;\r\n }\r\n\r\n /**\r\n * Constructs a new instance of the class\r\n * @param engine The engine to use for the copy\r\n * @param isDepthTexture True means that we should write (using gl_FragDepth) into the depth texture attached to the destination (default: false)\r\n * @param sameSizeCopy True means that the copy will be done without any sampling (more efficient, but requires the source and destination to be of the same size) (default: false)\r\n */\r\n constructor(engine: AbstractEngine, isDepthTexture = false, sameSizeCopy = false) {\r\n this._engine = engine;\r\n this._isDepthTexture = isDepthTexture;\r\n\r\n this._renderer = new EffectRenderer(engine);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._initShaderSourceAsync(isDepthTexture, sameSizeCopy);\r\n }\r\n\r\n private _shadersLoaded = false;\r\n private async _initShaderSourceAsync(isDepthTexture: boolean, sameSizeCopy: boolean) {\r\n const engine = this._engine;\r\n\r\n if (engine.isWebGPU) {\r\n this._shaderLanguage = ShaderLanguage.WGSL;\r\n\r\n await import(\"../ShadersWGSL/copyTextureToTexture.fragment\");\r\n } else {\r\n await import(\"../Shaders/copyTextureToTexture.fragment\");\r\n }\r\n\r\n this._shadersLoaded = true;\r\n\r\n const defines: string[] = [];\r\n\r\n if (isDepthTexture) {\r\n defines.push(\"#define DEPTH_TEXTURE\");\r\n }\r\n if (sameSizeCopy) {\r\n defines.push(\"#define NO_SAMPLER\");\r\n }\r\n\r\n this._effectWrapper = new EffectWrapper({\r\n engine: engine,\r\n name: \"CopyTextureToTexture\",\r\n fragmentShader: \"copyTextureToTexture\",\r\n useShaderStore: true,\r\n uniformNames: [\"conversion\"],\r\n samplerNames: [\"textureSampler\"],\r\n defines,\r\n shaderLanguage: this._shaderLanguage,\r\n });\r\n\r\n this._effectWrapper.onApplyObservable.add(() => {\r\n if (isDepthTexture) {\r\n engine.setState(false);\r\n engine.setDepthBuffer(true);\r\n engine.depthCullingState.depthMask = true;\r\n engine.depthCullingState.depthFunc = Constants.ALWAYS;\r\n } else {\r\n engine.depthCullingState.depthMask = false;\r\n // other states are already set by EffectRenderer.applyEffectWrapper\r\n }\r\n\r\n if (this._textureIsInternal(this._source)) {\r\n this._effectWrapper.effect._bindTexture(\"textureSampler\", this._source);\r\n } else {\r\n this._effectWrapper.effect.setTexture(\"textureSampler\", this._source);\r\n }\r\n this._effectWrapper.effect.setFloat(\"conversion\", this._conversion);\r\n });\r\n }\r\n\r\n /**\r\n * Indicates if the effect is ready to be used for the copy\r\n * @returns true if \"copy\" can be called without delay, else false\r\n */\r\n public isReady(): boolean {\r\n return this._shadersLoaded && !!this._effectWrapper?.effect?.isReady();\r\n }\r\n\r\n /**\r\n * Copy one texture into another\r\n * @param source The source texture\r\n * @param destination The destination texture. If null, copy the source to the currently bound framebuffer\r\n * @param conversion The conversion mode that should be applied when copying\r\n * @returns\r\n */\r\n public copy(source: InternalTexture | ThinTexture, destination: Nullable<RenderTargetWrapper | IRenderTargetTexture> = null, conversion = ConversionMode.None): boolean {\r\n if (!this.isReady()) {\r\n return false;\r\n }\r\n\r\n this._source = source;\r\n this._conversion = conversion;\r\n\r\n const engineDepthFunc = this._engine.getDepthFunction();\r\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\r\n\r\n this._renderer.render(this._effectWrapper, destination);\r\n\r\n this._engine.setDepthWrite(engineDepthMask);\r\n\r\n if (this._isDepthTexture && engineDepthFunc) {\r\n this._engine.setDepthFunction(engineDepthFunc);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Releases all the resources used by the class\r\n */\r\n public dispose(): void {\r\n this._effectWrapper?.dispose();\r\n this._renderer.dispose();\r\n }\r\n}\r\n"]}
@@ -5,7 +5,12 @@ const name = "copyTextureToTexturePixelShader";
5
5
  const shader = `uniform float conversion;uniform sampler2D textureSampler;varying vec2 vUV;
6
6
  #include<helperFunctions>
7
7
  void main(void)
8
- {vec4 color=texture2D(textureSampler,vUV);
8
+ {
9
+ #ifdef NO_SAMPLER
10
+ vec4 color=texelFetch(textureSampler,ivec2(gl_FragCoord.xy),0);
11
+ #else
12
+ vec4 color=texture2D(textureSampler,vUV);
13
+ #endif
9
14
  #ifdef DEPTH_TEXTURE
10
15
  gl_FragDepth=color.r;
11
16
  #else
@@ -1 +1 @@
1
- {"version":3,"file":"copyTextureToTexture.fragment.js","sourceRoot":"","sources":["../../../../dev/core/src/Shaders/copyTextureToTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,kCAAkC,CAAC;AAE1C,MAAM,IAAI,GAAG,iCAAiC,CAAC;AAC/C,MAAM,MAAM,GAAG;;;;;;;;;;;CAWd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,+BAA+B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport \"./ShadersInclude/helperFunctions\";\n\nconst name = \"copyTextureToTexturePixelShader\";\nconst shader = `uniform float conversion;uniform sampler2D textureSampler;varying vec2 vUV;\n#include<helperFunctions>\nvoid main(void) \n{vec4 color=texture2D(textureSampler,vUV);\n#ifdef DEPTH_TEXTURE\ngl_FragDepth=color.r;\n#else\nif (conversion==1.) {color=toLinearSpace(color);} else if (conversion==2.) {color=toGammaSpace(color);}\ngl_FragColor=color;\n#endif\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const copyTextureToTexturePixelShader = { name, shader };\n"]}
1
+ {"version":3,"file":"copyTextureToTexture.fragment.js","sourceRoot":"","sources":["../../../../dev/core/src/Shaders/copyTextureToTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,kCAAkC,CAAC;AAE1C,MAAM,IAAI,GAAG,iCAAiC,CAAC;AAC/C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;CAgBd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,+BAA+B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport \"./ShadersInclude/helperFunctions\";\n\nconst name = \"copyTextureToTexturePixelShader\";\nconst shader = `uniform float conversion;uniform sampler2D textureSampler;varying vec2 vUV;\n#include<helperFunctions>\nvoid main(void) \n{\n#ifdef NO_SAMPLER\nvec4 color=texelFetch(textureSampler,ivec2(gl_FragCoord.xy),0);\n#else\nvec4 color=texture2D(textureSampler,vUV);\n#endif\n#ifdef DEPTH_TEXTURE\ngl_FragDepth=color.r;\n#else\nif (conversion==1.) {color=toLinearSpace(color);} else if (conversion==2.) {color=toGammaSpace(color);}\ngl_FragColor=color;\n#endif\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const copyTextureToTexturePixelShader = { name, shader };\n"]}
@@ -2,10 +2,19 @@
2
2
  import { ShaderStore } from "../Engines/shaderStore.js";
3
3
  import "./ShadersInclude/helperFunctions.js";
4
4
  const name = "copyTextureToTexturePixelShader";
5
- const shader = `uniform conversion: f32;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;varying vUV: vec2f;
5
+ const shader = `uniform conversion: f32;
6
+ #ifndef NO_SAMPLER
7
+ var textureSamplerSampler: sampler;
8
+ #endif
9
+ var textureSampler: texture_2d<f32>;varying vUV: vec2f;
6
10
  #include<helperFunctions>
7
11
  @fragment
8
- fn main(input: FragmentInputs)->FragmentOutputs {var color: vec4f=textureSample(textureSampler,textureSamplerSampler,input.vUV);
12
+ fn main(input: FragmentInputs)->FragmentOutputs {
13
+ #ifdef NO_SAMPLER
14
+ var color: vec4f=textureLoad(textureSampler,vec2u(fragmentInputs.position.xy),0);
15
+ #else
16
+ var color: vec4f=textureSample(textureSampler,textureSamplerSampler,input.vUV);
17
+ #endif
9
18
  #ifdef DEPTH_TEXTURE
10
19
  fragmentOutputs.fragDepth=color.r;
11
20
  #else
@@ -1 +1 @@
1
- {"version":3,"file":"copyTextureToTexture.fragment.js","sourceRoot":"","sources":["../../../../dev/core/src/ShadersWGSL/copyTextureToTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,kCAAkC,CAAC;AAE1C,MAAM,IAAI,GAAG,iCAAiC,CAAC;AAC/C,MAAM,MAAM,GAAG;;;;;;;;;;;CAWd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;IACtC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,mCAAmC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport \"./ShadersInclude/helperFunctions\";\n\nconst name = \"copyTextureToTexturePixelShader\";\nconst shader = `uniform conversion: f32;var textureSamplerSampler: sampler;var textureSampler: texture_2d<f32>;varying vUV: vec2f;\n#include<helperFunctions>\n@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {var color: vec4f=textureSample(textureSampler,textureSamplerSampler,input.vUV);\n#ifdef DEPTH_TEXTURE\nfragmentOutputs.fragDepth=color.r;\n#else\nif (uniforms.conversion==1.) {color=toLinearSpaceVec4(color);} else if (uniforms.conversion==2.) {color=toGammaSpace(color);}\nfragmentOutputs.color=color;\n#endif\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const copyTextureToTexturePixelShaderWGSL = { name, shader };\n"]}
1
+ {"version":3,"file":"copyTextureToTexture.fragment.js","sourceRoot":"","sources":["../../../../dev/core/src/ShadersWGSL/copyTextureToTexture.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,kCAAkC,CAAC;AAE1C,MAAM,IAAI,GAAG,iCAAiC,CAAC;AAC/C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;CAoBd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;IACtC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,mCAAmC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport \"./ShadersInclude/helperFunctions\";\n\nconst name = \"copyTextureToTexturePixelShader\";\nconst shader = `uniform conversion: f32;\n#ifndef NO_SAMPLER\nvar textureSamplerSampler: sampler;\n#endif\nvar textureSampler: texture_2d<f32>;varying vUV: vec2f;\n#include<helperFunctions>\n@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {\n#ifdef NO_SAMPLER\nvar color: vec4f=textureLoad(textureSampler,vec2u(fragmentInputs.position.xy),0);\n#else\nvar color: vec4f=textureSample(textureSampler,textureSamplerSampler,input.vUV);\n#endif\n#ifdef DEPTH_TEXTURE\nfragmentOutputs.fragDepth=color.r;\n#else\nif (uniforms.conversion==1.) {color=toLinearSpaceVec4(color);} else if (uniforms.conversion==2.) {color=toGammaSpace(color);}\nfragmentOutputs.color=color;\n#endif\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const copyTextureToTexturePixelShaderWGSL = { name, shader };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onerjs/core",
3
- "version": "8.27.6",
3
+ "version": "8.27.8",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",