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
1
Question by 0867532 · Nov 21, 2016 at 07:21 AM · shadertexturematerialshadersmaterials

Shader: get back scene pixel color?

I've just started with shaders, and began with writing simple shader, wich inverts all colors behind object. It was fairly easy, based on ShaderLab Docs, just using "Blend OneMinusDstColor". And i've tryed to write similar shader, wich apply grayscale effect to all pixels, behind object. Reading docs on simple ShaderLab tells me, that it is unreachable witout accessing color components, so i have to use CGPROGRAM. But i cant figure out, how to get back color of scene. Ive tryed wack GL_DST_COLOR, but shader copiller dont recognize that. Any one can help, please?

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
Best Answer

Answer by Pangamini · Nov 21, 2016 at 11:39 AM

Shader doesn't natively access the underlying color. Blending is done in a separate, fixed-function (non-programmable) unit, controlled by the Blend settings (OneMinusDstColor in your case). Blending In the link, you can see the blending is done outside the pixel shader. If you really want to access the underlying pixels, for special effect such as grayscale, you need to do GrabPass. Basically, an unity's feature that captures the screen into a texture which you can access from the shader. Works exactly as you want (lets you sample any pixel, not just under the current fragment) but it's a lot more expensive to execute than blending. But since you can access any pixel (it's just texture sampling) you can do custom effects, such as blurring or refraction.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Dynamic batching breaks with the material Mobile/Alpha Blended. 0 Answers

MaterialPropertyBlock causes Z-fighting sprites 0 Answers

CRT/LCD screen shader (for materials) 4 Answers

Is this the correct way? 1 Answer

How to make a cube with metallic look and soft edges [pic included] 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