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 Steven-1 · Jun 16, 2015 at 08:52 AM · shaderterraindepth-buffer

problem with custom terrain shader (added holes-functionality, problem with some post effects)

I wanted holes in my terrain, so I modified the terrain shader (firstpass shader) to allow this, I simply made 1 of the splats be used for clipping. Then I added a ShadowCaster subshader so it would render shadows correctly (I do the same clipping there).

It all seemed to work, until I used screen space ambient occlusion or obscurance, these effects behave as if the terrain is still completely opaque (no holes).

So it seems to me as if the depthbuffer or normalbuffer is somehow incorrect, which I find strange as everything (apart from these post effects) is all still correctly rendered.

I'm using deferred in Unity5

any ideas?

 //added this in the surface shader
 clip (0.2-splat_control.a);
 
 //added this at the end to get correct shadows:
 SubShader
     {
         // Pass to render object as a shadow caster
         Pass
         {
             Name "ShadowCaster"
             Tags { "LightMode" = "ShadowCaster" }
         
             Fog {Mode Off}
             ZWrite On ZTest LEqual //Cull Off
             //Offset 1, 1
 
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             #pragma multi_compile_shadowcaster
             #include "UnityCG.cginc"
 
             struct v2f
             {
                 V2F_SHADOW_CASTER;
                 float2 tc_Control : TEXCOORD4;
             };
             
 sampler2D _Control;
 float4 _Control_ST;
 
             v2f vert( appdata_base v )
             {
                 v2f o;
                 o.tc_Control = TRANSFORM_TEX(v.texcoord, _Control);    // Need to manually transform uv here, as we choose not to use 'uv' prefix for this texcoord.
                 TRANSFER_SHADOW_CASTER(o)
                 return o;
             }
 
             float4 frag( v2f i ) : COLOR
             {
                 half4 splat_control = tex2D(_Control, i.tc_Control);
                 clip (0.2-splat_control.a);
                 //clip (-1);
                 SHADOW_CASTER_FRAGMENT(i)
             }
             ENDCG
         }
     }
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 killsteal_interactive · Oct 18, 2015 at 09:21 AM 0
Share

Same problem for me... Did you found a way to fix that?

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

22 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

Related Questions

Does anyone know how to implement these depth-mask shaders? 1 Answer

Shader for ZTest Between Terrain and Objects 0 Answers

Forward Rendering for Terrain, overriding the shader? 0 Answers

Shader with "alpha" parameter no longer writes to Z-Buffer 2 Answers

Terrain shader optimisation 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