From 1e0b1976f9ca3676f4546a84e37843507e450f51 Mon Sep 17 00:00:00 2001 From: Martin Valigursky <59932779+mvaligursky@users.noreply.github.com> Date: Mon, 19 Aug 2024 16:10:12 +0100 Subject: [PATCH] [BREAKING] Remove no longer needed drawTexture (#6886) * [BREAKING] Remove no longer needed drawTexture * lint * types --------- Co-authored-by: Martin Valigursky --- src/index.js | 2 +- .../graphics/webgl/webgl-graphics-device.js | 35 +------------------ src/scene/graphics/quad-render-utils.js | 31 +--------------- 3 files changed, 3 insertions(+), 65 deletions(-) diff --git a/src/index.js b/src/index.js index bbba9072d98..b29d25d4be7 100644 --- a/src/index.js +++ b/src/index.js @@ -122,7 +122,7 @@ export { SoundInstance3d } from './platform/sound/instance3d.js'; // SCENE export * from './scene/constants.js'; -export { drawQuadWithShader, drawTexture } from './scene/graphics/quad-render-utils.js'; +export { drawQuadWithShader } from './scene/graphics/quad-render-utils.js'; export { Batch } from './scene/batching/batch.js'; export { BatchGroup } from './scene/batching/batch-group.js'; export { SkinBatchInstance } from './scene/batching/skin-batch-instance.js'; diff --git a/src/platform/graphics/webgl/webgl-graphics-device.js b/src/platform/graphics/webgl/webgl-graphics-device.js index 98504a0d8f0..b07ac1661c0 100644 --- a/src/platform/graphics/webgl/webgl-graphics-device.js +++ b/src/platform/graphics/webgl/webgl-graphics-device.js @@ -35,8 +35,6 @@ import { WebglIndexBuffer } from './webgl-index-buffer.js'; import { WebglShader } from './webgl-shader.js'; import { WebglTexture } from './webgl-texture.js'; import { WebglRenderTarget } from './webgl-render-target.js'; -import { ShaderUtils } from '../shader-utils.js'; -import { Shader } from '../shader.js'; import { BlendState } from '../blend-state.js'; import { DepthState } from '../depth-state.js'; import { StencilParameters } from '../stencil-parameters.js'; @@ -45,6 +43,7 @@ import { TextureUtils } from '../texture-utils.js'; /** * @import { RenderPass } from '../render-pass.js' + * @import { Shader } from '../shader.js' * @import { VertexBuffer } from '../vertex-buffer.js' */ @@ -1127,38 +1126,6 @@ class WebglGraphicsDevice extends GraphicsDevice { return true; } - /** - * Get copy shader for efficient rendering of fullscreen-quad with texture. - * - * @returns {Shader} The copy shader (based on `fullscreenQuadVS` and `outputTex2DPS` in - * `shaderChunks`). - * @ignore - */ - getCopyShader() { - if (!this._copyShader) { - this._copyShader = new Shader(this, ShaderUtils.createDefinition(this, { - name: 'outputTex2D', - vertexCode: /* glsl */` - attribute vec2 vertex_position; - varying vec2 vUv0; - void main(void) - { - gl_Position = vec4(vertex_position, 0.5, 1.0); - vUv0 = vertex_position.xy*0.5+0.5; - } - `, - fragmentCode: /* glsl */` - varying vec2 vUv0; - uniform sampler2D source; - void main(void) { - gl_FragColor = texture2D(source, vUv0); - } - ` - })); - } - return this._copyShader; - } - frameStart() { super.frameStart(); diff --git a/src/scene/graphics/quad-render-utils.js b/src/scene/graphics/quad-render-utils.js index f50520272f8..e678f10e7ec 100644 --- a/src/scene/graphics/quad-render-utils.js +++ b/src/scene/graphics/quad-render-utils.js @@ -70,33 +70,4 @@ function drawQuadWithShader(device, target, shader, rect, scissorRect) { quad.destroy(); } -/** - * Draws a texture in screen-space. Mostly used by post-effects. - * - * @param {GraphicsDevice} device - The graphics device used to draw the texture. - * @param {Texture} texture - The source texture to be drawn. Accessible as - * `uniform sampler2D * source` in shader. - * @param {RenderTarget} [target] - The destination render target. Defaults to the frame buffer. - * @param {Shader} [shader] - The optional custom shader used for rendering the texture. - * @param {Vec4} [rect] - The viewport rectangle to use for the texture, in pixels. Defaults to - * fullscreen: `[0, 0, target.width, target.height]`. - * @param {Vec4} [scissorRect] - The scissor rectangle to use for the texture, in pixels. Defaults - * to fullscreen `[0, 0, target.width, target.height]`. - * @category Graphics - */ -function drawTexture(device, texture, target, shader, rect, scissorRect) { - Debug.assert(!device.isWebGPU, 'pc.drawTexture is not currently supported on WebGPU platform.'); - - const useBlend = arguments[6]; - Debug.call(() => { - if (useBlend !== undefined) { - Debug.warnOnce('pc.drawTexture no longer accepts useBlend parameter, and blending state needs to be set up using GraphicsDevice.setBlendState.'); - } - }); - - shader = shader || device.getCopyShader(); - device.constantTexSource.setValue(texture); - drawQuadWithShader(device, target, shader, rect, scissorRect); -} - -export { drawQuadWithShader, drawTexture }; +export { drawQuadWithShader };