#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# In P3D, what is the expected positioning of blitted images with respect to other 3D objects?

edited April 2017

The following sketch draws some coloured lines to the screen and THEN draws an image (a black square).

Two of the lines are 3D - they are drawn with the six-parameter version of line(). The first is drawn at depth -0.3f -- it appears behind the black square. The second is drawn at depth -0.2f -- it appears in front of the black square.

The third (red) line is drawn with the normal 2D four-parameter version of line(). It appears in front of the black square.

I am struggling to understand what is happening here. It's almost as if the 'black square' image is being drawn between -0.2 and -0.3 depth (I found those numbers by experimenting).

I cannot understand why the 2D-version of the line appears in front of the image, even though the image is drawn afterwards.

I can see that muddling up 2D and 3D could lead to weird behaviours, but it is helpful to be able to generate a scene in 3D and then slap images on top (for example, a life bar in a game). It wouldn't be good if they appear underneath part of the scene!

I tried the same sketch with P2D - there you get the black square painted over the top of all the lines. I also tried it with P3D on Processing2 and Processing1 -- P2 gives the same result as P3, but P1 paints the square over the top of all the lines.

Can anyone help to explain why I'm seeing what I'm seeing?

``````void setup()
{
size(300,300,P3D);
}

void draw()
{
camera();
stroke(255,255,255);
line(50,0,-0.3f,width,height,-0.3f);
line(0,50,-0.2f,width,height,-0.2f);

stroke(255,100,100);
line(0,0,width,height);

PImage testImg = createImage(100,100,RGB);
image(testImg,0,0);
}
``````

Tagged: