Skip to content

Commit ba0c380

Browse files
committed
Support rendering a shader to a texture instead of the display list
1 parent 22b107b commit ba0c380

1 file changed

Lines changed: 36 additions & 28 deletions

File tree

src/gameobjects/shader/ShaderWebGLRenderer.js

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,48 @@ var ShaderWebGLRenderer = function (renderer, src, interpolationPercentage, came
3030

3131
renderer.clearPipeline();
3232

33-
var camMatrix = src._tempMatrix1;
34-
var shapeMatrix = src._tempMatrix2;
35-
var calcMatrix = src._tempMatrix3;
36-
37-
shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY);
38-
39-
camMatrix.copyFrom(camera.matrix);
40-
41-
if (parentMatrix)
33+
if (src.renderToTexture)
4234
{
43-
// Multiply the camera by the parent matrix
44-
camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY);
45-
46-
// Undo the camera scroll
47-
shapeMatrix.e = src.x;
48-
shapeMatrix.f = src.y;
35+
src.load();
36+
src.flush();
4937
}
5038
else
5139
{
52-
shapeMatrix.e -= camera.scrollX * src.scrollFactorX;
53-
shapeMatrix.f -= camera.scrollY * src.scrollFactorY;
40+
var camMatrix = src._tempMatrix1;
41+
var shapeMatrix = src._tempMatrix2;
42+
var calcMatrix = src._tempMatrix3;
43+
44+
shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY);
45+
46+
camMatrix.copyFrom(camera.matrix);
47+
48+
if (parentMatrix)
49+
{
50+
// Multiply the camera by the parent matrix
51+
camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY);
52+
53+
// Undo the camera scroll
54+
shapeMatrix.e = src.x;
55+
shapeMatrix.f = src.y;
56+
}
57+
else
58+
{
59+
shapeMatrix.e -= camera.scrollX * src.scrollFactorX;
60+
shapeMatrix.f -= camera.scrollY * src.scrollFactorY;
61+
}
62+
63+
camMatrix.multiply(shapeMatrix, calcMatrix);
64+
65+
// Renderer size changed?
66+
if (renderer.width !== src._rendererWidth || renderer.height !== src._rendererHeight)
67+
{
68+
src.projOrtho(0, renderer.width, renderer.height, 0);
69+
}
70+
71+
src.load(calcMatrix.matrix);
72+
src.flush();
5473
}
5574

56-
camMatrix.multiply(shapeMatrix, calcMatrix);
57-
58-
// Renderer size changed?
59-
if (renderer.width !== src._rendererWidth || renderer.height !== src._rendererHeight)
60-
{
61-
src.projOrtho(0, renderer.width, renderer.height, 0);
62-
}
63-
64-
src.load(calcMatrix.matrix);
65-
src.flush();
66-
6775
renderer.rebindPipeline(pipeline);
6876
};
6977

0 commit comments

Comments
 (0)