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
1
Question by gpz22 · Jun 23, 2014 at 11:09 AM · shaderscaletransparencyshield

Transparent shader with depth writes

Hi guys,

I spent the afternoon trying to find out how to make a shader that do a similar thing than this:

https://www.youtube.com/watch?v=CK5emREuwrQ#t=17

alt text

I added a second pass to the bumped specular, another surface shader with vertex shader (that scale the model up). So I have this model upscaled with alpha but it is semi-transparent and some surfaces overlay as the left figure in:

alt text

I tried to use an extra path to calculate the depth but nothing help I have always some overdrawing artifacts and I would like to have a uniform solid color or a gradient at best, like the right figure but impossible.

Any ideas how I could avoid two surfaces to overlap and display nicely like in oxide demo?

Thanks guys.

oxide.jpg (159.4 kB)
Comment
Add comment · Show 1
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 gpz22 · Jun 24, 2014 at 02:17 AM 0
Share

By the way,

Here is what I have with a second pass using a surface shader and the code.

alt text

 Tags { "RenderType"="Transparent" "Queue"="Transparent" }
 LOD 300
 Cull Back
 
 CGPROGRA$$anonymous$$
 #pragma surface surf BlinnPhong vertex:vert alpha
 
 fixed4 _Color;
 fixed4 _ShieldColor;
 half _Scale;
 half _Offset;
 half _Shininess;
 sampler2D _Bump$$anonymous$$ap;
 sampler2D _$$anonymous$$ainTex;
 
 struct Input 
 {
     float2 uv_$$anonymous$$ainTex;
     float2 uv_Bump$$anonymous$$ap;
 };
 
 void vert(inout appdata_full v) 
 {
     v.vertex = mul(float4x4(
         _Scale, 0, 0, 0,
         0, _Scale, 0, 0,
         0, 0, _Scale, 0,
         0, 0, 0, 1 ), v.vertex);
 }
 
 void surf (Input IN, inout SurfaceOutput o) 
 {
     o.Albedo = _ShieldColor.rgb;
     o.Emission = _ShieldColor.rgb * _ShieldColor.a;
     o.Alpha = _ShieldColor.a;
 }    
 ENDCG


Here is what I have with a second pass using a frag shader.

alt text

 Pass 
 {
 Blend SrcAlpha One$$anonymous$$inusSrcAlpha
     
 CGPROGRA$$anonymous$$
 #pragma vertex vert
 #pragma fragment frag
 
 #include "UnityCG.cginc"
 
 struct v2f 
 {
     float4 vertex : SV_POSITION;
 };
 
 half _Scale;            
 fixed4 _ShieldColor;            
 sampler2D _$$anonymous$$ainTex;
 float4 _$$anonymous$$ainTex_ST;
 
 v2f vert (appdata_base v)
 {
     v2f o;
     float4x4 matrix = float4x4(
         _Scale, 0, 0, 0,
         0, _Scale, 0, 0,
         0, 0, _Scale, 0,
         0, 0, 0, 1 );
 
     o.vertex = mul(UNITY_$$anonymous$$ATRIX_$$anonymous$$VP, mul(matrix, v.vertex));
     return o;
 }
 
 fixed4 frag (v2f i) : SV_Target
 {
     return _ShieldColor;
 }
 ENDCG
 }

preview_surface.png (40.3 kB)
preview_frag.png (18.8 kB)

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by gpz22 · Jun 24, 2014 at 04:32 AM

Found a solution thanks to this thread:

http://answers.unity3d.com/questions/290333/transparent-solid-color-shader.html

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 gpz22 · Jun 24, 2014 at 06:36 AM 0
Share

And for the gradient like appearance:

http://answers.unity3d.com/questions/229829/shader-based-on-surface-distance-from-center-.html

avatar image
0

Answer by Pawl · May 04, 2016 at 01:03 AM

I posted an answer to this question (with a comprehensive shader) here.

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 Brother_77 · Aug 25, 2021 at 09:35 AM

https://forum.unity.com/threads/question-about-transparency-and-rear-faces.774224/

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Transparency artifacts android 0 Answers

Shield shader no longer working 1 Answer

Seamless Water Material on a Plane using Shader Graph 3 Answers

Does the Particle Animator work with transparent shaders? 1 Answer

Strange effects of two transparent objects on each other. 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