Jump to content


Photo

Shader examples - source and download included

shader

  • Please log in to reply
244 replies to this topic

#1 xygthop3

xygthop3

    You may know me from such forums as "Shaders"

  • GMC Member
  • 3367 posts
  • Version:GM:Studio

Posted 05 July 2013 - 10:13 PM

All these Shaders are available on the Marketplace here:

https://marketplace....61/free-shaders

 

All these shaders and more have been migrated to the Marketplace (forever FREE) Marketplace Link

 

CONDITIONS OF USE:

You may use any of these shaders in your game(s), paid or free. GameJolt, Steam, own website are permitted.

You may not redistribute any of the shaders/examples on the Yoyogames Marketplace, paid or free as projects, extensions, shaders, etc are not permitted.

Any questions related to these conditions please private message me.
 

All shaders use the application_surface, as such this will require you to be using either the v1.3.1307 Beta and above or v1.99.97 EA and above. The reason to move to using the application_surface was to try to accommodate cross-platform use of these shaders without me having to actually test on them.

 

Thanks


Edited by xygthop3, 18 January 2016 - 06:59 AM.

  • 86

#2 aurel

aurel

    GMC Member

  • GMC Member
  • 47 posts
  • Version:GM:Studio

Posted 05 July 2013 - 10:23 PM

I'm so jumping on this! That's exactly what i need.

 

Thank you, very, very much...

 

EDIT: tested, very easy to import, and it works perfectly in my game. I will not forget to add you to the credits.


Edited by aurel, 05 July 2013 - 10:37 PM.

  • 0

#3 Overloaded

Overloaded

    Oneirophobia

  • GMC Member
  • 995 posts
  • Version:GM:Studio

Posted 05 July 2013 - 11:10 PM

These shaders are awesome! They will be very useful! However, I tried importing the wave one into my game. In your example, the wave applies into a background. Is it possible to make the shader apply to every instance and background into my game? If it is, then do you know how can I do it? Thanks. Again, this is very awesome, thanks!


  • 1

gmc_signature.png

Upcoming 2D Turn-Based RPG. You can visit our website, like us on Facebook and follow us on Twitter.

Check out my GM Marketplace Assets!

Follow me on Twitter: @OVLDD

 


#4 aurel

aurel

    GMC Member

  • GMC Member
  • 47 posts
  • Version:GM:Studio

Posted 05 July 2013 - 11:15 PM

On a side note, and maybe it can be useful for other users, I had to stock my background alone in a special texture page, in order to get it to work correctly with draw_background_tiled.

Without it, I had bits of other textures merged on the edge of my water.


  • 0

#5 krele

krele

    GMC Member

  • GMC Member
  • 640 posts
  • Version:GM:Studio

Posted 05 July 2013 - 11:25 PM

Beautiful! Shockwave is amazing!


  • 0

If I helped you, you can help me back :3

Brocoola


#6 Overloaded

Overloaded

    Oneirophobia

  • GMC Member
  • 995 posts
  • Version:GM:Studio

Posted 06 July 2013 - 12:14 AM

Hm... I have found another problem in the wave shader. I'm trying to apply it with some water instances. I tried both draw_self(); and draw_sprite(sprite_index,image_index,x,y); however what the shader does is to switch between other random sprites of my game... yeah it's weird I know. So I created a whole new texture page for my water. The problem disappeared, however the shader doesn't do anything- at all! And that's weird because my code is the same with the example I downloaded... (expect the draw_background part of course). Any idea what is wrong? Does the shader only work for backgrounds? Thanks for your time!

Your shaders look good, I'll also download the other ones later, when I have more time!


Edited by Overloaded, 06 July 2013 - 12:15 AM.

  • 1

gmc_signature.png

Upcoming 2D Turn-Based RPG. You can visit our website, like us on Facebook and follow us on Twitter.

Check out my GM Marketplace Assets!

Follow me on Twitter: @OVLDD

 


#7 xygthop3

xygthop3

    You may know me from such forums as "Shaders"

  • GMC Member
  • 3367 posts
  • Version:GM:Studio

Posted 06 July 2013 - 12:32 AM

Hm... I have found another problem in the wave shader.

 

