Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 lyonb · Mar 23, 2017 at 08:14 AM · spriteoffset2.5dbillboarddepth-buffer

Correct for 2.5D sprite clipping with shader depth offset?

I've got 2D sprites in a 3D game that are set to always face the camera. The problem is, as the camera is angled, the top of the sprite can pass through walls. To correct for this, I've set the sprite's shader Offset property to something like -1000 for the units variable which helps, but a portion of the head of the sprite still passes through walls. Anything further than that (ie -2000), and I reach a point of diminishing returns as the bottom half of the sprite starts to render above foreground objects while the head does not go through walls.

So to clarify, the offset is

Offset 0, -1000

I've tried messing around with the first variable (offset factor), but it doesn't seem to yield any results as best as I can tell, so I don't think I quite understand what it does.

alt text

You can see the bottom half of the sprite rendering above foreground elements in this image with the units set to -2000

alt text

And here it is with the head being cropped with the units set to -1000.

Is there a way to like angle the offset of the depth order? Is this something I'd have to get into writing into a vertex shader? Currently I'm just using the unity Sprite Diffuse shader with the offset line added (which is a simple lambertian subsurf shader, so that... complicates things), and the camera facing is done through a C# script, not through the shader.

screen-shot-2017-03-22-at-100648-pm.png (116.0 kB)
screen-shot-2017-03-22-at-100724-pm.png (86.9 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 jokon · Apr 18, 2019 at 09:39 PM

Ok i know I'm very late on this. But i had the same type of problem making a 2.5D game. I'm leaving this reply mainly in case someone has this problem and needs help.


The camera renders the sprites by what sprite objects pivot is closest to the camera. This creates the clipping. You can fix it by going in to "edit -> project settings -> Graphics" then close to the top there is "Camera Settings". Set "Transparency Sort Mode" to "Custom Axis" and adjust the axis to what you need.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Couple of Questions dealing with 2.5D 0 Answers

Doom-style billard/sprite skybox without perspective warping? 1 Answer

How do I write a cutout sprite shader to depth depthtexture ? 0 Answers

How do you get the world-space position of a sprite with a custom pivot? 1 Answer

Dynamically alter shader parameters? 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