Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Guitar rocks · Dec 29, 2014 at 05:09 PM · shader

fragment Shader -> get the current pixel color int the color Buffer :D

hi, im tring to do a refraction shader,and i can find info about how to get the current pixel color, so i can use it to change the color of other pixel.

plz help !! :D

ty for reading! cya

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 tanoshimi · Dec 29, 2014 at 07:43 PM

What do you mean by the "current pixel color"?

You can't access the value in the colour buffer at the point a fragment shader runs, because at that time it may not be known. And, if it were known, it would be unreliable - fragment shaders run in parallel and you wouldn't know which other operations that also affect this fragment had already run. Why do you need to know this value? To "change" pixel colours, what you generally do is specify both the output colour from a fragment shader and the appropriate BlendOp as to how it should be combined with the existing colour value in the buffer.

Or do you mean the pixel colour determined by a previous pass? If so, you can render the first pass to a texture, and then lookup that pixel from the texture using tex2Dfetch.

Comment
Add comment · Show 2 · 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 Guitar rocks · Dec 29, 2014 at 09:30 PM 0
Share

i want to do a refractive shader so i have queeque in transparent, and them i just need the color of the pixel that im running the fragment program, so i can grab it and change it, by doing a shift position of simply do a blend like:

uniform _Color col;

frag(){

return (_Color + CURRENTPIXELCOLOR)* 0.5;

} //CURRENTPIXELCOLOR = to the color pixel(in the colorBuffer) that it´s running the frag program

~

can u tell me how can i get this ->CURRENTPIXELCOLOR

if this is totally "non-sense", can u write a simple transperancy shader to demonstra, plz :D

sorry for the englis:D

avatar image tanoshimi · Dec 29, 2014 at 10:05 PM 0
Share

Like I said, "CURRENTPIXELCOLOR" doesn't make sense, unless you're talking about a previous pass?

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

2 People are following this question.

avatar image avatar image

Related Questions

How to force the compilation of a shader in Unity? 5 Answers

Custom terrain material makes the texture appear in bad quality 0 Answers

Fade-In/Out shadows for a specific object 0 Answers

Changing shaders in a game during runtime 1 Answer

How would i eliminate flickering caused by shader? 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