Without seeing the code I'm not sure what you're talking about...


  • 0

#8 Overloaded

Overloaded

    Oneirophobia

  • GMC Member
  • 995 posts
  • Version:GM:Studio

Posted 06 July 2013 - 12:34 AM

 

Hm... I have found another problem in the wave shader.

 
Without seeing the code I'm not sure what you're talking about...

 

 
 

 And that's weird because my code is the same with the example I downloaded... (expect the draw_background part of course).

 

Moreover, as I mentioned in my previous post, I replaced draw_background with draw_self();. Didn't work, so I tried draw_sprite(sprite_index,image_index,x,y); too. Also didn't work...


Edited by Overloaded, 06 July 2013 - 12:38 AM.

  • 1

gmc_signature.png

Upcoming 2D Turn-Based RPG. You can visit our website, like us on Facebook and follow us on Twitter.

Check out my GM Marketplace Assets!

Follow me on Twitter: @OVLDD

 


#9 aurel

aurel

    GMC Member

  • GMC Member
  • 47 posts
  • Version:GM:Studio

Posted 06 July 2013 - 12:54 AM

Wow, you're on fire, can't wait to try the TV one too!

 

Overloaded > I just made the test on a sprite with draw_self(), worked on the first try for me. (but I still had to make a special texture page for the sprite) 

 

edit:

 

xygthop3 > could you please explain how to get the scanline effect to be applied all the time, with no here/not here cycle? I tried to search for a timer or something in the code but found nothing about it. (Sorry if it's a dumb question.)


Edited by aurel, 06 July 2013 - 01:07 AM.

  • 0

#10 xygthop3

xygthop3

    You may know me from such forums as "Shaders"

  • GMC Member
  • 3367 posts
  • Version:GM:Studio

Posted 06 July 2013 - 01:20 AM

xygthop3 > could you please explain how to get the scanline effect to be applied all the time, with no here/not here cycle? I tried to search for a timer or something in the code but found nothing about it. (Sorry if it's a dumb question.)

 

I need help with this too....


  • 0

#11 Zei33

Zei33

    GMC Member

  • New Member
  • 17 posts
  • Version:GM:Studio

Posted 06 July 2013 - 03:33 AM

It's too bad the embossed one doesn't work too well with sprites and backgrounds with transparency. Otherwise I love the light bloom one, looks pretty nice.


  • 0

#12 Overloaded

Overloaded

    Oneirophobia

  • GMC Member
  • 995 posts
  • Version:GM:Studio

Posted 06 July 2013 - 08:44 AM

Nevermind actually, it was a mistake of mine. The shader worked great.

 

@xygthop3 you did an awesome job with those shaders, thanks! They will be very helpful.


  • 0

gmc_signature.png

Upcoming 2D Turn-Based RPG. You can visit our website, like us on Facebook and follow us on Twitter.

Check out my GM Marketplace Assets!

Follow me on Twitter: @OVLDD

 


#13 slojanko

slojanko

    HARD GAMER

  • GMC Member
  • 588 posts
  • Version:GM:Studio

Posted 06 July 2013 - 09:00 AM

I must say, shaders actually look cool :)


  • 0

Games in progress:

The unexpected: [--------------------]

My examples on YYG sandbox

My games on GameJolt

 


#14 Indecom4000

Indecom4000

    GMC Member

  • GMC Member
  • 1636 posts
  • Version:GM:Studio

Posted 06 July 2013 - 09:03 AM

I must say, shaders actually look cool :)

 

Shaders are what make next gen games look so next genny. Shaders are responsible for making your xbox, ps3, or pc games look so shiny and pretty. These shaders are pretty slick, although that normal mapping shader seems to be acting a little strange but it could just be the maps i'm testing it with. Still, looks great!


  • 0

LD-Logo-sml.png


#15 slojanko

slojanko

    HARD GAMER

  • GMC Member
  • 588 posts
  • Version:GM:Studio

Posted 06 July 2013 - 09:08 AM

 

I must say, shaders actually look cool :)

 

Shaders are what make next gen games look so next genny. Shaders are responsible for making your xbox, ps3, or pc games look so shiny and pretty. These shaders are pretty slick, although that normal mapping shader seems to be acting a little strange but it could just be the maps i'm testing it with. Still, looks great!

 

