# Pixelizing objects in 3d scene

**URL:** <https://discourse.threejs.org/t/pixelizing-objects-in-3d-scene/3993>\
**Category:** Questions\
**Tags:** shaders\
**Created:** [September 3, 2018, 7:13am UTC](https://discourse.threejs.org/t/pixelizing-objects-in-3d-scene/3993 "2018-09-03T07:13:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![1115](https://avatars.discourse-cdn.com/v4/letter/1/9f8e36/32.png) [@1115](https://discourse.threejs.org/u/1115)\
**Post date:** [September 3, 2018, 7:13am UTC](https://discourse.threejs.org/t/pixelizing-objects-in-3d-scene/3993/1 "2018-09-03T07:13:05Z")

</div>

Hello!

1. Is it possible to make a stable feature in 3d scene like here (not necessasry exactly like there, I just want it to look like there)  
[https://github.com/mats31/Dragon-Ball-Web-Application](https://github.com/mats31/Dragon-Ball-Web-Application)  
I want objects to “pixilize” when I am far from them and come “pixels” together when I’m approaching them.  
I made an “analog” of it in 3d scene, but it works in static (not reacting to approaching to obj) and very unstable: an obj pixelizes after several reloads of page. And the page itself eats all available memory after some time.
2. Is it possible to translate coords where the player should be in a url?

Maybe someone realized this features in other engines (e.g. b4w)?

---

<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:** [September 3, 2018, 2:20pm UTC](https://discourse.threejs.org/t/pixelizing-objects-in-3d-scene/3993/2 "2018-09-03T14:20:50Z")

</div>

You can achieve a similar effect by using a custom shader. As you can see in this example, I use the image as a texture for a plane with a `ShaderMaterial`. The fragment shader computes are grid which is used to make certain parts of the surface totally transparent. I’ve added a few comments to the code in order to explain what’s happening.

> **[Edit fiddle - JSFiddle - Code Playground](https://jsfiddle.net/4aomj95b/)**
>
> Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.

---

<div class="post-metadata">

**Author:** ![1115](https://avatars.discourse-cdn.com/v4/letter/1/9f8e36/32.png) [@1115](https://discourse.threejs.org/u/1115)\
**Post date:** [September 5, 2018, 9:36am UTC](https://discourse.threejs.org/t/pixelizing-objects-in-3d-scene/3993/3 "2018-09-05T09:36:45Z")

</div>

Nice effect, but it’s not exactly what I want. This is a flat one, I want something more 3D (vertexes should be dispersed in space and come together when I’m approaching).

---

<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:** [September 5, 2018, 10:31am UTC](https://discourse.threejs.org/t/pixelizing-objects-in-3d-scene/3993/4 "2018-09-05T10:31:46Z")

</div>

Um, maybe you can use a similar approach like in the `webgl_materials_video` example. So your single pixel objects are simple box meshes. For each mesh, you create a new `BoxBufferGeometry` object and manipulate the texture coordinates like in the beneath code snippet. Since all meshes share a single material, they now render just a certain part of the common texture.

> <https://github.com/mrdoob/three.js/blob/ce501ae22b51665646a8d4a8a7131d78cc54005f/examples/webgl_materials_video.html#L203-L214>

This approach should provide you more flexibility since you can independently animate the boxes. And you have a real 3D effect.

---

<div class="post-metadata">

**Author:** ![pailhead](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/pailhead/32/85_2.png) [@pailhead](https://discourse.threejs.org/u/pailhead)\
**Post date:** [September 5, 2018, 3:45pm UTC](https://discourse.threejs.org/t/pixelizing-objects-in-3d-scene/3993/5 "2018-09-05T15:45:56Z")

</div>

I believe you are describing “voxels”?

> **[Voxel](https://en.wikipedia.org/wiki/Voxel)**
>
> A voxel represents a value on a regular grid in three-dimensional space. As with pixels in a bitmap, voxels themselves do not typically have their position (their coordinates) explicitly encoded along with their values. Instead, rendering systems infer the position of a voxel based upon its position relative to other voxels (i.e., its position in the data structure that makes up a single volumetric image). In contrast to pixels and voxels, points and polygons are often explicitly represented by t...

It’s like a pixel, but it’s volume based rather than surface. Minecraft is a good example of a voxelized world.

You could render slices into a texture. Put an orthographic camera above the world, and clip the world at constant height intervals. You could then loop through the texture and extract voxels with their colors in order to reduce the footprint of the texture.

---

<div class="post-metadata">

**Author:** ![MateuszWis](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mateuszwis/32/38322_2.png) [@MateuszWis](https://discourse.threejs.org/u/MateuszWis)\
**Post date:** [September 6, 2018, 7:45am UTC](https://discourse.threejs.org/t/pixelizing-objects-in-3d-scene/3993/6 "2018-09-06T07:45:30Z")

</div>

You could also use a modified [PointsMaterial](https://threejs.org/docs/index.html#api/en/materials/PointsMaterial) each pixel will face camera and you can change their shape with map param.  
Here is an example [https://jsfiddle.net/f2Lommf5/13188/](https://jsfiddle.net/f2Lommf5/13188/)

Edit: I had some more fun with it [https://jsfiddle.net/f2Lommf5/13256/](https://jsfiddle.net/f2Lommf5/13256/)  
Any idea why I couldn’t use THREE.Points with THREE.PlaneGeometry?
