[SOLVED] Trying to render camera feed as texture on a plane


I’m trying to Render Camera Feed as Texture on a Plane, but I’v got this error when I play the scene:
“Trying to bind current color buffer as a texture”

What does this error means? I found some explanations in relation dynamic rendering cubemap, but I don’t think it has anything to do with what I want to do.

So I’ve got two cameras:

  • One Camera for navigation "when I scroll (up or down) I move the camera forward or backward.
  • One a rendering camera that will be used for the projection on a Plane.

In rendering camera I added a JS file with the following code:

var RenderTotextureTEST = pc.createScript('renderTotextureTEST');

RenderTotextureTEST.attributes.add('applyTextureToEntity', {
    type: 'entity', 
    title: 'Entity to Apply Texture to', 

// initialize code called once per entity
RenderTotextureTEST.prototype.initialize = function() {
    var colorBuffer = new pc.Texture(this.app.graphicsDevice, {
        width: 512,
        height: 512,
        format: pc.PIXELFORMAT_R8_G8_B8
    var renderTarget = new pc.RenderTarget(this.app.graphicsDevice, colorBuffer, {
        depth: true

    // Set the render target on an entity's camera component
    this.entity.camera.renderTarget = renderTarget;
    var meshInstances = this.applyTextureToEntity.model.meshInstances;
    for (var i = 0; i < meshInstances.length; ++i) { 
        var mesh = meshInstances[i];
        mesh.material.emissiveMap = renderTarget.colorBuffer;

In my Plane entity I only have a simple material without texture.

Any ideas or solutions?

Thanks, and have a good Christmas and New Year’s Eve !


Hi @Antony, many wishes to you!

I don’t see anything wrong in your code. Is your second camera enabled and rendering?

Check this engine example on render targets in case it’s of help:


The error usually means that the render target you are rendering to is also used as a texture in an object that you render to that render target. Usual solution is to use layers, and exclude some objects from rendering into the render target. See how the mentioned example does it,

1 Like

Thanks for this link !

Many thanks for the explanation, thanks to you I found the origin of the problem.