Lookin sexy indeed, but I can't get GM:S at the moment D:


  • 0

Games in progress:

The unexpected: [--------------------]

My examples on YYG sandbox

My games on GameJolt

 


#16 MancVandaL

MancVandaL

    GMC Member

  • GMC Member
  • 213 posts
  • Version:GM:Studio

Posted 06 July 2013 - 01:21 PM

Game over, this thread wins!


  • 0

#17 aurel

aurel

    GMC Member

  • GMC Member
  • 47 posts
  • Version:GM:Studio

Posted 06 July 2013 - 02:04 PM

Just tried the grass effect with more grass sprites and different values for each. that was fun to play with.

 

...One more wonder to your gallery!


  • 0

#18 krele

krele

    GMC Member

  • GMC Member
  • 640 posts
  • Version:GM:Studio

Posted 06 July 2013 - 04:07 PM

Thanks a lot for showing us how powerful shaders can be even in GM. The update barely got released, yet you're making a bunch of awesome shaders for us to learn from. Props on that mate, you make this look easy <3


  • 0

If I helped you, you can help me back :3

Brocoola


#19 xygthop3

xygthop3

    You may know me from such forums as "Shaders"

  • GMC Member
  • 3367 posts
  • Version:GM:Studio

Posted 06 July 2013 - 10:21 PM

Seems like a couple of people are having issues using sprites in the shader, someone also had issues with alpha in the embossed effect. So I've updated the emboss effect to show how to use sprites with alpha in the shader.

 

I've also added a water shader to the first post

 

Spoiler

Enjoy


  • 0

#20 battlefront

battlefront

    GMC Member

  • GMC Member
  • 108 posts
  • Version:Unknown

Posted 06 July 2013 - 10:29 PM

nice shaders! suggestion: phong shader, a terrain shader


Edited by battlefront, 06 July 2013 - 10:30 PM.

  • 0

#21 xygthop3

xygthop3

    You may know me from such forums as "Shaders"

  • GMC Member
  • 3367 posts
  • Version:GM:Studio

Posted 07 July 2013 - 02:24 AM

nice shaders! suggestion: phong shader, a terrain shader

 

Those are primarily 3D style shaders, my current shader ability is still quiet low. Maybe in the future....?


  • 0

#22 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 07 July 2013 - 06:55 AM

wow... these are awesome :) but how to change light size in normal mapping?


  • 0

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#23 xygthop3

xygthop3

    You may know me from such forums as "Shaders"

  • GMC Member
  • 3367 posts
  • Version:GM:Studio

Posted 07 July 2013 - 07:38 AM

wow... these are awesome :) but how to change light size in normal mapping?

 

This is relies on the distance the light is to the normal and changing the ambient light may help you too

 

See: uniform vec3 LightPos; uniform vec4 AmbientColor;

You can mess with the shader_set_uniform_f for both these uniforms in the draw_event

 

Have fun


  • 0

#24 Consumer

Consumer

    GMC Member

  • GMC Member
  • 143 posts
  • Version:Unknown

Posted 08 July 2013 - 07:16 AM

Very nice job writing and porting these shaders for us to learn from and use!

 

Your Gaussian blur example was helpful, but I couldn't get it to work exactly as I wanted. Primarily, blurSize doesn't seem to have an impact past a magnitude of 2.0. I can change the numBlurPixelsPerSide constant, but I'd prefer being able to pass a variable in to change it without making the loop have a non-constant number of iterations. Any ideas there? Otherwise, might be helpful to some to note that the shader is just the horizontal blur, so you can pass a vertical vector and blur a surface in 2 passes.


  • 1

#25 xygthop3

xygthop3

    You may know me from such forums as "Shaders"

  • GMC Member
  • 3367 posts
  • Version:GM:Studio

Posted 08 July 2013 - 09:41 AM

Added an Old Film shader effect, I'm sure someone requested it but I can't find the request post...

 

On a side note, yoyogames seems to have left their code for the 2D water shader that was used in their shader demo video just laying around!!!! I couldn't help myself and had to play around with it a bit.... here's the result, it needs some work because I dont completely understand the uniforms in the shader. I'm not sure if I should upload the shader code just yet tho...

 

