# Turn environment map to z-up

**URL:** https://discourse.vtk.org/t/turn-environment-map-to-z-up/12432
**Category:** Development
**Created:** [October 5, 2023, 10:30pm UTC](https://discourse.vtk.org/t/turn-environment-map-to-z-up/12432 "2023-10-05T22:30:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Sean\_Curtis](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sean_curtis/32/718_2.png) [@Sean\_Curtis](https://discourse.vtk.org/u/Sean_Curtis)
#### Post date: [October 5, 2023, 10:30pm UTC](https://discourse.vtk.org/t/turn-environment-map-to-z-up/12432/1 "2023-10-05T22:30:06Z")

</div>

I’m adding environment maps for the first time. I work in a z-up world. When I simply naively add an equirectangular map as environment map (and skybox), it’s clear that the world in the skybox and in observed in the reflection is a y-up representation. In the image below, the world y-axis goes off to the right.

 ![image](https://discourse.vtk.org/uploads/default/original/2X/8/84d9d9b5055589f422ddc3d27ea2b1c44cfdd522.jpeg)

Now, I can set the floor equation of the skybox to lie on the Wz = 0 plane. And, in the rendering, the skybox is now rendering z-up as I would expect. However, the reflections still reflect a y-up world. (See image below):

 ![image](https://discourse.vtk.org/uploads/default/original/2X/b/ba5830f38dfbcd625cc6c9aa66daf0bbaceb878c.jpeg)

I’ve tried setting a transform on the texture passed as the environment map, but that seems to have no effect. Am I missing something? How do I inform the `vtkOpenGlRenderer` that the spherical coordinates should have the poles on the z-axis instead of the y?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [October 6, 2023, 10:26am UTC](https://discourse.vtk.org/t/turn-environment-map-to-z-up/12432/2 "2023-10-06T10:26:17Z")

</div>

```auto
    // skybox orientation
    double front[3];
    vtkMath::Cross(this->RightVector, this->UpVector, front);
    this->SkyboxActor->SetFloorPlane(this->UpVector[0], this->UpVector[1], this->UpVector[2], 0.0);
    this->SkyboxActor->SetFloorRight(front[0], front[1], front[2]);

    // environment orientation
    this->SetEnvironmentUp(this->UpVector);
    this->SetEnvironmentRight(this->RightVector);

```

From: [https://github.com/f3d-app/f3d/blob/master/library/VTKExtensions/Rendering/vtkF3DRenderer.cxx](https://github.com/f3d-app/f3d/blob/master/library/VTKExtensions/Rendering/vtkF3DRenderer.cxx)

---

<div class="post-metadata">

### Author: ![sankhesh](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sankhesh/32/73_2.png) [@sankhesh](https://discourse.vtk.org/u/sankhesh)
#### Post date: [October 6, 2023, 1:04pm UTC](https://discourse.vtk.org/t/turn-environment-map-to-z-up/12432/3 "2023-10-06T13:04:17Z")

</div>

As @mwestphal suggested, you should use the `vtkRenderer::SetEnvironmentUp` and `vtkRenderer::SetEnvironmentRight` to re-orient the map.

---

<div class="post-metadata">

### Author: ![Sean\_Curtis](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sean_curtis/32/718_2.png) [@Sean\_Curtis](https://discourse.vtk.org/u/Sean_Curtis)
#### Post date: [October 6, 2023, 2:21pm UTC](https://discourse.vtk.org/t/turn-environment-map-to-z-up/12432/4 "2023-10-06T14:21:54Z")

</div>

I feel foolish. The documentation for `SetEnvironementUp()` is _right below_ the documentation for `SetEnvironmentTexture()`. Thank you for such a swift and helpful response.

For the sake of completeness:

1. `vtkRenderer` already sets the environment right to be [1, 0, 0].
2. Therefore, it was enough to set the environment up to be [0, 0, 1] to get the desired result.

 ![image](https://discourse.vtk.org/uploads/default/original/2X/a/a7b90fecd35b1e82d1323605607a6f778e327271.jpeg)
