Is it possible to use this shader to get the normals, but maybe something like cell shading or a metal reflexive shader?
Sprite Shaders for Unity
They could certainly be expanded further. There's already the option for using a texture to ramp the diffuse to get a cell shaded look. Adding in edge detection / drawing outlines would be ace as well.
Also allowing cubemap reflection could be cool, together with specular and possibly heightmapping too!
There's a lot that be added actually haha
If you do need a metal reflexive shader then you can always use the Standard shader in Cutout mode which is the equivalent of these Sprite Shaders in pixel lighting mode (although there's no support for pre-multiplied alpha or fixed normals). Oh plus it culls back faces.
The shaders have been written as clearly as possibly though so should be easy to try stuff out!
How exactly I use this texture to get a cell shaded look? The shadows will move with the light?
01 Aug 2016, 15:41
Well I think I find it, I just create a black square in the center and it works haha
Hey! Heh sorry I realized the light attenuation wasn't being ramped along with its direction so fixed that and some other stuff to do with ramp textures in the shaders - grab the latest ones from the first post to get the fixes!
Diffuse ramping works by filtering the effect of lighting through a 'Ramp Texture'.
Where normally you'd get a nice smooth transition from light to dark, you can instead can define how it changes using a black and white texture going from black on the left to white on the right.
If you want 'hard edges' to lighting effects like most cartoons have then your texture can be a very simply half black and half white. If you want a couple of bands in the light gradients then add more bands of grey in!
Here's an example ramp texture I was using and what it looks like when applied to a sprite. (The ground is using the same shader). This ramp texture has 8 different colors so you'll get 8 stages of 'lightness' before you reach complete darkness.
Hope that all makes sense!
Yes, perfect sense, thank you!!
For a further update, something like rim light and outerline will be cool!
Some little test I did. Image removed due to the lack of support for HTTPS. | Show Anyway
@[deleted]
Those are really nice results.
Scene-light-independent rim light sounds useful.
Well-composed games take good advantage of it for readability of important objects/characters in game.
Yeah that looks great!
Ok I've updated the shaders to support 'fake' rim lighting - its done with a simple color and value for the rim 'power' (the lower its is the thicker the rim). The rim color's alpha is used to define how strong the effect is.
Here's a naff example image which kinda looks like an invading player from Dark Souls!
I also added some color adjustment options that allow you to change the sprites hue, saturation and brightness which might be usefull to create simple color varients at runtime or faking lighting effects etc. (You can also make a sprite look like a ghost my turning the saturation down and fading it!).
There's also the added option to overlay a solid color for things like hit effects (ie you can make the whole sprite flash solid red).
This is done usign the Overlay Color in the Color Adjustment settings (the alpha is used to blend from the original color to the specified one).
This is turning into the uber Unity Standard Shader, but for sprites.
Hehe that was kind of the plan when I started on them - I wanted to use one shader for my whole game, including my 3d geometry (even if it compiles to a bunch of different variants behind the scenes).
I do plan to put them up on the asset store (for free obv) at some point.
Outlines, and possibly specular and cube map based lighting is what's left I think!
Don't forget Receive Shadows.
I mean if we're counting...
I think the uber standard shader also compiles to a bunch of variants, so it's pretty much the same.
I have no problems with it though.
Really Cool!
I was going to say that, receive shadow haha.
I am gonna take a look at the rim light, and what it can be done with that.
03 Aug 2016, 19:21
Well, it didn't work here, I checked the Rim, but nothing happened.
03 Aug 2016, 19:25
In fact, it seems that is working in reverse, the things close are white. With number between 0.1 and 1.0, negative number are full white, and 1 and above the effect dissapear.
Receive shadows does now work, I forgot to say!
It only works using pixel lighting and only when you write to depth (which should be turned on when using pixel lighting really anyway).
Hmm that sounds like your sprites normals all face the camera maybe? I should've also said Rim Lighting will only work if you're sprites have normal maps - it bascially fades to a color based how much a pixel is facing away from the camera. A sprite with no normal map will have all of its pixels facing one way - towards the camera so you won't get any rims.
To check its working could you try the shader out on a sphere?
Here, what is happening: Image removed due to the lack of support for HTTPS. | Show Anyway
Yipes that is bizarre! Thats the same settings I tried in the test level and it works fine. Maybe its the diffuse ramp? Shouldnt be though...
Could you create a sphere and add that material to it and see if it rims in the correct way?
Yes, without the difuse ramp, it worked.
I am missing an option to control the rim light distance. Because I can't control how much the rim light will affect the entire object, just the intensity. Image removed due to the lack of support for HTTPS. | Show Anyway
hmm could grab the latest shaders from the first post again? I think I uploaded a version with broken ramped rim lighting before, its certainly working for me with latest:
The rim power should dermine the distance or size of the rims - the lower the rim power the thicker the rims (0 should fill the whole object pretty much). The rim colors alpha then is used to fade the effects strenght (so if the colors alpha is zero the rims will be invisible).
Hm, I don't know maybe is my normalmap is not good enough, because with my caracter is a little strange, the borders aren't white. Image removed due to the lack of support for HTTPS. | Show Anyway
And maybe I could use rim without ramp even I use the light with ramp? Is it possible?
What Fog does?
04 Aug 2016, 07:06
I put a 3D sphere and not happened with Rim Light.
It's a 2D rim light. It requires a normal map and a flat mesh. It shouldn't work on a 3D sphere, theoretically.
Awesome Todd! No wonder Mitch stopped working on Magelight (Sorry Mitch )
Hope you're going to get compensation in the form of the asset store etc. You put in a ton of work and saved alot of people alot of time! Can't wait to check this out when I get home
BTW what tools are you guys using for your .gif captures? Everything I'm finding can't give me smooth 30\60fps results.
I use gifcam. It does 30fps (actually 33) and 50fps.
The truth actually is that gifs store frame DELAYS, not framerates. And browsers cap at 0.02 sec.
Check out my post on technical limitations of gifs to learn about why you might not get results you expect:
http://pharanpostsartndevtrivia.tumblr.com/post/126581964275/how-is-an-animated-gifs-time-delay-between
Also check this gif set: http://imgur.com/a/DwzqK