Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 joeyong · Apr 25, 2018 at 12:36 PM · androidshadersaugmented-realitypost processing

Ideas on Transparent shader that can receive shadows and is not ignored by Post processing stack?

Hey Everyone,

So I am currently working on an AR app for android using ARcore. For the trackable floor I am using a transparency shader that allows for shadows to rendered on top of it. I wanted to add in some very subtle ambient occlusion for a more natural look at the base of objects in an AR environment.

My problem is that I can't get the SSAO from the post processing stack to render onto the transparent shader. Does anyone have any experience with this in AR? Or any suggestions on how this might be achieved?

Thanks in advance

Comment
Add comment · Show 3
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 Harinezumi · Apr 25, 2018 at 01:12 PM 0
Share

Could you share more about the transparency shader with shadow, preferably the code?
You could also check this answer that might be related (the rest of the results a search gives are VERY old).

avatar image joeyong Harinezumi · Apr 25, 2018 at 01:39 PM 0
Share

Hey thanks for the reply,

Yes of course, the current shader I'm using is pasted below. In all fairness, I could settle for a transparent shader without shadows as long as it is included in the post process pipeline to receive the SSAO onto the transparent surface.

I did also check out that post previously, although it didn't result in much luck

Shader "Custom/ShadowCollector" { Properties { _ShadowIntensity ("Shadow Intensity", Range (0, 1)) = 0.6 }

 SubShader
 {
 
     Tags {"Queue"="AlphaTest" }
 
     Pass
     {
         Tags {"Light$$anonymous$$ode" = "ForwardBase" }
         Cull Back
         Blend SrcAlpha One$$anonymous$$inusSrcAlpha
         CGPROGRA$$anonymous$$
         #pragma vertex vert
         #pragma fragment frag
         #pragma multi_compile_fwdbase
 
         #include "UnityCG.cginc"
         #include "AutoLight.cginc"
         uniform float _ShadowIntensity;
 
         struct v2f
         {
             float4 pos : SV_POSITION;
             LIGHTING_COORDS(0,1)
         };
         v2f vert(appdata_base v)
         {
             v2f o;
             o.pos = UnityObjectToClipPos (v.vertex);
             TRANSFER_VERTEX_TO_FRAG$$anonymous$$ENT(o);
            
             return o;
         }
         fixed4 frag(v2f i) : COLOR
         {
             float attenuation = LIGHT_ATTENUATION(i);
             return fixed4(0,0,0,(1-attenuation)*_ShadowIntensity);
         }
         ENDCG
     }
 
 }
 Fallback "VertexLit"

}

avatar image Harinezumi joeyong · Apr 25, 2018 at 01:54 PM 0
Share

I'm not very good with shaders, but if the problem is that transparency doesn't write into the zbuffer, then maybe adding ZWrite Onand/or ZTest LEqual could help.
Alternatively, check out how the standard vertex color shader adds shadows:

     // ------------------------------------------------------------------
     //  Shadow rendering pass
     Pass {
         Name "ShadowCaster"
         Tags { "Light$$anonymous$$ode" = "ShadowCaster" }

         ZWrite On ZTest LEqual

         CGPROGRA$$anonymous$$
         #pragma target 2.0

         #pragma shader_feature _VERTEXCOLOR
         #pragma shader_feature _VERTEXCOLOR_LERP
         #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPRE$$anonymous$$ULTIPLY_ON
         #pragma shader_feature _$$anonymous$$ETALLICGLOSS$$anonymous$$AP
         #pragma skip_variants SHADOWS_SOFT
         #pragma multi_compile_shadowcaster

         #pragma vertex vertShadowCaster_VC
         #pragma fragment fragShadowCaster_VC

         #include "UnityStandardShadow.cginc"
         #include "UnityVCShadow.cginc"

         ENDCG
     }


Complete shader file, in txt.

standardvertexcolorshader.txt (12.7 kB)

0 Replies

· Add your reply
  • Sort: 

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

186 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 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 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 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 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 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 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 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 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 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 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

Custom postprocess white in build 0 Answers

apply Transformation on augmented model ,apply transformation on individual target image 0 Answers

Heating Problem with Unity-Android App even in low FPS??!! 1 Answer

Extracting Dataset (AR) from OBB (Expansion Files) 1 Answer

[Post Processing] Depth of Field issue on Android & WebGL 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