# readRenderTargetPixels without any shader. Just to get the pixelcolor returns \[0,0,0\]

**URL:** <https://discourse.threejs.org/t/readrendertargetpixels-without-any-shader-just-to-get-the-pixelcolor-returns-0-0-0/7022>\
**Category:** Questions\
**Tags:** webgl-renderer\
**Created:** [April 11, 2019, 10:34am UTC](https://discourse.threejs.org/t/readrendertargetpixels-without-any-shader-just-to-get-the-pixelcolor-returns-0-0-0/7022 "2019-04-11T10:34:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vin-ni](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/vin-ni/32/5013_2.png) [@vin-ni](https://discourse.threejs.org/u/vin-ni)\
**Post date:** [April 11, 2019, 10:34am UTC](https://discourse.threejs.org/t/readrendertargetpixels-without-any-shader-just-to-get-the-pixelcolor-returns-0-0-0/7022/1 "2019-04-11T10:34:02Z")

</div>

I defined a render target like that:

```
scene = new THREE.Scene();
renderTarget = new THREE.WebGLRenderTarget(renderer.domElement.clientWidth, renderer.domElement.clientHeight);

```

And later I try to read the pixel color at a certain place.

```
var read = new Uint8Array(1 * 1 * 4);
renderer.readRenderTargetPixels(renderTarget, x, y, 1, 1, read);
console.log('r:' + read[0] + ' g:' + read[1] + ' b:' + read[2]);

```

This is my renderer:

```
renderer.setRenderTarget(renderTarget);
renderer.render(scene, camera);
renderer.setRenderTarget(null);
renderer.render(scene, camera);

```

Unfortunately this returns **[0,0,0]** all of the time. Am I missing something?  
Thanks!

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [April 11, 2019, 11:35am UTC](https://discourse.threejs.org/t/readrendertargetpixels-without-any-shader-just-to-get-the-pixelcolor-returns-0-0-0/7022/2 "2019-04-11T11:35:52Z")

</div>

I have refactored your code according to the this official [example](https://threejs.org/examples/webgl_interactive_cubes_gpu.html).

Live demo: [https://jsfiddle.net/g48rvsyL/](https://jsfiddle.net/g48rvsyL/)

I’m not exactly sure what was missing in your application since important bits of your code are not listed in your post. Anyway, try to stick to the official code and things should work 👍

---

<div class="post-metadata">

**Author:** ![vin-ni](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/vin-ni/32/5013_2.png) [@vin-ni](https://discourse.threejs.org/u/vin-ni)\
**Post date:** [April 11, 2019, 12:53pm UTC](https://discourse.threejs.org/t/readrendertargetpixels-without-any-shader-just-to-get-the-pixelcolor-returns-0-0-0/7022/3 "2019-04-11T12:53:53Z")

</div>

Thank you so much! This example already really helped.  
Why do you need to add a perspectiveCamera? Is it possible to do it with a `new THREE.Camera();`  
I don’t need a perspective Camera as It’s for an ar project.

If I replace the camera in your example, it stops working.

---

<div class="post-metadata">

**Author:** ![vin-ni](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/vin-ni/32/5013_2.png) [@vin-ni](https://discourse.threejs.org/u/vin-ni)\
**Post date:** [April 11, 2019, 1:03pm UTC](https://discourse.threejs.org/t/readrendertargetpixels-without-any-shader-just-to-get-the-pixelcolor-returns-0-0-0/7022/4 "2019-04-11T13:03:23Z")

</div>

Ah, it’s actually working. Perfect! Thanks!
