Yep, rendered on cube. I tested it again with 5.4 Unity, and there it works. So there must be something changed in 5.5
Sprite Shaders for Unity
Anyone having problem working on mobile?
@dothem Hey so I just checked the shaders out on android and it all works for me ALTHOUGH - do check what your pixel light count is when running the game I reckon that will be whats making pixel lighting not work for you.
Go to Quality settings inside of Project Settings.
For each of the quality settings (Fastest/Fast/Simple etc) check the pixel light count.
If its zero then pixel lighting won't work, and you should use Vertex lighting instead. Less than 4 means less lights will effect objects than when using vertex lighting so it will look noticeably different.
Android /mobile tends to pick a faster quality setting than when you run the build on your PC so there might be lighting differences.
Vertex lighting is recommended for mobile because of this (its cheaper to do).
It would be nice to automatically switch shaders when pixel lighting is disabled but not sure there is.
Hey. I'm trying to use volumetric in my project.
I'm having difficulty with the imposition on the volumetric character.
Character appears transparent and looks nice smooth edges. Either the light is working properly, but the character at the same time gets rough edges.
I tried all the options of the shader settings could find. However, the ideal solution is not found.
Please help find a solution that will help to get smooth edges and realistic behavior of light.
The following video shows the essence of the problem.
@xcube That's because Volumetric lighting depends on the depth buffer, you can't write soft edges to the depth buffer, a pixel is either written at its depth or not written - fading doesn't really make sense physically.
However!! I did manage to write a custom camera replacement shader that allows just that - writing soft edge to the depth buffer, its actually on my github:
https://github.com/traggett/UnitySpriteShaders/blob/master/SpriteShaders/SpriteDepthNormalsTexture.shader
Using that you can generate a depth+normals texture for a camera that allows you to use effects like Depth of Field or Volumetric Lighting without having to write to depth when rendering sprites (the sprites get written to the depth texture afterwards, with soft edged alpha).
Anyways! I'm away for a bit but though I'd leave peops with a christmas present - I've added Specular maps to the shaders :sun:
It was a hell of a lot more work than I'd imagined - I fell down the rabbit hole somewhat pulling apart how Unity's new shaders do their physics based specular effects but managed to get it workign with the sprite shaders.
Specular effects are optional (so wont effect shaders performance unless you enable them) and are based on the Metallic workflow for shiny materials using a Metallic Gloss Map as explained by the first chart here:
https://docs.unity3d.com/Manual/StandardShaderMaterialCharts.html
@ToddRivers Thank you very much for your help!
But I was not able to apply your shader SpriteDepthNormalsTexture.shader camera. I'm not a great expert in this field.
Nevertheless, I tried to create your shader and script UseShade.cs
public class UseShade : MonoBehaviour {
public Camera custom_CAMERA;
public Shader myShade;
void Start () {
custom_CAMERA.RenderWithShader(myShade, "_forVol");
}
}
But it did not change anything in the scene. What am I doing wrong? :S
If it is interesting to test the project spread. (Unity5.5.0f3)
https://drive.google.com/open?id=0B3A2ZpysfaxBNm9MaXRlY3lUSjg
ToddRivers ha scritto@[cancellato] That's because Volumetric lighting depends on the depth buffer, you can't write soft edges to the depth buffer, a pixel is either written at its depth or not written - fading doesn't really make sense physically.
However!! I did manage to write a custom camera replacement shader that allows just that - writing soft edge to the depth buffer, its actually on my github:
https://github.com/traggett/UnitySpriteShaders/blob/master/SpriteShaders/SpriteDepthNormalsTexture.shader
Using that you can generate a depth+normals texture for a camera that allows you to use effects like Depth of Field or Volumetric Lighting without having to write to depth when rendering sprites (the sprites get written to the depth texture afterwards, with soft edged alpha).Anyways! I'm away for a bit but though I'd leave peops with a christmas present - I've added Specular maps to the shaders :sun:
It was a hell of a lot more work than I'd imagined - I fell down the rabbit hole somewhat pulling apart how Unity's new shaders do their physics based specular effects but managed to get it workign with the sprite shaders.
Specular effects are optional (so wont effect shaders performance unless you enable them) and are based on the Metallic workflow for shiny materials using a Metallic Gloss Map as explained by the first chart here:
https://docs.unity3d.com/Manual/StandardShaderMaterialCharts.html
Can't say it enough, but you sir are a god! Thanks so much for falling down the rabbit hole. We all definitely appreciate it.
Have a great winter break and early happy new year! :party:
Hi there!
I was wondering if there is an easy way to colorize differently several Spine Skeletons instances of the the same Prefab, without causing all the contained materials in the MeshRenderers to automatically create a separate instance of each material for each SpineSkeleton?
Is there any workaround for this? (excluding having skins colored differently of course - last resort)
I have several skeletons in the scene and I fear that colorizing each material individually could compromise performance.
@[cancellato]
Is this related? Spine-Unity Runtime Documentation: Setting Material Properties Per Instance
Pharan ha scritto@[cancellato]
Is this related? Spine-Unity Runtime Documentation: Setting Material Properties Per Instance
Totally! It's 100% my case. I didn't know MaterialPropertyBlocks existed, I think all my apps are going to be a little more optimized from now, thank you a lot! :nod:
Hey everyone, happy new year!
I've, just checked in some updates to how fixed normals work - you can now specify them either in camera space or model space and adjusting for lighting back faces now works correctly (there were a couple of bugs with it).
However correct back face lighting now requires mesh normals (its the only way the shader can know what direction a vertex is facing in).
The shader does now remind you what it wants in terms of tangents or normals though
If you grab latest you might need to retick 'use fixed normals' on your materials as the defines have changed, sorry!
The majority of the time with Spine animations you don't need to adjust the tangents for correct back face lighting - it's needed only when you have rotated your object to face away from the camera and thus the tangents need to be flipped in the shader.
I recommend instead of rotating sprites, use the Spine skeleton.FlipX/Y. This means your Spine animation won't need normals and things like Z offset for submeshes will stay correct.
If you render Unity Sprites or Meshes then you might need to turn on the 'Adjust Backface Tangents' option if they face away from the camera.
03 Jan 2017, 12:39
@[cancellato] yeah using a custom Depth+Normals buffer is pretty advanced to be fair.
What you're doing there is correct - that should render the depth+normals for the scene including soft alpha'd sprites.
However you want to render into a RenderTexture which you can then pass through to your Post Effects. (ie give the camera a target texture).
You will also need to edit the PostEffect shaders you're using to use this newly created RenderTexture instead of the default camera Depth+Normals texture.
Admittedly this is all pretty advanced stuff and you'll need to be able to edit your post effects shaders to get it to work but it's what I do for my game so def works
I recommend reading this (plus the first 2 parts) which explains the CameraDepthNormals texture and how it gets used with a simple example.
http://willychyr.com/2013/11/unity-shaders-depth-and-normal-textures-part-3/
In this example he's telling his camera to render a depth+normals texture for him with the following line of code:
camera.depthTextureMode = DepthTextureMode.DepthNormals;
Then his post effect shader is using that texture with:
_CameraDepthNormalsTexture
Which inside a unity shader automatically grabs the last cameras generated DepthNormals texture.
In your case you don't want to generate a texture or use _CameraDepthNormalsTexture as you've rendered your own special one. So instead of using _CameraDepthNormalsTexture in the shader, pass it the texture you rendered into with
camera.RenderWithShader() and you should see the normals and depth for your Sprites.
This can then be adapted for things like Depth of Field or SAAO.
Happy new year!
Thank you for your help and information. I will try to apply it in practice.
Cool, good luck! If you want to use it for a Post Effect that just uses the Depth Buffer (Like I think Unity's built SSAO now does) then I've added a shader that renders a custom depth buffer for a camera with nice soft edges for sprites that don't normally write to depth:
https://github.com/traggett/UnitySpriteShaders/blob/master/SpriteShaders/SpriteDepthTexture.shader:
However aswell as changing references to _CameraDepthTexture in the post effect shader to be your own depth texture you will also need to use DecodeFloatRGB() instead of SAMPLE_DEPTH_TEXTURE() to get a depth value from the texture (SAMPLE_DEPTH_TEXTURE uses 32bit RGBA for depth, we have to use just 24bit RGB because we're using the alpha channel to blend the soft edges).
DecodeFloatRGB() is inside ShaderMaths.cginc.
I'm playing around with the new specular map option. Super cool stuff man! !
Just letting you know, I haven't had any trouble with it on 5.5.0f3.
09 Jan 2017, 09:02
@ToddRivers
Hi ToddRivers, do you have this performance spike when you are using pixel lit, sprite?
Immagine rimossa a causa della mancanza di supporto per HTTPS. | Mostra Comunque
Hey AlaNintendo!
I have noticed spikes in the editor when you turn on/off features on a material for the first time. I haven't experienced them at run time though - looking a the profiler it looks like its the editor compiling a new version of the shader when defines get enabled / disabled. Thats taking 1131ms for me which is a bit scary!
Immagine rimossa a causa della mancanza di supporto per HTTPS. | Mostra Comunque
I suspect I've either done something stupid or gone over the shader keyword limit or something.
Once the shader is compiled there should be no more spikes though (so shouldn't effect performance apart from in the editor)
Is your spike happening whilst playing? It strange it looks like its calling shader.editorloadvariant - the way I thought Unity worked was it makes a compiled version of your shader beforehand.... maybe i need to do something to make unity spit out variants properly when it builds:
https://blogs.unity3d.com/2014/05/06/shader-compilation-in-unity-4-5/
Hi ToddRivers,
I believe it's just lagging while in editor. My builds lag on occasion, but that may be because of other problems with my own code haha..
But just wanted to give you a heads up on what I was experiencing, in regards to your shader.
Thanks again for this. It's been a really awesome shader for Spine!
Hi @ToddRivers,
I'm keeping up with the updates and keep thanking you for creating these shaders.
Is there any chance you could add support for simple offset-shadows to the ubershader (or maybe also an outline?), as part of the ubershader, or as a separate single-coloured-shadow-shader, maybe with some configurable edge blurring that also supports fading the skeleton shadow as a whole (an alpha value for the whole skeleton, not made by overlaying each bone's alpha: i.e.: like a real shadow?)
I remember to have seen something like a skeleton trail FX but can't remember where, and if the trail was actually revealing each bone's borders when fading or was faded as a whole.
If it's not available right now, and you're available to work on it, I'd happily donate to have this feature (working on mobile, I suppose some multiple passes could be needed, but I would be using this for the main chars only)
Cheers,
Alessandro Salvati
Hey folks, does anyone have input for this guy?
Hey! Added a little update which I think was requested a while ago - scaling for normal maps (I noticed Unity added it into their standard shader so just copied that code) that means you can tweak how bumpy your bump map is in the shader
As far as my normal map flow I use SpriteIlluminator to create my normal maps. I'm still paying around with the best way of solving 'pillowing' where joints or limbs that should be one continous shape look like seperately beveled parts.
One method is instead of using SpriteIlluminator to bump each sprite image seperately, export your full character or full limb from photoshop, bump that in SpriteIlluminator and then reimport it into photoshop and then cut it up and export it in the same way you cut up the character for animations.
This means the parts that should be one piece like a leg for example get bumped as they should.
Sure there's better methods though!
What are the limitations of these Shaders? I'm using this for my mobile game. The sprites (SpriteRenderer) flickering very hard on mobile. With flickering I mean appear / disappear of the sprites. Anyne facing the same issue?