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
2
Question by AR_Rizvi · Aug 24, 2013 at 09:43 AM · shadertransparencybillboards

Can i make this shader an alpha cutout

hi guys i was wondering that can i make this shader's _MainTex to a alpha cutout and if yes then how can i do it plz guide me on this i am realy new to shader writing so i cant figure out how to do it i ws trying to merge transparent cutout shader and the shader given below but it result in desater plz help code given below

 Shader "Cg  shader for billboards" {
    Properties {
       _MainTex ("Texture Image", 2D) = "white" {}
    }
    SubShader {
       Pass {   
          CGPROGRAM
  
          #pragma vertex vert  
          #pragma fragment frag 
  
          // User-specified uniforms            
          uniform sampler2D _MainTex;        
  
          struct vertexInput {
             float4 vertex : POSITION;
             float4 tex : TEXCOORD0;
          };
          struct vertexOutput {
             float4 pos : SV_POSITION;
             float4 tex : TEXCOORD0;
          };
  
          vertexOutput vert(vertexInput input) 
          {
             vertexOutput output;
  
             output.pos = mul(UNITY_MATRIX_P, 
               mul(UNITY_MATRIX_MV, float4(0.0, 0.0, 0.0, 1.0))
               - float4(input.vertex.x, input.vertex.z, 0.0, 0.0));
  
             output.tex = input.tex;
  
             return output;
          }
  
          float4 frag(vertexOutput input) : COLOR
          {
             return tex2D(_MainTex, float2(input.tex.xy));   
          }
  
          ENDCG
       }
    }
 }

any help wud b much appreciated.. thanks

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 $$anonymous$$ · Aug 24, 2013 at 11:35 AM 0
Share

I would suggest to post this question in shaderlab(Forum). http://forum.unity3d.com/forums/16-ShaderLab

1 Reply

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

Answer by whydoidoit · Aug 24, 2013 at 11:50 AM

Try something like this:

 Shader "Cg  shader for billboards" {
    Properties {
       _MainTex ("Texture Image", 2D) = "white" {}
       _CutOff("Cut off", float) = 0.1
    }
    SubShader {
       Pass {   
          CGPROGRAM
  
          #pragma vertex vert  
          #pragma fragment frag 
  
          // User-specified uniforms            
          uniform sampler2D _MainTex;        
          uniform float _CutOff;
  
          struct vertexInput {
             float4 vertex : POSITION;
             float4 tex : TEXCOORD0;
          };
          struct vertexOutput {
             float4 pos : SV_POSITION;
             float4 tex : TEXCOORD0;
          };
  
          vertexOutput vert(vertexInput input) 
          {
             vertexOutput output;
  
             output.pos = mul(UNITY_MATRIX_P, 
               mul(UNITY_MATRIX_MV, float4(0.0, 0.0, 0.0, 1.0))
               - float4(input.vertex.x, input.vertex.z, 0.0, 0.0));
  
             output.tex = input.tex;
  
             return output;
          }
  
          float4 frag(vertexOutput input) : COLOR
          {
             
             float4 color = tex2D(_MainTex, float2(input.tex.xy));   
             if(color.a < _CutOff) discard;
             return color;
          }
  
          ENDCG
       }
    }
 }
Comment
Add comment · Show 4 · 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 AR_Rizvi · Aug 24, 2013 at 11:56 AM 0
Share

Thank you sooo much its working perfectly i asked for help that how can i do it but u came up with a a complet solution thanks once again cheers AR

avatar image AR_Rizvi · Aug 24, 2013 at 12:18 PM 0
Share

But i have a slight problem with this shader coz in playmode my trees r dissapers i dnt knw may b its because it is billboarding/showing me the worng side of the planer can u plz help me with this to

i have checked this by adding $$anonymous$$us to the
input.vertex.x input.vertex.z but no luck so far

many thanks

avatar image whydoidoit · Aug 24, 2013 at 01:03 PM 0
Share

Try sticking a:

  Cull Off

In the pass - that'll tell us if it's only one sided.

avatar image AR_Rizvi · Aug 24, 2013 at 01:56 PM 0
Share

it is working when i set the transform of my trees in 3ds max its working nicely thanks alot

and what if i wanted to add shadows in it

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

17 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 avatar image avatar image avatar image

Related Questions

Is there a way to have a transparent vertex shader recieve and cast Shadows? 0 Answers

transparent object: everything behind it appears in grayscale 0 Answers

Standard shader transparency 0 Answers

Adding Transparency to Custom Unity Shader 1 Answer

Transparency with different colors? 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