1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

Discussion Can't make shaders for vector .swf graphics

Discussion in 'GameMaker Studio 2 Community Tech Support' started by Kyon, Nov 27, 2019.

  1. Kyon

    Kyon Member

    Joined:
    Jun 27, 2016
    Posts:
    486
    So after discovering you cannot use draw_sprite_general on an vector sprite,
    I also noticed, since vector graphics arent on a texture page, you can't really make shaders for a vector (it doesn't track pixels, it does something else, I can't explain it).

    I wanted to use draw_sprite_general to make a gradient-overlay on a vector sprite.
    But since this wasn't possible I tried to do it as a surface, which worked, but as vector users know. You'll lose the scalability and anti aliasing on a vector graphic in a surface. So it's useless if your whole game is smooth and straight.

    Then I thought, I make a gradient shader.
    But this is impossible since you can't track the x or y position within a vector graphic.

    Is this true or am I missing something?
    It would really really suck.


    Kyon.
     
  2. robproctor83

    robproctor83 Member

    Joined:
    Sep 30, 2019
    Posts:
    113
    You could probably render the Sprite to a surface and then render the surface with your shader... But that kind of defeats the point of having vector art, though it's probably fine, you wouldn't want to do that with a bunch of sprites. Also if your game has zoom in/out effects the surface is going to be a pain cause you will have to manage it separately, especially if your zooming in on a Sprite and you don't want it to appear pixelated. Best of luck.
     
  3. Kyon

    Kyon Member

    Joined:
    Jun 27, 2016
    Posts:
    486
    yeah exactly, I have that right now (I'm even using draw_surface_general, no shader needed). But I can't live with everything looking smooth, and then the gradient parts of my game not:
    [​IMG]

    [​IMG]
     
  4. robproctor83

    robproctor83 Member

    Joined:
    Sep 30, 2019
    Posts:
    113
    Oh you probably need to draw to the surface scaled up by 2x or 4x then when you draw the actual surface you scale it back down by the same amount.
     
  5. Kyon

    Kyon Member

    Joined:
    Jun 27, 2016
    Posts:
    486
    [​IMG]

    Whoa, I did not expect that the make such a difference. Yeah it's sharper, but of course it's not the same as vectors.
    As seen on the picture, on the left it's the surface, on the right it's a vector. The difference isn't as big as before though.
    But I'm stressing, because making larger surfaces can cause quite some harm on cpu/gpu right?
    I just don't think this is the most efficient way.


    Are there more ideas?
    How should I start a shader for a sprite that's not in a texture page?


    Kyon.
     
  6. robproctor83

    robproctor83 Member

    Joined:
    Sep 30, 2019
    Posts:
    113
    Yea I mean making really large surfaces is surely more processor intense than a small sprite, but if your talking about a single surface it's probably fine. Turn show_debug_overlay(true) and see what your FPS is like and how it changes when making the large surface. Maybe make a couple hundred of the surfaces with repeat(100) and see how slow it really is. May not be so bad.

    And, apart from that I don't know how you would do this. I haven't really worked with vector art much in GMS apart from a few tests.
     
  7. Mike

    Mike nobody important GMC Elder

    Joined:
    Apr 12, 2016
    Posts:
    2,412
    Shaders should be able to use vectors - you just can't look up a texture, you'll only get the colour in the vertex. However.... you can supply a texture yourself, and then use screen based coordinates to map into a 0 to 1 space.

    Or.... if you know how large it'll be roughly, then supply the size and base coordinate into the shader as a constant, and then use that as your base 0 to 1 so that you can then apply a gradient. Remember X and Ys are passed into the shader for you to transform into screen space, so you can do stuff with them, especially once you're in camera space - rather than screen space.

    Shaders in 2D just require a little lateral thinking to get what you want, but it's usually possible. At the end of the day everything, can go through a shader, and you just have see what you have to play with. Worst case... render to a surface, then pass the surface through the shader as it's then a texture....
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice