Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by Glacier Games · Mar 26, 2013 at 05:53 PM · shadowprojector

Projector is showing through other objects

Hey guys, so I've been working on my main character and he's got a hood. So I thought, "Hey, wouldn't it be cool if the hood put a shadow over his face?!". I immediately thought of the Projector and made a pretty good looking shadow on his face:

alt text

The projector is ignoring the hood so it just shows up on the face.. but, there is a problem: the shadow kinda bleeds/shows through the hood. Here's what I mean:

alt text

I've tried so many different things, but nothing's preventing the shadow from 'bleeding' through! Any ideas?

capture3.jpg (116.7 kB)
capture5.jpg (12.9 kB)
Comment
Add comment
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

5 Replies

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

Answer by Glacier Games · Mar 26, 2013 at 07:01 PM

Haha, solved it. Weird solution, but I found a projector shader that doesn't do it.

 Shader "Cg projector shader for drop shadows" {
    Properties {
       _ShadowTex ("Projected Image", 2D) = "white" {}
    }
    SubShader {
       Pass {      
           Blend Zero OneMinusSrcAlpha // attenuate color in framebuffer 
             // by 1 minus alpha of _ShadowTex 
          CGPROGRAM
  
          #pragma vertex vert  
          #pragma fragment frag 
  
          // User-specified properties
          uniform sampler2D _ShadowTex; 
  
          // Projector-specific uniforms
          uniform float4x4 _Projector; // transformation matrix 
             // from object space to projector space 
  
           struct vertexInput {
             float4 vertex : POSITION;
             float3 normal : NORMAL;
          };
          struct vertexOutput {
             float4 pos : SV_POSITION;
             float4 posProj : TEXCOORD0;
                // position in projector space
          };
  
          vertexOutput vert(vertexInput input) 
          {
             vertexOutput output;
  
             output.posProj = mul(_Projector, input.vertex);
             output.pos = mul(UNITY_MATRIX_MVP, input.vertex);
             return output;
          }
  
  
          float4 frag(vertexOutput input) : COLOR
          {
             if (input.posProj.w > 0.0) // in front of projector?
             {
                return tex2D(_ShadowTex , 
                   float2(input.posProj) / input.posProj.w); 
                // alternatively: return = tex2Dproj(  
                //    _ShadowTex, float3(input.posProj));
             }
             else // behind projector
             {
                return float4(0.0);
             }
          }
  
          ENDCG
       }
    }  
    // The definition of a fallback shader should be commented out 
    // during development:
    // Fallback "Projector/Light"
 }
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 Glacier Games · Mar 26, 2013 at 07:01 PM 0
Share

btw, I had to invert the projected image

avatar image
0

Answer by Quaker_SDR · Dec 22, 2014 at 06:36 AM

Hi,

I have this problem, Can you you help me out ??

I tried using your shader, But it giving a transparent image as output.

Projector Image


capture.jpg (59.1 kB)
Comment
Add comment · 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
0

Answer by mubashar437 · Dec 22, 2014 at 07:45 AM

to quaker-sdr

http://docs.unity3d.com/Manual/class-Projector.html

maybe second hint will help..........

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 Quaker_SDR · Dec 22, 2014 at 08:42 AM 0
Share

its not giving proper solution to

avatar image
0

Answer by HonoraryBob · Feb 26, 2017 at 01:29 AM

@Glacier Games : I also couldn't get this to work - it goes through objects and reverses the pattern. I'm using Unity 5.0.1

Comment
Add comment · 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
0

Answer by diabuli · Mar 30, 2018 at 09:08 AM

Amazing!!, can you send me the projector prefab with the shader,

Comment
Add comment · 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

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

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

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

How to make a blob shadow project from a fixed angle as the object rotates? 2 Answers

Blob Shadows - Reversing Shadow Effect? 2 Answers

how to prevent stretched vertical shadow in blob shadow which projected by Projector of Unity 0 Answers

How to use a shadow projector 1 Answer


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