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 fafnir · Mar 28, 2017 at 06:43 PM · shadertoonambient light

ShadeSH9 always zero

I'm trying to write a per-pixel cel shader that uses ambient light. In my ForwardBase pass fragment shader I do

 final.rgb += ShadeSH9(half4(UnityObjectToWorldNormal(f.normal), 1));

but whenever I disable all light except ambient in the scene, everything is drawn black. Everything in my scene uses my shader, and the lighting setup is a skybox with a sun directional light, and nothing else. I also tried to multiply instead of add in the line above and the result was black, so the ShadeSH9 call returns zero. The ambient intensity varies in script but is never zero. Any ideas what I could be doing wrong here?

Comment
Add comment · Show 2
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 meat5000 ♦ · Mar 28, 2017 at 06:56 PM 0
Share

I recommend you fly through the first few chapter of this

https://en.wikibooks.org/wiki/Cg_Program$$anonymous$$g/Unity

it wont take long. By the time you've done that you'll understand how to diagnose your blackness.

Given changes in shaders recently it wouldn't surprise me if you've simple omitted something you needed or not omitted something that was required to go. This is usually within the first few lines of shader setup.

https://www.google.co.uk/search?q=unity+shader+everything+black&ie=utf-8&oe=utf-8&client=ubuntu&channel=fs&gfe_rd=cr&ei=LbLaWNX2IuiAgAaCooCoDg&gws_rd=ssl

avatar image StrogaBeef · May 18, 2017 at 01:22 PM 0
Share

I have the same issue. ShadeSH9 function returns zero if a skybox is selected as ambient source but it works with gradient and solid color as ambience.

did you solve it fafnir?

There is defenetly something fishy about the ShadeSH9, the documentation on it is sparse.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by mptp · Jun 26, 2019 at 12:33 AM

Something I just found out as well: if you haven't got Tags { "LightMode" = "ForwardBase" } at the beginning of your pass (before CGPROGRAM), ShadeSH9 will return zero.

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
0

Answer by StrogaBeef · May 19, 2017 at 02:00 PM

I think I know! the ShadeSH9 can only sample a skybox is it is baked! try baking the scene and see if the ShadeSH9 picks up something

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

6 People are following this question.

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

Related Questions

Toon shader for a cube - outline problem 2 Answers

How to Get Nice Thick Toon-Like Outlines On Non-Smooth Geometry? 1 Answer

Shader Assitance: Sprite Outline Color, Hidden Object -1 Answers

Exclude outline only, from fog, in custom toon shader. 1 Answer

Shader to use for background images in a 3D scene with variable lighting 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