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 Junkface · Feb 21, 2018 at 07:55 AM · lightingsurface shadergrab

Different lighting in grabpass

I'm attempting to do some manipulation of colours after all lighting calculations have been done. As a first step I'm trying to get the scene with basic lighting using a grab pass but I'm getting a different image from the grab pass than if I use the same shader with the grab pass commented out. I'm using the default surface shader created as new by Unity with the following (copy and pasted from here) added to the end:

             GrabPass
             {
                 "_BackgroundTexture"
             }
     
             Pass
             {
                 CGPROGRAM
                 #pragma vertex vert
                 #pragma fragment frag
                 #include "UnityCG.cginc"
     
                 struct v2f
                 {
                     float4 grabPos : TEXCOORD0;
                     float4 pos : SV_POSITION;
                 };
     
                 v2f vert(appdata_base v) {
                     v2f o;
                     o.pos = UnityObjectToClipPos(v.vertex);
                     o.grabPos = ComputeGrabScreenPos(o.pos);
                     return o;
                 }
     
                 sampler2D _BackgroundTexture;
     
                 half4 frag(v2f i) : SV_Target
                 {
                     half4 bgcolor = tex2Dproj(_BackgroundTexture, i.grabPos);
                     return bgcolor;
                 }
                 ENDCG
 }

Without that snippet I get: alt text With it I get: alt text

Any ideas why, or of an alternative way to get the brightness of each pixel after all lights have rendered? If it's relevant, I currently have one directional light and one spotlight in the scene. Thanks in advance for taking the time to try and answer my (probably) silly question.

nograbpass.jpg (12.5 kB)
grabpass.jpg (10.1 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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Junkface · Feb 21, 2018 at 01:15 PM

A couple of hours away from it and looking at the documentation again I realised the problem's "_BackgroundTexture" in the GrabPass. Got rid of that and now working as I expected it to. I'll leave this here in the hope it's of use to someone else.

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

93 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

Related Questions

Unity Surface Shader - Deferred lighting viewDir and lightDir 0 Answers

How to edit the new particle surface shader? / Make it so particles receive light from all angles 0 Answers

Refraction Surface Shader Upside down 1 Answer

Lighting support in Unlit shader 0 Answers

How to fix this point light bug in surface shader? 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