Skip to content

Commit 795a190

Browse files
committed
The BaseShader default vertex shader now includes the outTexCoord vec2 varying, mapped to be the same as that found in the pipeline shaders. Fix phaserjs#5120
1 parent 4d8cff1 commit 795a190

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/display/shader/BaseShader.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ var Class = require('../../utils/Class');
99
/**
1010
* @classdesc
1111
* A BaseShader is a small resource class that contains the data required for a WebGL Shader to be created.
12-
*
12+
*
1313
* It contains the raw source code to the fragment and vertex shader, as well as an object that defines
1414
* the uniforms the shader requires, if any.
15-
*
15+
*
1616
* BaseShaders are stored in the Shader Cache, available in a Scene via `this.cache.shaders` and are referenced
1717
* by a unique key-based string. Retrieve them via `this.cache.shaders.get(key)`.
18-
*
18+
*
1919
* BaseShaders are created automatically by the GLSL File Loader when loading an external shader resource.
2020
* They can also be created at runtime, allowing you to use dynamically generated shader source code.
21-
*
21+
*
2222
* Default fragment and vertex source is used if not provided in the constructor, setting-up a basic shader,
2323
* suitable for debug rendering.
2424
*
@@ -66,10 +66,12 @@ var BaseShader = new Class({
6666
'attribute vec2 inPosition;',
6767

6868
'varying vec2 fragCoord;',
69+
'varying vec2 outTexCoord;',
6970

7071
'void main () {',
71-
'gl_Position = uProjectionMatrix * uViewMatrix * vec4(inPosition, 1.0, 1.0);',
72-
'fragCoord = vec2(inPosition.x, uResolution.y - inPosition.y);',
72+
' gl_Position = uProjectionMatrix * uViewMatrix * vec4(inPosition, 1.0, 1.0);',
73+
' fragCoord = vec2(inPosition.x, uResolution.y - inPosition.y);',
74+
' outTexCoord = vec2(inPosition.x / uResolution.x, fragCoord.y / uResolution.y);',
7375
'}'
7476
].join('\n');
7577
}

0 commit comments

Comments
 (0)