Don't mind the Braid background, it's the best I could find the represents the shader in a static image.

 

lrud.jpg


Edited by xygthop3, 08 July 2013 - 09:43 AM.

  • 1

#26 krele

krele

    GMC Member

  • GMC Member
  • 640 posts
  • Version:GM:Studio

Posted 08 July 2013 - 10:00 AM

Whoa, that looks pretty nice even unpolished haha :D

 

On a side note, Braid was awesome :)


  • 0

If I helped you, you can help me back :3

Brocoola


#27 Mike.Dailly

Mike.Dailly

    Evil YoYo Games Employee

  • Administrators
  • 5277 posts
  • Version:GM:Studio

Posted 08 July 2013 - 12:54 PM

Yeah, it's not that we don't want to release it.... its just that the demo code is a total mess and would just confuse everyone.

 

if we can clean it up, we'll add it to the simple shader demo - that and the noise one. Be warned though, it can hurt like hell on mobile as it stands.


  • 0

#28 lordvtp

lordvtp

    GMC Member

  • GMC Member
  • 785 posts
  • Version:GM:Studio

Posted 08 July 2013 - 09:06 PM

I cant seem to get the shockwave to work within my own project....  I need it to work with views and without using a static background =\


  • 0

lord5.png

 


#29 Zei33

Zei33

    GMC Member

  • New Member
  • 17 posts
  • Version:GM:Studio

Posted 09 July 2013 - 08:15 AM

Added an Old Film shader effect, I'm sure someone requested it but I can't find the request post...

 

On a side note, yoyogames seems to have left their code for the 2D water shader that was used in their shader demo video just laying around!!!! I couldn't help myself and had to play around with it a bit.... here's the result, it needs some work because I dont completely understand the uniforms in the shader. I'm not sure if I should upload the shader code just yet tho...

 

Don't mind the Braid background, it's the best I could find the represents the shader in a static image.

 

lrud.jpg

I'd love to get a hold of that shader, even if it's messy. Obviously it could be updated later on so that it's less messy :)


  • 0

#30 AFredenucci

AFredenucci

    GMC Member

  • New Member
  • 6 posts
  • Version:GM:Studio

Posted 09 July 2013 - 03:36 PM

xygthop3 your shader are awesome :)

 

