clamp
clamp

Reputation: 34006

opengL: mirror object in glsl shader

is it possible to mirror an object along some axis, just in the vertex shader?

if i simply scale one axis by -1 in the projection matrix, i get bad culling and would need to change the culling from backface to frontface in the application. is there a way to do it without changing the culling?

thanks!

Upvotes: 1

Views: 1810

Answers (1)

datenwolf
datenwolf

Reputation: 162164

Culling is done based on the so called chirality of the face, i.e. the turning direction in which the vertices are drawn. It is the core property of a reflection that it changes the chirality. So you'll inevitably have to switch the culling behaviour, since back-/frontface culling happens purely on the chirality in screen space.

You could use a geometry shader to exchange two vertices of each triangle which will also switch the chirality. But frankly: Reflections require some additional precautions like stencil masking and such; switching the culling function is no big deal then, too.

Upvotes: 6

Related Questions