• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Discussion Can't make shaders for vector .swf graphics

Kyon

Member
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.
 
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.
 

Kyon

Member
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.
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:


 
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.
 

Kyon

Member
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.


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.
 
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.
 

Mike

nobody important
GMC Elder
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....
 
Top