The Shader Game Object now supports being able to use a Render Texture as a sampler2D texture on the shader. Fix #5423

This commit is contained in:
Richard Davey 2020-12-07 12:19:42 +00:00
parent 15a6f50d2c
commit d6d5c09552
2 changed files with 13 additions and 9 deletions

View file

@ -728,6 +728,12 @@ var Shader = new Class({
if (textureManager.exists(textureKey))
{
var frame = textureManager.getFrame(textureKey);
if (frame.glTexture && frame.glTexture.isRenderTexture)
{
return this.setSampler2DBuffer(uniformKey, frame.glTexture, frame.width, frame.height, textureIndex, textureData);
}
var uniform = this.uniforms[uniformKey];
var source = frame.source;
@ -908,7 +914,7 @@ var Shader = new Class({
var data = uniform.textureData;
if (data)
if (data && !uniform.value.isRenderTexture)
{
// https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D
@ -1017,7 +1023,7 @@ var Shader = new Class({
}
else if (uniform.type === 'sampler2D')
{
gl.activeTexture(gl['TEXTURE' + textureCount]);
gl.activeTexture(gl.TEXTURE0 + textureCount);
gl.bindTexture(gl.TEXTURE_2D, value);

View file

@ -967,11 +967,6 @@ var PipelineManager = new Class({
pipeline = this.previous;
}
if (!pipeline)
{
return;
}
var renderer = this.renderer;
var gl = renderer.gl;
@ -995,9 +990,12 @@ var PipelineManager = new Class({
renderer.setBlendMode(0, true);
this.current = pipeline;
if (pipeline)
{
this.current = pipeline;
pipeline.rebind();
pipeline.rebind();
}
renderer.resetTextures();
},