<p>I have 2 shading models right now, one is using voxels the other one is the standard projection absed renderization method.</p>

<p>Putting them side by side I have noticed that no matter what I do one is mirrored with respect to the other.</p>

<p>To show what I mean I have a program that renders the scene with both models simultaneously. Supposedly the model loads the same camera parameters to both shading programs, so both should "see" the same thing.</p>

<p>This is what I mean:</p>

<p>In this screenshot pay attention to the color pairings. We have:
<a href="https://i.sstatic.net/s5paD.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/s5paD.jpg" alt="enter image description here"></a></p>

<p>Left:
green-red at back;
red-blue at front</p>

<p>Right:
blue-red at back;
red-green at front</p>

<p>On this image, which corresponds to a 180 rotation however we get:</p>

<p><a href="https://i.sstatic.net/7ArxN.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/7ArxN.jpg" alt="enter image description here"></a></p>

<p>Left:
blue-red at back;
red-green at front</p>

<p>Right:
green-red at back;
red-blue at front</p>

<p>So the image seems to be mirrored. However I have tried inverting the polarity of multiple parameters without success. I tried negating the focal length of the camera. Negating the x value of the ray. Negating both...</p>

<p>However no matter which combination of parameters I try I get some form of mirroring (no always the same one).</p>

<p>I calculate the ray in teh raytracer as:</p>

<pre><code>vec3 r = (vec3(f_coord.xy,1.f/tan(radians(40))));
r.y /= aspect_ratio;
vec3 dir = vec3(view_m*vec4(normalize(r),0));
dir = normalize(dir);
r = camera_pos;
</code></pre>

<p>Where f_coord is the normalized -1 to 1 coordinate of the current pixel and </p>

CC BY-SA 4.0
2018-07-19T09:05:46.400Z
You're the only one with the source code, so we can't debug this problem for you. The obvious suggestion would be to check that they're both using the same handedness for their co-ordinate systems. OpenGL is right-handed until you get to screen-space, which is left-handed.
Dan Hulme
CC BY-SA 4.0
2018-07-23T18:18:47.710Z
The top left image matches the bottom right and the top right matches the bottom left. Are you sure you are actually getting mirroring and not just a 180 rotation?
Sebastián Mestre
CC BY-SA 4.0
2018-07-23T19:44:46.363Z
A 180 rotation is a reflection
Makogan
CC BY-SA 4.0
2018-07-23T22:43:08.727Z
A rotation is actually not a reflection. The determinant of a matrix that does rotation will always be 1, and the det of a matrix that does reflection will alwayd be -1.
Sebastián Mestre
CC BY-SA 4.0
2018-07-23T23:14:43.173Z
You are correct I was too fast to answer. However in the images yes, it is a mirroring effect and nota 180 rotation. The reason why I know (and should have put it on the images) is that, on teh second floor, there is a shield in one side and a door in the other. In the images aboive you see the shield in both shading versions, which would not be possible with a 180 rotation.
Makogan
<opengl><raytracing><image-processing><c++><geometry>
How to ensure that the raytrcing coordinate system is teh same as the projection one?
Makogan
# How to ensure that the raytrcing coordinate system is teh same as the projection one?

(Asked by: username_0 on 2018-07-19)

I have 2 shading models right now, one is using voxels the other one is the standard projection absed renderization method.

Putting them side by side I have noticed that no matter what I do one is mirrored with respect to the other.

To show what I mean I have a program that renders the scene with both models simultaneously. Supposedly the model loads the same camera parameters to both shading programs, so both should "see" the same thing.

This is what I mean:

In this screenshot pay attention to the color pairings. We have:
[![enter image description here](https://i.sstatic.net/s5paD.jpg)](https://i.sstatic.net/s5paD.jpg)

Left:
green-red at back;
red-blue at front

Right:
blue-red at back;
red-green at front

On this image, which corresponds to a 180 rotation however we get:

[![enter image description here](https://i.sstatic.net/7ArxN.jpg)](https://i.sstatic.net/7ArxN.jpg)

Left:
blue-red at back;
red-green at front

Right:
green-red at back;
red-blue at front

So the image seems to be mirrored. However I have tried inverting the polarity of multiple parameters without success. I tried negating the focal length of the camera. Negating the x value of the ray. Negating both...

However no matter which combination of parameters I try I get some form of mirroring (no always the same one).

I calculate the ray in teh raytracer as:

```
vec3 r = (vec3(f_coord.xy,1.f/tan(radians(40))));
r.y /= aspect_ratio;
vec3 dir = vec3(view_m*vec4(normalize(r),0));
dir = normalize(dir);
r = camera_pos;

```

Where f\_coord is the normalized -1 to 1 coordinate of the current pixel and

**Tags:** opengl, raytracing, image-processing, c++, geometry

> **Comments:**
> **username_1**: You're the only one with the source code, so we can't debug this problem for you. The obvious suggestion would be to check that they're both using the same handedness for their co-ordinate systems. OpenGL is right-handed until you get to screen-space, which is left-handed.  
> **username_2**: The top left image matches the bottom right and the top right matches the bottom left. Are you sure you are actually getting mirroring and not just a 180 rotation?  
> **username_0**: A 180 rotation is a reflection  
> **username_2**: A rotation is actually not a reflection. The determinant of a matrix that does rotation will always be 1, and the det of a matrix that does reflection will alwayd be -1.  
> **username_0**: You are correct I was too fast to answer. However in the images yes, it is a mirroring effect and nota 180 rotation. The reason why I know (and should have put it on the images) is that, on teh second floor, there is a shield in one side and a door in the other. In the images aboive you see the shield in both shading versions, which would not be possible with a 180 rotation.  

---

## 0 answers