Could you please post the file of this example ? ^^ ( even if it's messy )

 

lrud.jpg


  • 0

#31 Hiric

Hiric

    GMC Member

  • GMC Member
  • 55 posts
  • Version:GM:Studio

Posted 09 July 2013 - 04:02 PM

:teehee: Now I'm seriously thinking about converting A.D.O.N. Project to GM:Studio, I expect a dramatic increase in FX quality and overall speed :woot:

*overexcited*
  :bunny:  :bunny:  :bunny:


Edited by Hiric, 09 July 2013 - 05:23 PM.

  • 0

Current Project: Adon Project (beta v0.9 build 993)
gmisignadon02.png

Info: twitter-icon-small.giffacebook_icon.pnggoogleplush.png Videos: icon-youtube.png


#32 Chrscool8

Chrscool8

    Call me Chris.

  • GMC Member
  • 2399 posts
  • Version:GM:Studio

Posted 09 July 2013 - 06:33 PM

The Gaussian Blur (almost!) looks great! On the edges of transparency, and more obviously on the edges of the bounding box, this happens, though. Any way to avoid it?

 

blur%20example.png?token_hash=AAG_0n2hfR


  • 0

Click the banner to check out my game, Suh Burb!

XPTintI.gif

Add me on Steam! Let's talk about making games!


#33 xygthop3

xygthop3

    You may know me from such forums as "Shaders"

  • GMC Member
  • 3367 posts
  • Version:GM:Studio

Posted 09 July 2013 - 09:56 PM

 

On a side note, yoyogames seems to have left their code for the 2D water shader that was used in their shader demo video just laying around!!!! I couldn't help myself and had to play around with it a bit.... here's the result, it needs some work because I dont completely understand the uniforms in the shader. I'm not sure if I should upload the shader code just yet tho...

 

Don't mind the Braid background, it's the best I could find the represents the shader in a static image.

I'd love to get a hold of that shader, even if it's messy. Obviously it could be updated later on so that it's less messy :)

 

 

As Mike.Dailly said above if we can clean it up, we'll add it to the simple shader demo. If yoyo decide to not release it, I will clean it up as best I can and upload it but for now it's up to yoyo to release it as it is their code.

 

 

Could you please post the file of this example ? ^^ ( even if it's messy )

Please see above

 

The Gaussian Blur (almost!) looks great! On the edges of transparency, and more obviously on the edges of the bounding box, this happens, though. Any way to avoid it?

 

I will take another look at the code and see if I can replicate the issue and try to find away to resolve it.


  • 0

#34 Swifty

Swifty

    Shadow

  • GMC Member
  • 516 posts
  • Version:GM:Studio

Posted 10 July 2013 - 10:02 AM

Great set of shaders here xygthop3! With the Normal Map shader, would it be possible to apply this to a tile layer? Like say a set of 32x32 tiles you've laid out in a room?

Swifty
  • 0

Don't be Afraid to Fail.


#35 Chrscool8

Chrscool8

    Call me Chris.

  • GMC Member
  • 2399 posts
  • Version:GM:Studio

Posted 10 July 2013 - 12:20 PM

 

The Gaussian Blur (almost!) looks great! On the edges of transparency, and more obviously on the edges of the bounding box, this happens, though. Any way to avoid it?

 

I will take another look at the code and see if I can replicate the issue and try to find away to resolve it.

 

 

Great. Let me know if I can try anything to help you out with testing this. Keep up the good work!

 

EDIT:

Okay, so I was messing around with it a bit more. As I suspected, it seems like the blurred color does correspond to the transparent color. -meaning, I went into the sprite editor, set the color to white, set the opacity slider on the right to 0 and 'replace', and then bucket dumped the invisible area. I did the same with black, and it made the blur that color. So, while we can't see it... it's still loading color information and ignoring the transparency information outside the frame, it seems. Hopefully that gives you a hint somehow.

 

Green, too:

blur%202.png?token_hash=AAH6IecaRqrmJZKS


Edited by chrscool8, 10 July 2013 - 12:58 PM.

  • 1

Click the banner to check out my game, Suh Burb!

XPTintI.gif

Add me on Steam! Let's talk about making games!


#36 rodgerdabbit

rodgerdabbit

    GMC Member

  • New Member
  • 10 posts
  • Version:GM:Studio

Posted 10 July 2013 - 09:58 PM

On a side note, and maybe it can be useful for other users, I had to stock my background alone in a special texture page, in order to get it to work correctly with draw_background_tiled.

Without it, I had bits of other textures merged on the edge of my water.

This is a problem with Game Maker. I talked to Mike about it and he said without writing your own system to handle anything tiled, you'll have to manually clamp the edges. There was a tech blog about it a while back. I'd like to see someone have a go at writing a tile system and a shader that automatically clamps the edges, I'm a little new to shaders so I doubt I can figure anything out soon.


  • 0

#37 alexandervrs

alexandervrs

    GMC Member

  • GMC Member
  • 745 posts
  • Version:GM:Studio

Posted 11 July 2013 - 12:24 PM

This is a nice collection!

 

I believe some of these shaders could benefit by adding more uniform "arguments" to make them easier to tweak & fine tune, especially for people who do not know much about shaders.

Like in the wave example, I changed the Shader's fragment to:

varying vec2 v_texcoord;
varying vec4 v_color;

uniform float time;
uniform float displace_x;
uniform float displace_y;

void main()
{

    vec2 texCoord = v_texcoord;
        texCoord.x = texCoord.x+cos(texCoord.y*displace_x+time*0.05)*0.1;
        texCoord.y = texCoord.y+sin(texCoord.x*displace_y+time*0.05)*0.1;

  gl_FragColor = texture2D(gm_BaseTexture, texCoord);

}

then in the draw Event:

move+=0.5;

var time = shader_get_uniform(shader0, "time")
var displace_x = shader_get_uniform(shader0, "displace_x") //get the displace_x handle
var displace_y = shader_get_uniform(shader0, "displace_y") //get the displace_y handle

shader_set(shader0);
shader_set_uniform_f(time, move);
shader_set_uniform_f(displace_x, 4.0); //set the displace_x uniform
shader_set_uniform_f(displace_y, 2.0); //set the displace_y uniform
draw_background(texDiffuse,0,0);
shader_reset();

What I did is added 2 more uniforms displace_x and displace_y that can be changed with shader_set_uniform_f to make the wavelength of the x,y smaller or bigger :)

Also, is it just me or do Shaders ignore interpolation?


Edited by alexandervrs, 11 July 2013 - 12:30 PM.

  • 0

#38 ulera

ulera

    GMC Member

  • GMC Member
  • 104 posts
  • Version:Unknown

Posted 12 July 2013 - 03:52 PM

As long as I gave credit, would you mind if I used these in a commercial project I'm making?


  • 0

#39 Chrscool8

Chrscool8

    Call me Chris.

  • GMC Member
  • 2399 posts
  • Version:GM:Studio

Posted 12 July 2013 - 04:06 PM

 

On a side note, and maybe it can be useful for other users, I had to stock my background alone in a special texture page, in order to get it to work correctly with draw_background_tiled.

Without it, I had bits of other textures merged on the edge of my water.

This is a problem with Game Maker. I talked to Mike about it and he said without writing your own system to handle anything tiled, you'll have to manually clamp the edges. There was a tech blog about it a while back. I'd like to see someone have a go at writing a tile system and a shader that automatically clamps the edges, I'm a little new to shaders so I doubt I can figure anything out soon.

 

 

Huh? Wasn't that exactly why these options were added? They fix that issue for me. They automatically extend the edge pixels.

 

34oy7tg.jpg


  • 0

Click the banner to check out my game, Suh Burb!

XPTintI.gif

Add me on Steam! Let's talk about making games!


#40 Mike.Dailly

Mike.Dailly

    Evil YoYo Games Employee

  • Administrators
  • 5277 posts
  • Version:GM:Studio

Posted 12 July 2013 - 04:17 PM

Also, is it just me or do Shaders ignore interpolation?

There is a bug in this version than interpolation only applies to the first sampler. This is fixed in the next version.

 


There was a tech blog about it a while back. I'd like to see someone have a go at writing a tile system and a shader that automatically clamps the edges, I'm a little new to shaders so I doubt I can figure anything out soon.

 


  • 1

#41 xygthop3

xygthop3

    You may know me from such forums as "Shaders"

  • GMC Member
  • 3367 posts
  • Version:GM:Studio

Posted 13 July 2013 - 03:04 PM

I've been busy creating more shaders..........code and downloads coming real soon

 

2ebzdl0.jpg


  • 3

#42 MishMash

MishMash

    GMC Member

  • GMC Member
  • 1124 posts
  • Version:GM:Studio

Posted 13 July 2013 - 03:13 PM

Those look great, love the toon shader! A Toon outline thing to go with that would look so cool xD!


  • 0

VitalitySig18thMar.png


#43 alexandervrs

alexandervrs

    GMC Member

  • GMC Member
  • 745 posts
  • Version:GM:Studio

Posted 14 July 2013 - 06:48 PM

You've been hard at work, nice ones! Makes me wanna sit down and learn all about Shaders, they don't seem all that impossible to make.

Perhaps also add some grayscale, sepia, color invert filter Shaders, pretty basic I know but still nice additions to the collection. :)

