Shadow volumes in Unity on the wiki

The other day I played around with shadow volumes, just as a proof of concept (in a sense “stencil buffer is not needed for shadow volumes”). I put a package on the wiki: Shadow Volumes in Alpha

It handles only very few use cases, and it consumes lots of fillrate by design (hey, it’s shadow volumes!), it requires specially postprocessed or at least high-polygon meshes, it sometimes has small artifacts and it’s a bit awkward to use. On the plus side, the shadows are pixel-perfect and should work on pretty much all hardware (I only tried on MacBook Pro though).

This is quite cool, and actually very useful. If the extrusion were more reliable, I’d put this to use immediately. It looks really high quality when it works.

Maybe one day I’ll play around with your code.

Thanks!

EDIT: Any suggestions to improve this issue, either artistically or programmatically? This is a closed form, albeit a bit odd in places. Would geometry face extrusion help here? or do I just need a cleaner model? Maybe a simplified shadow model attached would do it.

68022--2544--$picture_12_704.png
68022--2545--$picture_13_444.png

I’m not really sure; with shadow volumes you never know :wink: Either it’s not actually 2-manifold (in humanspeak: “each edge belongs to exactly two triangles”), or has hard edge creases (try 90 degree smoothing angle in import settings), or has too high shadow volume depth complexity.

Yeah, i rebuilt the head, with no funny geometry, eye sockets or anything, and it looks like the positive faces are negating the shadow faces-- including the shadow faces of objects behind it

import smoothing set to 90 or greater

I realize this was just a pet project, but it’s so cool!

68031--2546--$picture_14_373.png

It works on terrains too… and it also runs without complaining on my copy of Indie. :shock:

Very nice!

Alright, sorry to keep posting just fooling around here:
I reversed the order in your shader, and woila. Seems to work now, but only with cleaned up geometry. My original geometry doesnt work.
SO it looks like this method requires dedicated models. And I bet some clever shader programming could clean up some remaining artifacts.

// Draw back faces, halving the value in alpha channel
	Pass {
		Cull Front
		Blend DstColor Zero  
		
		CGPROGRAM
		ENDCG
	
		SetTexture[_MainTex] { constantColor(0.5,0.5,0.5,0.5) combine constant }
		
	}
	
	// Draw front faces, doubling the value in alpha channel
	Pass {
		Cull Back
		Blend DstColor One
		
		CGPROGRAM
		ENDCG
	
		SetTexture[_MainTex] { constantColor(1,1,1,1) combine constant }		
	}

68036--2547--$picture_15_942.png

Nice that it’s self shadowing but it lacks additive shadows and also here with glitches.

68077--2556--$bild_3_838.png

Glitches can be fixed by either postprocessing meshes or doing extrusion on the CPU, like written in the wiki article. You’re very welcome to implement that yourself of course!

Thanks, but that’s exactly the reason i once bought unity for and invested quite some time into: Getting a working tool which spares me writing fixes for this and that and so beeing able to concentrate on the core of my work and getting it done faster.

Shadow Volumes on the wiki is a script I did in an hour while on the airplane. It’s not a supported feature, and if it does not work, then it does not work. Maybe oneday I’ll make it more robust, or anyone else will make it more robust. It’s just my small contribution to the community, hoping that someone might find it useful. If you’ll keep on just complaining about it, I’ll just stop putting things on the wiki; will save me some time and nerves.

You know that i need a more professional solution which i can use for work instead of a script which produces such problems, so obviously i favour if otee would identify this as a lack in their featureset and work on a reliable solution instead.

taumel, i cant believe your audacity! then again i guess there’s always a few disgruntled children like you haunting every project. aras didn’t post this as a ‘new unity feature’ rather an experimental effort worked on in his free time. obviously its a creative gesture - if it’s over your head ask questions and learn but don’t complain.

I think Aras made it very clear before / when he posted his stuff that this was:

Just because Aras is a developer for UT doesn’t mean he can’t play around with stuff and offer it to the community (which I think is something people should really appreciate instead of complaining about it!) - but it should be quite obvious that this is just what it is: A contribution to the community, and not “the official cool new, robust, fully tested, generic work for all cases Unity feature”.

There’s a significant difference in the process: A proof of concept can be done quickly - implementing a new feature is something that comes with a whole bunch of complexities (some of them technical, some of them organizational). So, you can either be happy that you get a proof of concept almost immediately, or you can wait until it makes it through the process … or not.

Keep in mind: This is the showcase forum - and not UT’s official new features announcements.

And also keep in mind: The built-in Shadows were just introduced in Unity 2.0, so that’s still a pretty new feature - and new features naturally have a tendency to sometimes have limitations or bugs. That’s just the way it is in software-development.

Most companies don’t have their developers on their forums to interact with their customers in the generous way that UT has this, and there’s an obvious reason for that. However, I honestly think this “shock and awe support” is really one of Unity coolest features.

Sunny regards,
Jashan

Honestly holtsch you don’t know the background to this so i doubt the sense of talking to you about it. It’s nice that you want to explain the way software is beeing developed to me but i know that already… ;O)

We’re getting off topic here. Please keep the following discussion about the shadow volume package on the wiki, instead of talks about what should have been done.

This is quite cool Aras. Thanks a bunch. When I have some free time myself, I may try to extend it.

I guess I’ll have to read up on CPU extrusion.
:slight_smile:

We do not consider the hardware requirements for shadows to be a lack of our featureset. We have no scheduled plans to fix this, and have more pressing features to be working on. In short, it is not likely that you will receive this feature (built-in shadows working on older hardware) any time soon. Some other shadow solution may or might not appear, but the thing that was discussed with you was more like Projector-based shadows, not a “set checkbox and there are shadows” type of shadows.

Since this is apparently very important to your work, I would like to offer you a full refund on your Unity 2.0 upgrade.

Sincerly,
Nicholas Francis
Co-founder

Nice one Aras :slight_smile:

/P

@nicholas

Well, this is at least a clear statement where one knows what to expect, although it points into a different direction than what could be expected due to what has been said during the last year.

So i’m not sure if you’re making yourself the things a little bit easy here with offering a refund for the product. Actually the invested time would be more interesting getting refunded but i guess Albert would be against it.

I’m not quite sure what you mean with a projector based shadow.

What Nicholas is saying: current built-in shadows (the shadowmapped, self-shadowing kind) are very unlikely to ever run on older hardware, because of limitations of said hardware.

What I was discussing in private emails with you is that I want (this is not a commitment) at some point (this is not a release date) implement decal-style shadows. Very similar to what you can do with projector + CharacterShadow script on the wiki, but it would actually construct a geometric decal (thus saving fillrate), and be easier to setup.

I still want to do this, because it could be enough for a lot of games (where you basically want “shadow under this object”), and would have much lesser hardware requirements, but read the first sentence of the previous paragraph.