Mirror reflection - light


(Lukas 87) #1

Hi,

I have problem with mirror relfection.
I use the function mat4.scale(matrix, matrix, [-1, 1, 1]). Reflection is correct, but the problem is with light (object is dark).
So, can i use function/change parametrs in the API such as "FlippedNormals"?


(Stephomi) #2

Hmm I don't really think it's a good idea to use negative scale (or at least it should be uniform on the 3 components [-1,-1,-1]).

Do you have an example of what you are trying to achieve?


(Lukas 87) #3

I have a model: https://sketchfab.com/models/393ee84f66384b0a98a78e5b620c7b46 and I'm trying to make a mirror image in the API.
I use the function mat4.scale. It's good, I have a mirror image, but the light inside.


(Stephomi) #4

I'm confused by "mirror image", Are you trying to do something like https://sketchfab.com/models/7ac3d8ca78b347f5b5150d5efe01080c ?

Just wondering why you would need flippedNormals.


(Lukas 87) #5

Speaking of the mirror, I mean transformation Y-axis like this: http://studentstudyhub.com/wp-content/uploads/2014/04/reflect-y.gif


(Stephomi) #6

Ahhh ok it's clearer now.

When you use a mirror matrix, the triangles are reverted too so they are visible only because double sided is enabled (no backface culling).
In sketchfab, to get correct shading the normal needs to be consistent with the triangle clockwiseness.

Unfortunately I don't have any solution right now to get it work only with the API (except on using shadeless since it won't use normal information).


(Extradom) #7

Maybe we can create some loop to fix all triangles? There is a command to flip normals? Create two models (basic and mirrored) doesn't make sens.