Hi.
I am trying to render a 3d scene into a texture, but I have problems with the depth buffer. Please look at the picture: the black hexagon has been rendered onto a texture and rendered in s2d. And below is a green hexagon in a s3d (it displayed correctrly). But the black figure has a red outline only on the outside - it is bad.
Black and white edges i am drawing by h3d.scene.Graphics
Here is the code:
Be attention on marked line: if I write texSceneRT.depthBuffer = new Texture(200, 200); then black figure shape will disappear. Where i am mistaken?
class Stack extends Bitmap{
public var texSceneRT: Texture;
public var scene: StackScene;
public function new(parent: Scene) {
texSceneRT = new Texture( 200, 200, [Target]);
texSceneRT.depthBuffer = null; <<<<<<<<<<<<<<<<<<<<<<<<<!!!!!!!
scene = new StackScene();
super( h2d.Tile.fromTexture( texSceneRT ), parent);
}
public function update(dt: Float)
{
scene.update(dt);
texSceneRT.clear( 0x0 );
// Render 3d scene
Game.instance.engine.pushTarget( texSceneRT );
Game.instance.engine.clear(0, 1);
scene.render(Game.instance.engine);
Game.instance.engine.popTarget();
}
}
If StackScene sent to App.setScene, then everything correctly.
P.S. I did it
texSceneRT.depthBuffer = new Texture(200, 200, [], Depth24Stencil8);