More filter-like ideas here: http://html5-demos.a...ters/index.html


Edited by alexandervrs, 14 July 2013 - 07:01 PM.

  • 0

#44 xygthop3

xygthop3

    You may know me from such forums as "Shaders"

  • GMC Member
  • 3367 posts
  • Version:GM:Studio

Posted 15 July 2013 - 09:02 AM


xygthop3 > could you please explain how to get the scanline effect to be applied all the time, with no here/not here cycle? I tried to search for a timer or something in the code but found nothing about it. (Sorry if it's a dumb question.)

I've updated the TV scanline effect, I was PM'd and it kind of motivated me to get it done, enjoy

 



Perhaps also add some grayscale, sepia, color invert filter Shaders, pretty basic I know but still nice additions to the collection. :)

These are really easy effects, I wont upload a demo for them but here are the fragment shaders that should be enough info to get you going

 

Greyscale Fragment

Spoiler

 

Sepia Fragment

Spoiler

 

Color Invert Fragment

Spoiler

Edited by xygthop3, 15 July 2013 - 08:32 PM.

  • 0

#45 alexandervrs

alexandervrs

    GMC Member

  • GMC Member
  • 745 posts
  • Version:GM:Studio

Posted 15 July 2013 - 06:53 PM

Ahh, I see. They are indeed pretty easy.

