Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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 AlessandroCampi · Sep 17, 2021 at 05:50 PM · resolutionpost processingpost-process-effectdepth of field

Depth of Field and Resolution

Hello, I have a depth of field post-processing effect on my camera, and it works just like how it should. The problem is that when I change the screen resolution in the gameview, the effect gets weaker. I cannot create a script that increases the strenght of the blur based on resolution, since the effect is already at maximum strength. Does somebody know if there's a workaround for this?

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
1

Answer by Eno-Khaon · Sep 17, 2021 at 07:43 PM

Shaders have *some* limits to their versatility. In this case, the question is:

How many loops should the Depth of Field shader make to gather pixel color data for blurring?

The number of passes it makes dictates how far away from the "current" pixel the blur effect reaches to sample new color data. The resolution of the render, by extension, influences what color will be grabbed by each of those samples.

More importantly, as a general rule, the number of loops made for a blur effect in a shader can't and/or shouldn't be variable. The shader doesn't generally know how to handle that, since it's *typically* supposed to be compiled into a one-and-done sort of process.

Let's use a simple (numerically) example, 640x480 vs. 64x48 resolution. If, at 640x480, you sample 10 pixels in a row on each side of the current pixel (21 total), you're grabbing 3.3% of the total width and 4.3% of the total height of the screen. If you grab 21 consecutive pixels from 64x48 resolution, that's 33%/43% screen width/height sampled for the blur effect!

Okay, so going on a per-pixel basis is no good with that resolution difference. How about percentage-of-screen instead? Well, you run into the opposite problem instead: If your samples taken cover, say, 2% of the width/height of the screen, then a majority (all) of the pixels sampled at 64x48 resolution will sample THE SAME PIXEL, resulting in no blur at all. Likewise, the pixels sampled at higher resolutions will no longer be adjacent to each other, making the effect more visually confusing.

Because of the way Shaders are compiled, there's not really room for extreme versatility here. The ideal would probably be to have a small collection of blur-effect Shaders, where each type can be used for different resolution ranges.

Either way, adding in this sort of versatility would mean re-implementing Depth of Field for yourself to take advantage of a variety of Blur Shaders to use in the process.

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 AlessandroCampi · Sep 18, 2021 at 02:57 PM 0
Share

Thank you for your answer.

If I can't change the depth of field effect, can I change some camera settings so that its resolution is always the same? This could fix my problem, since the Depth of Field effect is rendered on a separate camera, and blurring everything would prevent the resolution from looking bad.

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

126 People are following this question.

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

Related Questions

How to get quality Depth Of Field effect with Post Processing Stack V2? 1 Answer

How to change Focus Distance at run time? Using PostProcessing Depth of Field. 1 Answer

How do i get depth of field from volume? 0 Answers

Modify values on VolumeProfile URP. 1 Answer

Is it possible to turn on and off a certain post processing effect by a script? 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