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

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

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

  • 1
    $\begingroup$ 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. $\endgroup$ – Dan Hulme Jul 19 '18 at 9:05
  • 1
    $\begingroup$ 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? $\endgroup$ – Sebastián Mestre Jul 23 '18 at 18:18
  • $\begingroup$ A 180 rotation is a reflection $\endgroup$ – Makogan Jul 23 '18 at 19:44
  • 1
    $\begingroup$ 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. $\endgroup$ – Sebastián Mestre Jul 23 '18 at 22:43
  • $\begingroup$ 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. $\endgroup$ – Makogan Jul 23 '18 at 23:14

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.