AlaNintendo

  • Sep 21, 2017
  • Joined Feb 23, 2016
  • @AlaNintendo, yeah like Pharan says what you're seeing is just the specular from the standard shader. The shader doen't support specular (yet!) so a better comparison would be to compare it with the 'Legacy Shaders/Bumped Diffuse' shader which doesn't have specular.
    Its something I'll prob add at somepoint, along with a specular map as don't think it makes sense for the whole sprite to be shiny but bits like armour etc would look cool ๐Ÿ™‚

    @Pharan so NeatWolf pointed out a bug with vertex lighting a while ago which meant he had to set the normal to (0,0,1). I fixed it in my github a while ago but not sure if you guys have kept up to date with the shaders in your runtimes?

    @alcyongames As Pharan says pixel lighting will always cause overdraw unless you write to depth. Pixel lighting is split into multiple passes for each light. The only way a pass wont draw on top of a previous one is using a depth test. For that to work you need to write to depth (which means a hard alpha edge).

    If you're art style has hard edges anyways that's not a problem, use pixel lighting just turn on write to depth.
    If it doesn't (ie you've got faded edges) then use vertex lighting and increase the number of verts used in your spine animation (ie use mesh attachments instead of just quads) to make it more accurate.
    With a decent number of verts you'll struggle to notice the difference between vertex and pixel lighting most of the time, and vertex lighting is faster (though increased number of verts is slightly more CPU intensive, vertex lighting is less GPU intensive).

  • @AlaNintendo Ok I found the problem with Ambient Occulsion, it was caused by how Unity writes a special Depth+Normals texture, for that it needs the RenderType tag to be correct and I was setting it to "AlphaTest" when Unity needed "TransparentCutout" (even though you need to use AlphaTest for the Queue tag grr stupid Unity!).

    Anyways it should work now but you might have to change something in the material property for it to update your material with the correct tag (just uncheck and then check the write to depth flag or something).

    @Gabriev Nice! I've put your emission power in the latest shaders ๐Ÿ™‚

  • Hey guys! Sorry for going missing, I somehow didn't see the responses.

    Firstly I've fixed some pesky typo's in the shaders where I wrote .rbg instead or .rgb grr
    Anyways!

    @AlaNintendo so first up you should never use mesh normals with rim lighting on spine meshes. Actually you shouldn't really use mesh normals at all on spine animations for lighting in general. The normals will just point outwards from the mesh and make it look like a flat bit of paper (which in essenese is what a sprite is!).
    By using a shader normal the shaders will treat it so the normal is constant in camera space meaning the normal is always facing into the camera even when the sprite is not. This might sound weird but it ends up making the lighting look a lot more 3d and realistic for sprites.

    For rim lighting however you need a range of normals for it to work (it needs to find the 'rims' of places where the normals change dramatically).
    For this on Spine Animations you need to use a normal map. I use this which works pretty nicely: https://www.codeandweb.com/spriteilluminator

    For your second image I've found a bug with the way I apply fog, I need to lerp the fog color to clear depending on the pixels alpha, I've now fixed this and it'll be in the latest shaders ๐Ÿ™‚

    What exactly is going on with ambient occlusion in the last pic? Is this a Screen Space Ambient Occlusion effect? Or something else?

    @LoneWarrior I love that art style! Emission would be hella cool and something I'd love to have in my game so is prob next on the list ๐Ÿ™‚
    I'm curious as to whats going on with the alpha fade, will look into that too.

    Self shadowed sprite would be very cool but very hard to implement I think. Decent normal maps can help give that illusion but actual shadows a prob going to be too hard for now.

    Shadows for vertext lighting is something I looked into very briefly and think its possible just harder than pixel lit shadows - you can use pixel lighting with hard alphas though, the animation in you gif should work pretty well with that. It's more accurate than vertex lighting and supports full shadows and as long as your sprites got solid edges work fine (to get it to work turn on write to depth and play around with the Depth Alpha Cutoff).

    I use pixel lighting in most place although I've got one character thats furry and pixel lighting doesnt work with this as furr needs full alpha blending to look right so for that character I use vertex lighting. Will look into shadows for that too!


    16 Sep 2016, 12:31


    Ok emission was nice and easy, it's in the latest shaders on the front page ๐Ÿ™‚


    16 Sep 2016, 16:45


    @RtFishers I had a look at the alpha fade bug and think I've fixed it for vertex lighting as best I can , however you'll always get the fade to black problem when using pixel lighting.
    Because pixel shading is done over multiple passes it has to use depth testing to stop drawing lit areas over the top of each other.
    Because it writes to depth it blocks lighting happening on areas beneath the top most sprite. As this top sprite fades out you start seeing the unlit sprite behind it, unfortunately theres no way around this.
    Unity standard shader does not allow for alpha fading in "Cutout" mode for this reason.
    Anyhow if you're fading sprite in and out OR using any areas with partial alpha then I recommend using vertex lighting ๐Ÿ™‚

    @LoneWarrior I had a look into recieving shadows in vertext lighting and alas I don't think it's possible without some crazy hacks like I did to get normal maps working in vertex mode but I don't think theres enough texture coord channels to support both at the same time!
    Unity's own docs say vertex lighting does not support shadows here (although it also says it doesnt support normal maps and managed to get that one to work ๐Ÿ˜‰ )
    https://docs.unity3d.com/Manual/RenderTech-VertexLit.html

    Anyhow casting shadows still works fine in vertext mode, if you really want a character to recieve shadows I recommend authoring it without any faded edges and then using pixel lighting with write to depth enabled ๐Ÿ™‚