# how to scale am matrix non-uniformly/with negative values?

for reflections in my water shader i need to flip my scene upside down. i’m using glscalef( 1.0f, -1.0f, 1.0f) for this atm, but i’d prefer to use my matrix class for this, of course. but i can’t figure out how to scale a matrix non-uniformly and with negative values. no matter what i do, my scene is always deformed… any hints? thank you

If i am not mistaken, a scale matrix is
(sx, 0, 0, 0)
(0, sy, 0, 0)
(0, 0, sz, 0)
(0, 0, 0, 1)
Hence you need to use something like
(1, 0, 0, 0)
(0, -1, 0, 0)
(0, 0, 1, 0)
(0, 0, 0, 1)
Or?

thank you, that did it!
ok, next question - how to apply scaling to the inverted matrix?

Scale it by the inverse values…

(1/sx, 0, 0, 0)
(0, 1/sy, 0, 0)
(0, 0, 1/sz, 0)
(0, 0, 0, 1)

And of course you have to premultiply instead of postmultiply, as with every operation on the inverse matrix.

ah that’s probably the problem - i tried to multiply by the inverse values after i applied translation and rotation, but this screwed it all up. so i have to scale first, and then translate and rotate? i’ll give it a try thanks.