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 blitzen · Oct 29, 2011 at 06:04 AM · meshrenderoffzwrite

How to Render a Mesh Always, Ignoring Z-Distance

I'm trying to figure out how to always render a mesh's triangles fully, even if it's partially or completely behind another mesh. Thus, even as it moves further away behind other objects you'd only see it get smaller but still be drawn "in front of" them, with no occlusion culling or Z distance taken into consideration.

Applications might be, for example, to elminate z-fighting of meshes that line the contours of the terrain, or for a line renderer that's right on the surface of a mesh which becomes half-buried depending on the camera angle. You just want things like this to be drawn fully and not chopped off by any meshes they happen to intersect with.

Is this something that can only be done with a shader? I tried setting "ZWrite off" and "ZTest Always", but triangles still get chopped off by intersecting meshes regardless, thus I'm not sure what those commands actually accomplish. Tried also setting "Queue" to "Overlay" to no avail.

Comment
Add comment · Show 4
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 ina · Oct 29, 2011 at 06:21 AM 0
Share

camera culling?

avatar image CHPedersen · Oct 29, 2011 at 07:19 AM 2
Share

Try taking a look at the source code for the default 3DText shader. You can download a zip with source for all the built in shaders here:

http://forum.unity3d.com/threads/2085-Builtin-Unity-shaders-source

That shader was made to ignore depths so the 3DText always renders on top of things. $$anonymous$$aybe you can copy whatever it's doing do make a custom shader do the same for your mesh.

avatar image blitzen · Oct 29, 2011 at 02:26 PM 0
Share

Good call, Christian. For future reference, the Text Shader just draws in the regular "transparent" queue and sets:

Lighting Off Cull Off ZTest Always ZWrite Off Fog { $$anonymous$$ode Off }

These are all things I had already tried, and I'm not sure why they didn't work then, but for some reason after I copied them over to my shader the "ZTest Always" setting now does the trick.

avatar image ShawnFeatherly · Sep 28, 2015 at 02:53 AM 0
Share

I got $$anonymous$$e working by copying UI-Default.shader from the built-in shaders. Setting ZTest Off and _$$anonymous$$ainTex ("Base (RGB), Alpha (A)", 2D) = "white" {}

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Kiwasi · Sep 28, 2015 at 03:57 AM

I would tackle this with two cameras. Put your unhiddable object on a layer only rendered by the second camera. Then set the second camera up to render everything on top of the first camera.

This is the general technique used for things like guns and UI that must always be on top.

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

How do you add something to your pass? 1 Answer

Questions about render distance in an open world game 0 Answers

Hardware skinning support in unity? 1 Answer

Prevent inner edges from being at front 0 Answers

Combining Objects for Performance 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