Shadows from particles and from nothing

I know almost nothing about shader coding, so this is basically a challenge or a request for help. In two parts:

  1. is it possible to create a particle system that casts shadows? I assume one would need the proper shader, but I don’t know if billboards cast shadows at all.

  2. is it possible to create an “invisible” material that still casts a shadow?
    For a horror scene, I’d like to have some invisible creatures that still have shadows, so the player can spot them and react to their shadows, which gives him the additional challenge of having to guess at their positions giving the light sources in the room (some of them fly or float, so it’s not as simple as looking where the shadow ends).

Particle systems are not set up for light or shadows in Unity 2.6, although they are in Unity 3.

I think so. Try this shader, which has an effectively empty pass for normal rendering, but defers to VertexLit for shadow casting:

Shader "Shadows Only" {
	SubShader {
		ColorMask 0
		Cull Off
		Lighting Off
		ZWrite Off
		Pass {}
	}
	Fallback "VertexLit"
}
1 Like

That’s what I was looking for, thanks.

Unfortunately, it doesn’t seem to play nice with particles - this is a dog engulfed in shadows and flames (mesh itself invisible, with your shader) - unfortunately, where the mesh is, there are strange effects. It distorts on movement, like the old “hall of mirrors” effect that I haven’t really seen since Duke Nukem 3D. :slight_smile:

It also isn’t really invisble against the ground.

368272--12765--$shadows_872.jpg

I’m using Unity 3, but I can’t get shadows to work on particle systems, despite the checkboxes being there (and checked). Neither casting nor receiving shadows.

I tried it out, and it needs a dummy Shadow Collector pass. This should work:

Shader "Shadows Only" { 
	SubShader {
		Pass {
			Fog {Mode Off}
			ColorMask 0 
			Cull Off 
			Lighting Off 
			ZWrite Off 
		} 
			
		// Pass to render object as a shadow collector
		Pass {
			Name "ShadowCollector"
			Tags { "LightMode" = "ShadowCollector" }
			
			Fog {Mode Off}
			ZWrite On
			ZTest Less
			ColorMask 0 
		}
	}
	Fallback "VertexLit" 
}

As for particle shadows, there are definitely still some bugs. Make sure you’re using a shader that actually supports shadows (i.e. not one of the particle shaders), and you should at least get shadows cast from your system.

No luck yet, though it is getting more consistent - it is now black against other objects, and has the HOM effect against the skybox. :slight_smile:

It does, however, correctly cast shadows.

Couldn’t you simply add the dog to the camera’s culling list, but not to the light’s?

I tested that and it also culled the shadow.

But - it appears that the problem is with skyboxes, terrain or both. In a pure indoor scene, the shader works just fine. Strange.

Hi. Can someone add an alpha cutout to that shader? Please. :slight_smile: