Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
5
Question by Jean-Fabre · Jan 12, 2011 at 11:10 AM · shadershadowtransparentprojectormatte

how to make a shader that only shows the shadow while the rest becomes completly transparent?

Hi Everyone,

I would like to build a material that only catch shadows, for 3dsmax users this refers to the matte/shadow material.

Basically, the material is plain transparent and simply catch shadows. It might be already feasible, but I lack of experience with writing shaders...

Also, if that could work with projectors, that would be great :)

Thanks for your help,

Jean

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Novodantis 1 · Jan 12, 2011 at 11:50 AM 0
Share

Extra brownie points to you for revealing finally how to do something in $$anonymous$$ax that I've often needed, always thought possible, but never figured out how to do. I only wish I could answer this in return, but I don't know enough about shaders to be much help.

avatar image Jean-Fabre · Jan 12, 2011 at 01:40 PM 0
Share

:) I am sure it is possible, but requires I think some real shader scripting knowledge.

avatar image Jean-Fabre · Feb 17, 2011 at 01:15 PM 0
Share

Ok, Started a bounty, I am sure this one is a no brainer for some shader guru, just needs that extra rewards I guess :) thanks in advance!

avatar image runonthespot · Feb 21, 2011 at 03:31 PM 0
Share

Could you confirm what sort of shadows you want it to catch? I have a solution for this that works with shadows created with a projector.

4 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by Peter G · Feb 21, 2011 at 04:02 PM

I think this is what you want?

http://forum.unity3d.com/threads/14438-Matte-Shadow?highlight=matte+shadow

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jean-Fabre · Feb 24, 2011 at 08:47 AM 0
Share

haven't found yet a shader that works in these threads. $$anonymous$$atteShadowCust$$anonymous$$odel just show or cut everything, and $$anonymous$$atteShadowCust$$anonymous$$odel2 just don't show any shadow anymore. the matte shadow one seemed working, but for unity 2.x only. matShadow doesn't work neither. sigh...

avatar image $$anonymous$$ · Jul 24, 2015 at 05:23 AM 0
Share

hi...None of the shaders in this thread worked for me. Did u get a solution? if yes, your help would be much appreciated

avatar image
-1

Answer by taoa · Feb 21, 2011 at 09:27 AM

After (properly this time) reading your answer, I can tell you this:

What is a shadow in Unity? It's an area on an object where light don't shine because it's hidden from it by another object (that's true in real life as well actually).

In other words: a shadow, on a rendered 3D object, is a bunch of pixels where the influence (lighting calculation) of a light is removed, leaving only the ambient lighting (that colour you set in Render Settings).

OK.

Wait. What does that mean for an object that is invisible? There's no light calculation in the first place! Hey, there's not even any ambient lighting at all! How could an invisible object possibly receive and display any kind of shadow at all?

Impossible. Apparently.

It's technically possible though, as one would only have to consider 'OK so, this object's shader doesn't render anything, but where shadows would be if it was visible, I'm gonna use it's base colour/texture and multiply that with the ambient lighting colour and it's gonna be the shadow. I'll also add a transparency factor 'cause it'll be fun to play with that.'

That's how one would do it... if it was possible. Unfortunately shadows calculations are done behind-the-scenes in Unity and an End-User like you or me can't access these in order to play a bit with them.

So, I'd say this is impossible. I'd like to be wrong though.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jean-Fabre · Feb 21, 2011 at 12:15 PM 0
Share

hi, thanks for the explanations. $$anonymous$$atte composition is a very important feature of 3d rendering. I remain persuaded ( also feel the same about how theoritically it would work) that it is possible, hopefully someone from Unity or from "planet shader guru" will read this post and know the answer, I will open a forum question as well, cause it seems to be moving into a discussion more than a question/answer type of thing.

avatar image
0

Answer by genedegsg · Jul 12, 2017 at 04:41 PM

I know this is a necro thread and people may well flame me for replying, but I was never able to find an answer to this question anywhere else in the forum. My guess is that I'm not alone. So I wanted to link to an article that gives the full listing for a shader that will do exactly this. It also supports bump, specular, and gloss maps, opacity maps and thresholds for hair, or any other purposes that require tapering toward transparency: http://www.dawnofthefel.com/blogs/game-coding/its-all-hollywoods-fault . To make something fully transparent but still cast shadows, just set _Color's Alpha channel value to 0.

A good portion of the reason I wanted to post this is because one of the prior answers was fairly snarky in its assertion that this couldn't be done. It was also incorrect. (FWIW, being snarky when someone asks an honest question never seems warranted to me.)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JohnnyFactor · Jan 20, 2021 at 02:49 AM 0
Share

I don't $$anonymous$$d necros (obviously) but that wasn't the question. OP was looking for a shader that is visible only where it receives shadow-- not a transparent object that casts shadows. That functionality is already built in to Unity.

So, still looking for a solution.

avatar image
0

Answer by MahrCheen · Mar 29, 2018 at 08:24 AM

This thing works in the viewport for me- it lacks something like clearing in game mode. I don't know how to fix it.

     Shader "UnlitShadows/ShadowCatcher" {
     Properties{ _Color("Main Color", Color) = (1,1,1,1) _MainTex("Base (RGB)", 2D) = "white" {}    _Cutoff("Cutout", Range(0,1)) = 0.5 }
     SubShader{ Pass{ Alphatest Greater[_Cutoff] SetTexture[_MainTex] }    Pass{ Blend DstColor Zero Tags{ "LightMode" = "ForwardBase" }
     CGPROGRAM
     #pragma vertex vert
     #pragma fragment frag
     #include "UnityCG.cginc"
     #pragma multi_compile_fwdbase
     #include "AutoLight.cginc"
     struct v2f {
     float4 pos : SV_POSITION; LIGHTING_COORDS(0,1) };
     v2f vert(appdata_base v) {
     v2f o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); TRANSFER_VERTEX_TO_FRAGMENT(o);
     return o; }
     fixed4 frag(v2f i) : COLOR{
     float attenuation = LIGHT_ATTENUATION(i);
     return attenuation;
     } ENDCG } } Fallback "Transparent/Cutout/VertexLit" } 
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Shulman · Jul 18, 2018 at 07:25 PM 0
Share

Hi. Did you find solution to this issue?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Transparent objects and shadow 0 Answers

Shadows with Transparent Standard Shader? 2 Answers

Semitransparent object that cast shadow 0 Answers

blob shadow z-fighting on iphone 3 Answers

Need help with projector shader 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges