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
1
Question by irrationalistic · Jul 17, 2012 at 05:42 PM · shadershadowstransparency

Transparency Shader that Allows Shadows

I'm trying to "hide" walls behind the player by setting their transparency down a bit. I don't want them to cast or receive shadows any differently than if they were opaque, just make them slightly transparent so the player is never hidden. Seems like most of what I'm finding is for people who want to allow transparent objects to cast shadows based on transparency, so I'm hoping there is a multi-pass system that might allow shadows to ignore the alpha channel of the object, but still make the object alpha-y? Could I maybe just modify the diffuse channel's alpha?

In a related note, I've found reference to the Visibility Bubble system implemented in a few games, but very little in regards to how to implement it. Any thoughts?

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

1 Reply

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

Answer by ScroodgeM · Jul 17, 2012 at 06:45 PM

try this one

Shader "Transparent/Diffuse with Shadow" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} }

SubShader { Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } LOD 200 Blend SrcAlpha OneMinusSrcAlpha CGPROGRAM #pragma surface surf Lambert addshadow

 sampler2D _MainTex;
 fixed4 _Color;
 
 struct Input {
     float2 uv_MainTex;
 };
 
 void surf (Input IN, inout SurfaceOutput o) {
     fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
     o.Albedo = c.rgb;
     o.Alpha = c.a;
 }
 ENDCG

}

Fallback "Transparent/VertexLit" }

Comment
Add comment · Show 6 · 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 irrationalistic · Jul 17, 2012 at 07:03 PM 0
Share

This is really close! The only issue is with objects in this pass ignoring shadows from other objects in the pass. If there is any fix, that would be awesome. Otherwise I might be able to make this work by having only the objects that need to be transparent having this shader and then toggling back to the default diffuse geometry shader.

avatar image ScroodgeM · Jul 17, 2012 at 07:31 PM 0
Share

this shader is more expensive then diffuse shader (cause no zbuffer writes and it is everything below this geometry renders even if it is hided totally). so you shouldn't use it for all walls - just for ones that have at least some transparency

avatar image ScroodgeM · Jul 17, 2012 at 07:41 PM 0
Share

PS a shadow-receiving for transparency objects is not so easy due to shadow rendering mechanism

avatar image irrationalistic · Jul 17, 2012 at 09:34 PM 0
Share

Gotcha. That should be fine. I'll just toggle the shader on for objects I need it. It's only for objects blocking the view of the player, so they'll be out of focal point anyways. Thanks so much!

avatar image bateleur · Sep 07, 2012 at 12:27 PM 0
Share

Thanks for that shader - works perfectly. :-)

Show more comments

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

8 People are following this question.

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

Related Questions

Plugging in screenPosition node`s A channel gives different result then plugging in an identical float value in shader graph. 1 Answer

Unity 4.6 and Grabpass fails 1 Answer

No shadows when looking through a cutout shader 2 Answers

Receiving Shadows On a Tranparent Shader 1 Answer

Is there a way to have a transparent vertex shader recieve and cast Shadows? 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