Stencyl 3.4.0 is now out. Get it now!

Shaders! Shaders galore! Shaders for all! (gif heavy)

laserhosen

  • *
  • Posts: 21
I've been learning how to work with shaders recently and thought I'd share what I've been able to do so far. Shaders are still a bit of a black magic mystery to me, but I've learned enough to be able to port a few common shaders. I've included a .stencyl file so that you all can play around with them, alter, use them in your games, etc. I've only tested them on my PC, but they all run 60 fps for me!

First up is the Shockwave Shader! Clicking on the screen creates a shockwave. Customizable amplitude, refraction, and width.


Next is the Magnify Shader. This is just an adapted version of the Stencylpedia magnify shader that uses your mouse location to draw the magnification. Adjustable circle radius, minimum zoom, and maximum zoom.


Next, the Radial Blur Shader. This creates a radial blur that gets blurrier the further away from the mouse.


Also include are 6 other shaders. These include in clockwise order starting from the top left:
Posterization Shader. Limits the amount of colors drawn to screen. Customizable number of colors.
LED Shader. Gives the screen an LED look. Customizable LED size and LED brightness. Most numbers look odd!
Sketch Shader. Gives the game a black and white sketched look. Customizable intensity.
Thermal Shader This converts colors to give a thermal imaging appearance. Lighter colors get converted to red, oranges, yellows and darker colors get converted to greens, blues and purples.
Emboss Shader. Gives an embossed appearance to the entire screen.
Pixelate Shader. Creates a pixel effect. Customizable pixel amount.


I'll be adding more shaders as I go. I currently have a chromatic abberation, a vignetting, a tilt shift, a  glitter, a CRT effect, and a Gameboy-esque pallette swap shader in the works that I'll have finished soon.

havana24

  • *
  • Posts: 469
Seems amazing, thank you for sharing! :)
This works only on windows or also on flash/ios/android?
What about FPS in those last platforms?

Keep up the good work!
-Alessandro
My Website: www.havana24.net

Hectate

  • *
  • Posts: 4643
Plus one kudos! Also, watching this thread :)
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

laserhosen

  • *
  • Posts: 21
Thanks Hectate and Alessandro!

Seems amazing, thank you for sharing! :)
This works only on windows or also on flash/ios/android?
What about FPS in those last platforms?

As per the Stencylpedia article on shaders "Supported Platforms: Windows, Mac and Linux. Shaders are not supported on Flash or iOS. They work to a limited extent on Android."

I've only tested these on Windows but they should work on Mac and Linux just fine. I don't have an Android device so I couldn't tell you how they perform there.

laserhosen

  • *
  • Posts: 21
Attached is another shader that emulates how an old CRT monitor would look.

Press up and down to adjust the distortion amount, Z to toggle the distortion on and off, X to toggle the border on and off, and Enter to toggle the shader on and off.


LIBERADO

  • *
  • Posts: 2252
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

bonzero

  • *
  • Posts: 462
Awesome, I just wish shaders were available for mobile but very cool, thabks for sharing!

hoss08

  • Posts: 19
Looks great, thanks for sharing :)

Irock

  • *
  • Posts: 2829
Very cool! All of the shaders are working on Mac except the shockwave one (which is the coolest looking one, hahaha)
Code: [Select]
[haxelib] Shader.hx:80: ERROR: 0:31: Incompatible types (float and vec2) in assignment (and no available implicit conversion)
[haxelib] ERROR: 0:32: Incompatible types (float and vec2) in assignment (and no available implicit conversion)

laserhosen

  • *
  • Posts: 21
Very cool! All of the shaders are working on Mac except the shockwave one (which is the coolest looking one, hahaha)

Hmmm that's odd. I'll have to give it a look on my Mac later. I may be wrong but it sounds like the shader has to explicitly cast float, vec2, etc for Mac.

For instance, lines like:
Code: [Select]
vec2 uv = vTexCoord;...should be:
Code: [Select]
vec2 uv = vec2(vTexCoord);Shockwave is my favorite too, and one of the main reasons I started learning shaders! I'll try to get it working within the next day or two, along with a slew of other shaders that I'll be releasing too!

« Last Edit: September 12, 2016, 07:39:46 pm by laserhosen »

Irock

  • *
  • Posts: 2829
Let me know when you get it working on mac!

I must have it @_@

laserhosen

  • *
  • Posts: 21
Haven't had a chance to look into it yet but I'll give it a go this weekend. Hopefully I can figure out the issue!

laserhosen

  • *
  • Posts: 21
I had to rewrite the shockwave shader to work with Mac, but I was able to get it working on both Windows and Mac now. I noticed the radial blur shader is not working on Mac either so I'll have to look into that.  I'll repackage all of the shaders as well as a couple of new ones in the next few days and update the top post, but in the meantime you can get the shockwave shader attached to this post!

laserhosen

  • *
  • Posts: 21
Here's a Gameboy Color Palette shader. It limits the color palette to 4 user definable colors based on the original color's intensity. The RGB values of the 4 colors can be modified to create your own 4 color palette!


merrak

  • *
  • Posts: 1451
Have you found a way to load a normal map or other textures into a shader?