Hello,
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;
mesh.material.update();
}
};
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 !
Antony