# Update geometries' boundingBox taking Shader displacement into account

**URL:** <https://discourse.threejs.org/t/update-geometries-boundingbox-taking-shader-displacement-into-account/5729>\
**Category:** Questions\
**Tags:** bounding-box, geometry, shaders\
**Created:** [January 14, 2019, 10:33pm UTC](https://discourse.threejs.org/t/update-geometries-boundingbox-taking-shader-displacement-into-account/5729 "2019-01-14T22:33:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SlimMarten](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/slimmarten/32/3012_2.png) [@SlimMarten](https://discourse.threejs.org/u/SlimMarten)\
**Post date:** [January 14, 2019, 10:33pm UTC](https://discourse.threejs.org/t/update-geometries-boundingbox-taking-shader-displacement-into-account/5729/1 "2019-01-14T22:33:46Z")

</div>

Hi there! In my current project I have a few GPU Instanced Geometries. Means I duplicate and place the same model via shader code as described in this tutorial series [https://medium.com/@pailhead011/instancing-with-three-js-36b4b62bc127](https://medium.com/@pailhead011/instancing-with-three-js-36b4b62bc127).  
This way of placing static assets in a scene reduces draw calls and improves overall performance enormously.

BUT there is one little problem I couldn’t figure out by now. Since I use the mesh’s shader to translate duplicates of the actual geometry, the geo’s `boundingBox` won’t update – which means – I do have to set `frustumCulled` to `true` in order to make sure the mesh gets rendered. This results in the mesh getting rendered even if it’s not in the viewport, which again causes unnecessary draw calls.

So the question is: Is it possible to recalculate my geo’s BoundingBox and taking displacements via shaders into account?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![marquizzo](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/marquizzo/32/25192_2.png) [@marquizzo](https://discourse.threejs.org/u/marquizzo)\
**Post date:** [January 15, 2019, 5:29am UTC](https://discourse.threejs.org/t/update-geometries-boundingbox-taking-shader-displacement-into-account/5729/2 "2019-01-15T05:29:23Z")

</div>

Sadly, the `boundingBox` class only reads the geometry position attribute to calculate its dimensions. If you manipulate those positions via shader code, the `boundingBox` will not be aware of these changes.

Maybe you could manually tell the boundingbox where you plan to create more instances by using its `.expandByPoint` method: [https://threejs.org/docs/#api/en/math/Box3.expandByPoint](https://threejs.org/docs/#api/en/math/Box3.expandByPoint)

For instance, if you’re planning on making an instance at [5, 10, 3], you could do something like

```auto
var point = new THREE.Vector3(5, 10, 3);
geom.boundingBox.expandByPoint(point);

```

This of course, doesn’t take into consideration the width, height, or depth of this instance, but it’s an approximation. There are a bunch of other helper methods in `Box3` that can help you get better calculations, such as [https://threejs.org/docs/#api/en/math/Box3.setFromBufferAttribute](https://threejs.org/docs/#api/en/math/Box3.setFromBufferAttribute)
