# Which matirx can be used to make position fromworld space to local space ？

**URL:** <https://forum.babylonjs.com/t/which-matirx-can-be-used-to-make-position-fromworld-space-to-local-space/36779>\
**Category:** Questions\
**Tags:** material\
**Created:** [December 22, 2022, 2:52am UTC](https://forum.babylonjs.com/t/which-matirx-can-be-used-to-make-position-fromworld-space-to-local-space/36779 "2022-12-22T02:52:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![heyefeng229](https://avatars.discourse-cdn.com/v4/letter/h/f04885/32.png) [@heyefeng229](https://forum.babylonjs.com/u/heyefeng229)\
**Post date:** [December 22, 2022, 2:52am UTC](https://forum.babylonjs.com/t/which-matirx-can-be-used-to-make-position-fromworld-space-to-local-space/36779/1 "2022-12-22T02:52:24Z")

</div>

I want to achieve the Fake Interior effect.But I don’t konw how to make position fromworld space to local space.

vec4 objCam = **ObjectMatrix** \*vec4( cameraPosition, 1.0 );  
vec3 viewDir =normalize(position - objCam.xyz);

Ask for help.

Please do not forget to add a link to a [Playground](https://playground.babylonjs.com/) to get a faster answer:

> **[Make the Best Use of the Forum | Babylon.js Documentation](https://doc.babylonjs.com/journey/forum)**
>
> Learn about the best place to get help, the Babylon.js forum.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [December 22, 2022, 9:20am UTC](https://forum.babylonjs.com/t/which-matirx-can-be-used-to-make-position-fromworld-space-to-local-space/36779/2 "2022-12-22T09:20:17Z")

</div>

Welcome aboard!

To convert from world space to loca space, you must use the invert world matrix:

```typescript
vec4 objCam = invert(world) *vec4( cameraPosition, 1.0 );
vec3 viewDir =normalize(position - objCam.xyz);

```

You can also compute the invert of the world matrix on the CPU and pass it to the shader to avoid a matrix inversion each time the vertex shader is run.

---

<div class="post-metadata">

**Author:** ![heyefeng229](https://avatars.discourse-cdn.com/v4/letter/h/f04885/32.png) [@heyefeng229](https://forum.babylonjs.com/u/heyefeng229)\
**Post date:** [December 26, 2022, 8:25am UTC](https://forum.babylonjs.com/t/which-matirx-can-be-used-to-make-position-fromworld-space-to-local-space/36779/3 "2022-12-26T08:25:41Z")

</div>

Thank you for your help. I use invert(),but an error is prompted when compiling-“‘invert’ : no matching overloaded function found”。  
Link:[https://playground.babylonjs.com/#YSIA4K#2](https://playground.babylonjs.com/#YSIA4K#2)

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [December 26, 2022, 9:26am UTC](https://forum.babylonjs.com/t/which-matirx-can-be-used-to-make-position-fromworld-space-to-local-space/36779/4 "2022-12-26T09:26:35Z")

</div>

Sorry, it is `inverse` and not `invert`!

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [January 24, 2023, 12:25pm UTC](https://forum.babylonjs.com/t/which-matirx-can-be-used-to-make-position-fromworld-space-to-local-space/36779/5 "2023-01-24T12:25:34Z")

</div>

Hello @heyefeng229 just checking in if you need any further help?
