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 pointcube · Apr 19, 2013 at 04:36 PM · shadershadowalphablur

Blur the alpha part of a shader

First I explain what I want to achieve. My goal is to get a soft shadow alternative running on iOS (because unity soft shadows does not work on this plateform). I made a "transparentShadow" shader that is fully transparent but receive the shadow. Here is what I get with my shader and hard shadow :

alt text Here is my code :

 Shader "Custom/Transparent-Shadows-blur"
 {
     Properties
     { 
         // Shadow Stuff
         _ShadowIntensity ("Shadow Intensity", Range (0, 1)) = 0.6
         _ShadowBlur ("Shadow Blur",  Range (0, 0.01)) = 0.006  
     }
  
     SubShader
     {
         Tags {
             "Queue"="AlphaTest" 
             "IgnoreProjector"="True" 
             "RenderType"="Transparent"
         }
 
         LOD 300
     
         // Shadow Pass : Adding the shadows (from Directional Light)
         // by blending the light attenuation
         Pass {
             Blend SrcAlpha OneMinusSrcAlpha 
             Name "ShadowPass"
             Tags {"LightMode" = "ForwardBase"}
               
 CGPROGRAM 
         // Upgrade NOTE: excluded shader from DX11 and Xbox360; has structs without semantics (struct v2f members lightDir)
         #pragma exclude_renderers d3d11 xbox360
         #pragma vertex vert
         #pragma fragment frag
         #pragma multi_compile_fwdbase
         #include "UnityCG.cginc"
         #include "AutoLight.cginc"
      
         struct v2f { 
             float2 uv_MainTex : TEXCOORD0;
             float4 pos : SV_POSITION;
             LIGHTING_COORDS(3,4)
             float3    lightDir;
         };
      
         float4 _MainTex_ST;
         sampler2D _MainTex;
         float _ShadowIntensity;
         float _ShadowBlur;        
      
          v2f vert (appdata_full v){
              v2f o;
             o.uv_MainTex = TRANSFORM_TEX(v.texcoord, _MainTex);
             o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
             o.lightDir = ObjSpaceLightDir( v.vertex );
             TRANSFER_VERTEX_TO_FRAGMENT(o);        
             return o;
         }
     
         float4 frag (v2f i) : COLOR
         {    
             float atten = LIGHT_ATTENUATION(i);
             half4 c;
             c.rgb =  0;                
             c.a = (1-atten) * _ShadowIntensity;
             
             return c;
         }
 ENDCG
       }
   }
   Fallback "VertexLit"
 }

I would like to blur the result of this shader to simulate soft shadows, in order to have this kind of result :

alt text

I have read a lot about blur techniques shader. But it only blur the texture (like this link text).

But I don't achieve to blur the alpha part.

Any idea please?

transparentshadow.jpg (28.6 kB)
transparentshadowblur.jpg (29.0 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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by pointcube · Apr 23, 2013 at 09:34 AM

Any one can help me please ?

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

13 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

Related Questions

Shader with zwrite, shadows and alpha (special alpha) 2 Answers

Shadows with Alpha, fade out shadow. 2 Answers

Is it possible to create a blur effect based on the alpha of a transparent texture on a plane? 0 Answers

Fade-In/Out shadows for a specific object 0 Answers

Semi-transparent shader with Shadows 3 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