Zooming shader? (Layer zooming)

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hi there,

    I'm having a bit of trouble getting any zoom shader to work. I want to make a simple zoom feature, that will zoom in and out of a layer with the mouse wheel. This should be done with a shader - as it doesn't mess with the positions of the objects.
    I seem to remember getting it to work before, but i can't seem to work it out now! But I also remember there was a problem where sometimes sprites would have some crazy distortion put on them (is this to do with the 1 pixel border you are meant to use?)

    EDIT - I have found my old file where I have correctly made this - But there's still the problem that when objects pass below 0pixels (0,0 co-ords) even though my virtual height and width is set to -1 (infinite) the objects disappear, and it distorts them strangely before they finally go invisible... Anyone know if this can be fixed?


    Any help would be appreciated.
    Thanks,
    Alex

  • I implemented a zoom in my game, and after messing around with zoom shaders applied to both objects and to the frame, I settled on what I think is a better method.

    Make your game at the closest zoom level you want. (So frame size, sprite size, etc, should be pretty large.) Then in your MMF event code, actually scale and reposition all of the objects to simulate the zoom. Do this as the last events in your frame.

    Then the starting events of the frame should reverse the process, returning all objects and scales back to full zoomed in size. This way, all of your events occur at the closest zoom level, and the zoom is only applied to objects in the very last events each frame.

    HWA is plenty fast enough to use this method, and you don't have to worry about all the glitches that occur when using a zoom shader. Not to mention, you can have hi-def art when zoomed all the way in this way. (You don't end up just blowing up the lower res sprites.)

  • Thats a genius idea! That would certainly get round the bugs of using a shader, although the math for zooming+displacing objects i remember taking me a day or so, but that was years ago..

    Thanks, i'm going to give it a try. but it would be alot better if we could get a working zoom shader at some point ;)

  • I made a quick example of a zoom system. The example shows the bug though but it could have a workaround made and be updated a lot as it's just a simple example really. :)

    Please login to see this link.

  • astrospoon, thats a good idea but wouldnt you get rounding errors when you reposition objects when your zoomed out? Say your zoomed all the way in and move your object 2 pixels. When you zoom out again, your resizing and repositioning your object so you are actually rounding out any decimal that would occur when you scale down. Then when you zoom in again, you would be zooming in based on the rounded value, resulting in you losing the 2 pixels you just moved. Unless you stored the true positions as floats in alterable values this could cause problems for many games...

    previously know as bigredron

  • Your probably right redron, why can't we just have a working shader? Atom's example is just showing that the shader works only for zooming IN, which was my problem in the first post. Zooming is pretty useless if you can only zoom in.

  • One thing i was thinking of doing was to use large imported graphics and then set the zoom in more. Then when you zoom out it would create the effect as long as you worked to scale. The thing of course is that this could be more annoying to setup in the frames.

    My example does work for zooming in but it also has a bug depending on the position you are in the frame. With the extra stuff i added it was only slightly offset though and would work for simple areas but still needs a slight fix to center the player on zooming but i couldn't figure it out at the time. Nobody ever gave me any feedback for that thread unfortunately even after 2 bumps and many downloads.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!