mirror of
https://github.com/photonstorm/phaser
synced 2024-11-15 09:27:37 +00:00
Support rendering a shader to a texture instead of the display list
This commit is contained in:
parent
22b107b903
commit
ba0c380109
1 changed files with 36 additions and 28 deletions
|
@ -30,40 +30,48 @@ var ShaderWebGLRenderer = function (renderer, src, interpolationPercentage, came
|
|||
|
||||
renderer.clearPipeline();
|
||||
|
||||
var camMatrix = src._tempMatrix1;
|
||||
var shapeMatrix = src._tempMatrix2;
|
||||
var calcMatrix = src._tempMatrix3;
|
||||
|
||||
shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY);
|
||||
|
||||
camMatrix.copyFrom(camera.matrix);
|
||||
|
||||
if (parentMatrix)
|
||||
if (src.renderToTexture)
|
||||
{
|
||||
// Multiply the camera by the parent matrix
|
||||
camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY);
|
||||
|
||||
// Undo the camera scroll
|
||||
shapeMatrix.e = src.x;
|
||||
shapeMatrix.f = src.y;
|
||||
src.load();
|
||||
src.flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
shapeMatrix.e -= camera.scrollX * src.scrollFactorX;
|
||||
shapeMatrix.f -= camera.scrollY * src.scrollFactorY;
|
||||
var camMatrix = src._tempMatrix1;
|
||||
var shapeMatrix = src._tempMatrix2;
|
||||
var calcMatrix = src._tempMatrix3;
|
||||
|
||||
shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY);
|
||||
|
||||
camMatrix.copyFrom(camera.matrix);
|
||||
|
||||
if (parentMatrix)
|
||||
{
|
||||
// Multiply the camera by the parent matrix
|
||||
camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY);
|
||||
|
||||
// Undo the camera scroll
|
||||
shapeMatrix.e = src.x;
|
||||
shapeMatrix.f = src.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
shapeMatrix.e -= camera.scrollX * src.scrollFactorX;
|
||||
shapeMatrix.f -= camera.scrollY * src.scrollFactorY;
|
||||
}
|
||||
|
||||
camMatrix.multiply(shapeMatrix, calcMatrix);
|
||||
|
||||
// Renderer size changed?
|
||||
if (renderer.width !== src._rendererWidth || renderer.height !== src._rendererHeight)
|
||||
{
|
||||
src.projOrtho(0, renderer.width, renderer.height, 0);
|
||||
}
|
||||
|
||||
src.load(calcMatrix.matrix);
|
||||
src.flush();
|
||||
}
|
||||
|
||||
camMatrix.multiply(shapeMatrix, calcMatrix);
|
||||
|
||||
// Renderer size changed?
|
||||
if (renderer.width !== src._rendererWidth || renderer.height !== src._rendererHeight)
|
||||
{
|
||||
src.projOrtho(0, renderer.width, renderer.height, 0);
|
||||
}
|
||||
|
||||
src.load(calcMatrix.matrix);
|
||||
src.flush();
|
||||
|
||||
renderer.rebindPipeline(pipeline);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue