Hi!
I’m making a 2d game where shadows are symbolic shapes and made from other sprites with decreased alpha.
However shadows are additive (sprite-default on material, and all sprites from game are in one Atlas) what is not what we could expect from shadows.
I would like to get the real effect which concept is attached to that post.
Pardon if there were already answers for that, however I’m not a “hardcore” developer and really couldn’t find any answer for that, because I don’t even know what terms should use to achieve desired effect. I can only guess that it has to be made with shader on material but it is a black magic for me.
PS. Why the language used to program shaders is so hard?! Is it a standard language for such operations? Is this language procedural/imperative or declarative/functional?
Thanks!
And Happy New Year to all! ![]()
Ok. I manage to find out the concept. So here it is:
- generate world without shadows in one camera
- generate shadows which will be black boxes in another camera
- combine those two buffers, but for second buffer use alpha value and culling
Here is the solution on blog: http://frozenpixelstudio.com/uniformly-transparent-silhouette-in-unity-game-engine/
Here is probably the way how we combine buffers: graphics - unity3d: Use main camera's depth buffer for rendering another camera view - Stack Overflow
now have to try to implement it in practice…
the problems i see for now are:
- have to use 3 cameras
- ground, shadows, proper objects
- shadows will look good on ground but will never cover the objects (I want to use z value and y to simulate top/side view)…
Unfortunately it can’t be done with Unity Free… Free version can’t deal with post processing the write buffer…
Also I have found something like this:
but it doesn’t work (or it is but I’m doing something wrong?)…
Ok. Manage to get that effect.
Turned ZWrite On and ZTest Less on Transparent Shader.
Downside is that sprites of shadow must be at the same Z coord value.
Is it possible to not set Z value (specific requirement for that game)? Changing it makes me a headache because of playing with sorting layers…
The stencil buffer is available in free… I don’t know how to use it but it could be usefull for you.
