2d shader to flip an image
Asked Answered
S

5

0

hello everybody Im trying to make a 2d memory game but the problem is to flip the card. in order to flip the card I need to rotate the image along the y axis but in 2d I cant do that so instead I need a 2d shader that will rotate the image along the y axis with the specified value (for example 0 means the image is not flipped at all and 1 means the image is fully flipped). do you know how can I implement this shader? (since I dont know much about shaders).

Soutane answered 1/8, 2021 at 18:7 Comment(0)
S
0

Do you really need a shader for it? Would scaling along an axis not emulate rotation?

Sitra answered 1/8, 2021 at 19:47 Comment(0)
S
0

well you right but the thing is that with shaders you can make the rotation effect more realistic and actually making it look like a true 3d rotation (something like a perspective effect). scaling would work but if there is a shader that can produce a better effect that will be cool.

Soutane answered 1/8, 2021 at 20:10 Comment(0)
S
0

Well at that point you might be better off asking yourself if it's perhaps worth making it actually 3D instead. 3D doesn't have to mean bad performance. If you don't use the effects and features that have a heavy cost. Probably better to use fixed-function transforms rather than shaders for the rotation I would think.

edit: or if you are really adamant about keeping it 2D why not use animated spritesheets? You could just have the rotation animation be pre-rendered. That would be significantly more performant I'd expect.

Sitra answered 1/8, 2021 at 21:15 Comment(0)
M
0

You may be interested in this shader: https://godotshaders.com/shader/perspective-warp-skew-shader/

Maymaya answered 1/8, 2021 at 21:27 Comment(0)
S
0

yep I think this shader does the job, godot shaders? why I didnt know about this site before so much awesome shaders. thank you everybody.

Soutane answered 1/8, 2021 at 21:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.