|
| 1 | +/** |
| 2 | + * @author Richard Davey <rich@photonstorm.com> |
| 3 | + * @copyright 2020 Photon Storm Ltd. |
| 4 | + * @license {@link https://opensource.org/licenses/MIT|MIT License} |
| 5 | + */ |
| 6 | + |
| 7 | +var Class = require('../../../utils/Class'); |
| 8 | +var GetFastValue = require('../../../utils/object/GetFastValue'); |
| 9 | +var MultiPipeline = require('./MultiPipeline'); |
| 10 | +var ShaderSourceFS = require('../shaders/Single-frag.js'); |
| 11 | +var ShaderSourceVS = require('../shaders/Single-vert.js'); |
| 12 | +var WebGLPipeline = require('../WebGLPipeline'); |
| 13 | + |
| 14 | +/** |
| 15 | + * @classdesc |
| 16 | + * The Camera Pipeline is a special version of the Multi Pipeline that only ever |
| 17 | + * uses one texture, bound to texture unit zero and with a vertex capacity of 1. |
| 18 | + * |
| 19 | + * The fragment shader it uses can be found in `shaders/src/Single.frag`. |
| 20 | + * The vertex shader it uses can be found in `shaders/src/Single.vert`. |
| 21 | + * |
| 22 | + * The default shader attributes for this pipeline are: |
| 23 | + * |
| 24 | + * `inPosition` (vec2, offset 0) |
| 25 | + * `inTexCoord` (vec2, offset 8) |
| 26 | + * `inTexId` (float, offset 16) - this value is always zero in the Camera Pipeline |
| 27 | + * `inTintEffect` (float, offset 20) |
| 28 | + * `inTint` (vec4, offset 24, normalized) |
| 29 | + * |
| 30 | + * The default shader uniforms for this pipeline are: |
| 31 | + * |
| 32 | + * `uProjectionMatrix` (mat4) |
| 33 | + * `uMainSampler` (sampler2D) |
| 34 | + * |
| 35 | + * @class CameraPipeline |
| 36 | + * @extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline |
| 37 | + * @memberof Phaser.Renderer.WebGL.Pipelines |
| 38 | + * @constructor |
| 39 | + * @since 3.50.0 |
| 40 | + * |
| 41 | + * @param {Phaser.Types.Renderer.WebGL.WebGLPipelineConfig} config - The configuration options for this pipeline. |
| 42 | + */ |
| 43 | +var CameraPipeline = new Class({ |
| 44 | + |
| 45 | + Extends: MultiPipeline, |
| 46 | + |
| 47 | + initialize: |
| 48 | + |
| 49 | + function CameraPipeline (config) |
| 50 | + { |
| 51 | + config.fragShader = GetFastValue(config, 'fragShader', ShaderSourceFS), |
| 52 | + config.vertShader = GetFastValue(config, 'vertShader', ShaderSourceVS), |
| 53 | + config.vertexCapacity = 1; |
| 54 | + config.forceZero = true; |
| 55 | + |
| 56 | + MultiPipeline.call(this, config); |
| 57 | + }, |
| 58 | + |
| 59 | + boot: function () |
| 60 | + { |
| 61 | + WebGLPipeline.prototype.boot.call(this); |
| 62 | + |
| 63 | + this.set1i('uMainSampler', 0); |
| 64 | + } |
| 65 | + |
| 66 | +}); |
| 67 | + |
| 68 | +module.exports = CameraPipeline; |
0 commit comments