I did change the grayscale effect though, because it did not take the image's alpha into account. :)

varying vec2 v_vTexcoord;
varying vec4 v_vColour;

void main()
{
        vec4 col = texture2D(gm_BaseTexture, v_vTexcoord);
        gl_FragColor.r = dot(col, vec4(col.r, col.g, col.b, 0) / 3.0);
        gl_FragColor.g = dot(col, vec4(col.r, col.g, col.b, 0) / 3.0);
        gl_FragColor.b = dot(col, vec4(col.r, col.g, col.b, 0) / 3.0);
        gl_FragColor.a = col.a;
}


  • 0

#46 Indecom4000

Indecom4000

    GMC Member

  • GMC Member
  • 1636 posts
  • Version:GM:Studio

Posted 15 July 2013 - 06:57 PM

Just an fyi, you misspelled the word source in your thread title :)


  • 0

LD-Logo-sml.png


#47 xygthop3

xygthop3

    You may know me from such forums as "Shaders"

  • GMC Member
  • 3367 posts
  • Version:GM:Studio

Posted 15 July 2013 - 08:50 PM

 

Ahh, I see. They are indeed pretty easy.

I did change the grayscale effect though, because it did not take the image's alpha into account. :)

varying vec2 v_vTexcoord;
varying vec4 v_vColour;

void main()
{
        vec4 col = texture2D(gm_BaseTexture, v_vTexcoord);
        gl_FragColor.r = dot(col, vec4(col.r, col.g, col.b, 0) / 3.0);
        gl_FragColor.g = dot(col, vec4(col.r, col.g, col.b, 0) / 3.0);
        gl_FragColor.b = dot(col, vec4(col.r, col.g, col.b, 0) / 3.0);
        gl_FragColor.a = col.a;
}

 

Thanks, I did forget about the alpha. I've fixed the code in my previous post. Just remember what Mike.Dailly said about using as little code as possible in the shaders tho.

 

Just an fyi, you misspelled the word source in your thread title :)

hahaha Thanks, I've fixed this up


  • 0

#48 nikurizo

nikurizo

    GMC Member

  • GMC Member
  • 69 posts
  • Version:Unknown

Posted 15 July 2013 - 09:46 PM

In b&w those are better for your eyes.

gl_FragColor = vec4( dot( gl_FragColor.rgb,  vec3(0.2126, 0.7152, 0.0722) ) );

or

gl_FragColor = vec4( dot( gl_FragColor.rgb,  vec3(0.299, 0.587, 0.114) ) );

As explained in this post.

http://gmc.yoyogames...86033&p=4325197


Edited by nikurizo, 15 July 2013 - 09:46 PM.

  • 0

#49 ulera

ulera

    GMC Member

  • GMC Member
  • 104 posts
  • Version:Unknown

Posted 16 July 2013 - 04:39 AM

I just tried your scanline shader... and unfortunately when I used it it flipped everything upside down. I solved this by drawing the surface with a scale of -1 but that is less than ideal.
  • 0

#50 xygthop3

xygthop3

    You may know me from such forums as "Shaders"

  • GMC Member
  • 3367 posts
  • Version:GM:Studio

Posted 16 July 2013 - 06:02 AM

I just tried your scanline shader... and unfortunately when I used it it flipped everything upside down. I solved this by drawing the surface with a scale of -1 but that is less than ideal.

 

I see the issue, here is the new code for the Fragment shader, I've updated the source on the front page but not the download file

 

Fixed Scanline

Spoiler

  • 0





Also tagged with one or more of these keywords: shader