Matte Shadow

Hi,
Is it possible to make a matte shadow effect, like 3DS Max’s “matte shadow” material.

I want to create realtime shadows on a background image/movie.

Regards
ern

I don’t use Max so I’m not sure what a “matte shadow” is, perhaps something like Unity’s “blob shadow”?

@bigkahuna,
thanks for your reply, I don’t think “blob shadows” apply to what im trying to do, which is this…

I have a background picture of a room(foto)and i want my furniture(the furniture can be moved around.) to cast realtime shadows on to the floor.

If it was a max rendering, I would make a 3D floor and apply a “matte shadow” material. And then the 3D floor will recive shadows and project them onto the background picture, the 3D floor element itself is invisible.

Or like in this movie, the ground plane has a matte material that allows it to be invisible, and yet receive shadows…this way it looks like the
background 2D movie receives shadows from the 3D elements:http://www.youtube.com/watch?v=P5IDEe2UQfM

Regards
ern

In Unity there are only three ways to make shadows (that I know of at least):

  1. Baked shadows and added to a lightmap shader (not move-able).

  2. Blob shadows (which I already discussed).

  3. Real-time light based shadows (Unity Pro only feature):
    Unity - Manual: Shadows

It is not as much the shadows, as it is the object the shadows hits.
that object must be invisible, and only show shadows in areas where shadows are applied in realtime.

so the question is Can such a shader be made???

ern

Hi, it may be a little too late, but I jsut see your post. I found what you search for to “emulate” the Matte Shadow effect of 3DS Max. It’s the DephtMask shader in the ShaderLab part of the wiki. You can follow these links:

http://www.unifycommunity.com/wiki/index.php?title=DepthMask
http://forum.unity3d.com/viewtopic.php?t=16305&highlight=depth+mask

I don’t know if the shadows are casted with this shader, since I’m using Indie version, but I think that would help many people like us who are familiar with the Matte Shadow effect :wink:

I didn’t get the idea how to use depth shader to emulate matte shadow effect, so I’m also interested in a way to do it :slight_smile:

I tried to make a Matte Shadow shader, as I can’t see how the depth mask (as someone proposed) is a solution to this.
It’s working as the one in 3ds max. It’s probably buggy in some situations. I didn’t get it to work witout making a horrible outline on other objects recieving shadows, when they are drawn against the matte shadow object.
If you remove “Recieve shadows” from the objects which will cast shadows on the Matte shadow plane, the ugly outline disappears. My knowledge of the actual workings of this stuff is still rather limitied.
The strength of the shadow is controlled by the darkness of the main color of the shader.

This works fine enough for many situations, I guess :slight_smile:

274334–9861–$matteshadow_159.shader (1.15 KB)

1 Like

Nice Kragh, was looking for this, thanks!

Nice shader Kragh! It would be great to have it working with Unity3. Anyone?

is this the thing you need? http://forum.unity3d.com/threads/64941-Shader-for-displaying-self-shadow-without-rendering-the-actual-object.?p=422023&viewfull=1#post422023

Thanks Kragh, work just as I had hoped; however, is there possibly a way to control the hard/softness of the shadows? I opened up the shader, but as an artist, I couldn’t make heads or tails of it. Either way it still rocks. Thanks again

Does this even work in U3? I’m sure it doesn’t :slight_smile:
I haven’t checked this thread for ages, thought it would never become active…
I could probably throw one together working a lot more reliable than this (and for U3), as my knowledge of the stuff has increased since. As for this shader, you would control the softness by changing the lights shadow type to soft. But if I remember correctly, it presented some crappy outlining effect of the shadow, so I don’t think is useful to you.

Actually, I’m currently using v2.6. Sorry I forgot to specify that in my previous post. I took your advice and disabled the “receive shadows,” which does eliminate the weird outline, but it also disables any and all casted shadows on the object itself (as I’m sure you are probably already aware). Anyways, at the moment I’m trying to find away around this, but have yet to succeed. At the moment I’m experimenting with the “cutout” transparency shader but it appears that when something is transparent it does not receive shadows.

Can you texture your floor to match the background in max?

Or you can feed screen position into the uv input of your texture to make a a texture that is locked to your camera view. Not sure how to handle the shading.

531629–18767–$bgshadow.shader (2.21 KB)

Hi, If you are willing, I’d like to ask if you could make a version that works in U3. Shaders in Unity really blow my mind :shock:

EDIT: Doesn’t work, really. Need to have another object below it, which receives shadows. Or it won’t work. Really buggy solution, don’t use it for now!! But I may get back to it, if I find the time…

The surface system REALLy hate me trying to do this, so this was the best I could come up with (without going deeper into the shadow caster functions directly). There’s a lot of stuff going on behind the scene in surface shaders.
If I do not set the alpha to 0 (or just don’t set it, as I did in this), it is not possible to do anything with the alpha part of the lighting function, at least not using the “atten” property, which contain shadow information. But if set to 0, the Albedo part will be ignored.

So, this works, somewhat. But the shadow can’t be tinted using the color property. Hope this will be enough for your needs, I can’t use more time on it at the moment.
Beware the mainTex is not used for anything. It’s only there because removing it from the input struct, gave problems. Can’t have no inputs!!! But what to input? So I just left it there… Somebody else can clean it up, if needed :slight_smile:

Here was a shader that didn't work yet, sorry

Ok, so this is just crappy. But I can’t leave you with that last post :wink: This works, if you live with its limits. This can’t be done without going deeper into how shadows work in the shadow caster functions, which are built in.
This will receive shadows, but it will double the shadow intensity, if the is an object below which also receives shadows. Very funny, have no idea what goes on :slight_smile: But go ahead, if it works for some purposes,

Shader "FX/Matte Shadow" {

Properties {

	_Color ("Main Color", Color) = (1,1,1,1)

	_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}

	_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5

}



SubShader {

	Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}

	LOD 200

	Blend Zero SrcColor

	

CGPROGRAM

#pragma surface surf ShadowOnly alphatest:_Cutoff





fixed4 _Color;



struct Input {

	float2 uv_MainTex;

};



inline fixed4 LightingShadowOnly (SurfaceOutput s, fixed3 lightDir, fixed atten)

{

	

	fixed4 c;

	

	c.rgb = s.Albedo*atten;

	c.a = s.Alpha;

	return c;

}





void surf (Input IN, inout SurfaceOutput o) {

	fixed4 c = _Color;

	o.Albedo = c.rgb;

	o.Alpha = 1;

}

ENDCG

}



Fallback "Transparent/Cutout/VertexLit"

}
2 Likes

Hi,

Thanks for doing this. However, I can’t get this to display correctly, It renders the shadow and everything else is the colour of the skybox. It seems to not take underlying objects into account. Any idea?

-Gungnir

Do you have a screen shot of it?