# Why is P3D drawing to the pixel grid wrong?

**URL:** <https://discourse.processing.org/t/why-is-p3d-drawing-to-the-pixel-grid-wrong/33717>\
**Category:** Coding Questions\
**Created:** [November 24, 2021, 1:30pm UTC](https://discourse.processing.org/t/why-is-p3d-drawing-to-the-pixel-grid-wrong/33717 "2021-11-24T13:30:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rodsn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rodsn/32/12573_2.png) [@rodsn](https://discourse.processing.org/u/rodsn)\
**Post date:** [November 24, 2021, 1:30pm UTC](https://discourse.processing.org/t/why-is-p3d-drawing-to-the-pixel-grid-wrong/33717/1 "2021-11-24T13:30:27Z")

</div>

```auto
PImage sprite;
int size = 10;

void setup() {
	sprite = loadImage("sprite_10.png");
	size(500, 500, P3D);
	ortho();
	noStroke();
	noSmooth();
}

void draw() {
	background(255);
	loadPixels();
	sprite.loadPixels();
	println(" ____________");
	for (int xr = 0; xr < size; ++xr) {
		for (int yr = 0; yr < size; ++yr) {
			//println("X: "+(id+xr)+"Y: "+yr);
			color c1 = sprite.pixels[((yr)*(40))+(xr)];
			if (brightness(c1) > 250) {
				print("X");
			} else {

			print("0");
			}

			//println(brightness(c1));
			fill(0);
			text(xr+":"+yr, 30+xr*25, 30+yr*25);
			fill(c1);
			rect(30+xr*25, 30+yr*25, 25, 25);

			pixels[((yr)*width)+(+xr)] = c1;
		}
		println("");
	}
		updatePixels();
}

```

I have an 40x10 image and i want to use it as a sprite sheet to apply an ascii filter. Thing is, i need to use a 3D scene and then apply the filter. Right now this is my test .pde, and im trying to get the image to show up correctly (its thickening the pixels, but only if i update the pixel grid, if i just draw rectangles it works fine).

Here is the image:  
 ![sprite_10](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/1c4ef31cce52dd6e7a75836c9e8661ffb6e08119.png)

I encourage you to switch from P3D to regular render and notice how that also seems to work properly.  
I sent to the console the pixels, and it shows them thickened.  
Quite weird behaviour… Any help is much apreciated!

---

<div class="post-metadata">

**Author:** ![rodsn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rodsn/32/12573_2.png) [@rodsn](https://discourse.processing.org/u/rodsn)\
**Post date:** [November 24, 2021, 2:53pm UTC](https://discourse.processing.org/t/why-is-p3d-drawing-to-the-pixel-grid-wrong/33717/2 "2021-11-24T14:53:12Z")

</div>

The issue seems to be caused by the transparent pixels. I added a white background and it is now reading properly. It’s almost as if the pixel grid becomes bigger to accommodate the transparency data(?) I would like to read up on why this is the current behavior if anyone has any leads for me.
