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 someusernamehere · Jan 10, 2017 at 06:47 AM · 2dparticlessorting

Particle effect sorting around a 2d sprite

I am having difficulties understanding why this is not working, I have searched as much as I could but have not found an answer yet. Here is an image of what I mean
alt text

The particles being shown is a spinning GameObject with 2 particle effects emitting upwards and fading out after a certain point. The issue that I am having is that even though the center point of the character sprite and the particle emitting game object are perfectly lined up on the Z the particles are shown behind and do not actually visually spin around the character sprite but behind it.

What I am trying to achieve is just a simple effect that the particles spiral from the bottom up while spinning around the character sprite.

The top down part of the image shows that the particles are all in the right position but just not being z sorted.

ss-particles.png (177.5 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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by tanoshimi · Jan 10, 2017 at 06:53 AM

What shader are you using on your sprite material? By default, sprites don't write to (or test on) values in the depth buffe.

If you want to combine 3d objects and sprites in the same scene, it's generally necessary to add the appropriate ZTest and ZWrite conditions into your sprite shader.

Comment
Add comment · Show 1 · 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 someusernamehere · Jan 10, 2017 at 09:20 PM 0
Share

@tanoshimi

Everything was default, I created a new $$anonymous$$aterial and added the modified Shader( Sprite/Default ) to have properties ZWrite On and ZTest LEqual.

alt text

There is some changes but unfortunately still not what I was hoping for.

ss-particles1.png (183.2 kB)
avatar image
0

Answer by $$anonymous$$ · Feb 14, 2017 at 07:43 AM

The general problem is that transparent geometry has to be drawn back to front to be correct. In your case, the draw call for the particle system and the draw call for the sprite overlap each other in depth. Depth buffer sorting doesn't work at all because your sprite's transparent areas will still fill the depth buffer, thereby masking the particles behind it or the other way around.

If your sprites only have fully opaque and fully transparent texels(so no alpha = 0.5 e.g.) and are sampled pixel-perfect, you can clip shaded fragments that are transparent in the fragment shader (with the clip() function). Clipped fragments won't write to the depth buffer and this is basically what the transparent-cutout shaders do.

If you also have semi-transparent sprites the only dirty solution that comes to my mind and that I have already used would be splitting up the particle system into two that fake to be a single one - one behind the sprite and one in front of it.

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
avatar image
0

Answer by sefiroths · Oct 14, 2017 at 07:57 AM

Hi, I have the same problem... I have a fbx that is a spyral where the texture is rendered, so this spyral is around the character... some solution?

alt textThis is my assets


schermata-2017-10-14-alle-100931.png (284.9 kB)
assets.zip (343.8 kB)
Comment
Add comment · Show 1 · 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 someusernamehere · Dec 17, 2017 at 04:53 AM 0
Share

Sorry but I have not found a solution to this, not trolling but I have seen some really poor workarounds but no actual solution that I would ever consider realistically implementing.

I still have a very limited understanding of how Shaders work, maybe someone with good knowledge can shed some light on this but from my understanding of it is that the particle effect uses z sorting while the SpriteRenderer that we use to house our Character sprite within does not in the way that we would like it to.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Can I change individual particles to different sorting layers? 0 Answers

2D Sorting Layer don't worn with new material 2 Answers

Particle System: How To Control Axis? 0 Answers

Assets/Scripts/PlayerController.cs(32,49): error CS0126: An object of a type convertible to `float' is required for the return statement 1 Answer

Flat 2d image on 3d character. 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