• 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 Toxijuice · Sep 26, 2015 at 07:48 PM · particlesimage effectsdepthdepth of field

Depth of Field Ignoring Particles

Hello!

I have been trying to use Unity's built-in Depth of Field image effect in conjunction with Particle Systems. The problem is, the Depth of Field doesn't seem to factor in particles in a non-mesh rendering mode. Instead, it will be blurred based on the distance of the object behind it (as shown in the picture below).

alt text

I have tried many different types of shaders, including opaque shaders, and adding ZWrite On to existing particle shaders, with no luck whatsoever.

My question is: is there a way to make this work? And if not, is there perhaps an alternative (preferrably free) to either the particle system, or DoF effect that will make it work?

I am using Unity 5.2.1

ss-2015-09-24-at-021929-copy.png (460.4 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
Best Answer

Answer by Johannski · Dec 13, 2016 at 02:02 PM

For anyone who still has this problem: As for Unity 5.5 it is not possible to write into the depth buffer for transparent objects. The depth buffer is used for quite some post processing effects so in order to get the particles to render the correct depth they need to be cutout or opaque shaders instead. Here is a simple example of such a shader:

 Shader "Supyrb/Particles/Cutout" {
     Properties{
         _MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
         _Cutoff("Alpha cutoff", Range(0,1)) = 0.5
         // Not used, but important for fallback to render the correct depth buffer
         [HideInInspector] _Color("Main Color", Color) = (1,1,1,1)
     }
 
     SubShader{
         Tags{ "Queue" = "AlphaTest" "IgnoreProjector" = "True" "RenderType" = "TransparentCutout" }
         LOD 200
 
         CGPROGRAM
         #pragma surface surf Lambert alphatest:_Cutoff
 
         sampler2D _MainTex;
 
         struct Input {
             float2 uv_MainTex;
             float4 color: COLOR;
         };
 
         void surf(Input IN, inout SurfaceOutput o) {
             fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * IN.color;
             o.Albedo = c.rgb;
             o.Alpha = c.a;
         }
         ENDCG
     }
     Fallback "Legacy Shaders/Transparent/Cutout/VertexLit"
 }
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
1

Answer by ZacGarby · Sep 26, 2015 at 09:22 PM

Couldn't you just make it render the particles as a mesh?

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 Toxijuice · Sep 26, 2015 at 09:35 PM 0
Share

It is possible to render the particles as a mesh, as long as I use an opaque shader, otherwise I get the same problems (and see$$anonymous$$gly less performance).

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

Why don't soft particles work when using render objects feature? 0 Answers

How can I recreate the filled Ultimate Meter in Overwatch? 1 Answer

does post processing stack work on android and simple depth of field doesnt show in mobile 1 Answer

Depth of field error! :( 0 Answers

Standard Image Effects like Anti-Aliasing and Depth Of Field "Not supported on this platform 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