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 smokris · May 23, 2012 at 01:25 AM · shaderterrainalphahlsl

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

I'm working on a set of custom shaders to override Unity's built-in terrain shaders.

When I add the "alpha" parameter:

 #pragma surface surf Lambert alpha

...suddenly distant terrain trees start drawing on top of nearby terrain hills — it looks as though the terrain shader is no longer writing to the Z-Buffer.

I have ZWrite On set for my terrain Lightmap-FirstPass shader, and ZTest Less set for my BillboardTree shader.

Any ideas about how I can fix this?

alt text

Screen shot 2012-05-22 at 9.19.18 PM.png (340.2 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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Owen-Reynolds · May 23, 2012 at 03:13 AM

I believe it's a problem specific to Terrain, and can't really be solved.

Transparent objects need to be drawn back to front(?) after everything else. But, Terrain is drawn by a special routine -- the ground is cut up on the fly into squares, each subdivided based on LOD, then drawn probably outward from the player (for efficiency.) It's probably also run 1st, also for efficiency (these are just guesses.)

I tried a transparent shader with only Terrain, maxed out the "use low-res overmap" setting, and got the same occasional completely transparent hill. Transparent terrain didn't even draw correctly with itself, never mind trees.

Comment
Add comment · Show 2 · 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 smokris · May 23, 2012 at 03:24 AM 0
Share

Interesting. Thanks, Owen. I would have assumed that, even if the terrain is being drawn by a special segmented geometry renderer, it would still obey shader parameters as usual — but it looks like some internal magic is going on here.

avatar image Owen-Reynolds · May 23, 2012 at 01:22 PM 0
Share

I imagine the chunks could be created and then sent for general rendering. But, for example, each chunk of the same LOD has the same Triangle array. So, the terrain renderer can save time by only sending that once.

avatar image
0

Answer by ScroodgeM · Jul 14, 2012 at 12:16 PM

as you use own shader you just need terrain be rendered before trees and writes it's depth to z-buffer, then on tree-drawings stage z-buffer will hide far trees. just try to decrease queue (in shader parameters) value for terrain shader, to be lower then for tree shader

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Splat Map with transition texture? 0 Answers

Unlit Alpha Shader not working with Simple Water 0 Answers

Transparent terrain shader not working 2 Answers

Shader for ZTest Between Terrain and Objects 0 Answers

Forward Rendering for Terrain, overriding the shader? 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