Hey hey
A few weeks ago you introduced the change to flip the Y-Coordinate on textures. This had some implications when rendering a layer into a texture, which was then flipped onto its head. You fixed this by adding a flag “flipY” to the RenderTarget class, with which we were able to fix this.
Now we noticed something else and we are not sure if we are missing something in our implementation, or if this is another bug. The code we use to render into a texture:
RenderToTexture.prototype.postInitialize = function() {
var element = this.targetEntity.element;
var colorBuffer = new pc.Texture(this.app.graphicsDevice, {
width: element.width,
height: element.height,
format: pc.PIXELFORMAT_R8_G8_B8_A8,
autoMipmap: true,
minFilter: pc.FILTER_LINEAR,
magFilter: pc.FILTER_LINEAR,
});
var renderTarget = new pc.RenderTarget({
colorBuffer: colorBuffer,
depth: true,
flipY: true,
});
var layer = this.app.scene.layers.getLayerByName(this.layerName);
layer.renderTarget = renderTarget;
element.texture = layer.renderTarget.colorBuffer;
element.color = pc.Color.WHITE;
element.opacity = 1;
};
This results in the following: The left side is the element component into which we render our layer, the right side is what the main camera sees. As you can see, the normal map on our texture is interpreted wrong when rendering a layer to a texture.
If we set “flipY” to false though, the normal map gets used correctly, but the image is flipped of course.
Can you help us, are we missing something? Are we supposed to create a depth buffer as well and pass it to the render target? Or do you think the issue lies somewhere else?
Thanks again