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 MauveAvenger · Oct 30, 2015 at 09:01 PM · shaderspecular

Specularity not working on custom shader.

Hello,

I am currently working on a custom shader that is meant to resemble a soap bubble. It is a surface shader and for some reason specularity is not working at all.

I created a variable (_SpecPower) and tried plugging it in to both o.Specular and o.Gloss. But when I drag the slider, nothing happens. I have also tried plugging in a specular map but still no success.

Any help would be greatly appreciated.

Thank you, Alex


Mod posting user's comment into their question...


Thanks for your response. Here are some snippets of the code that I can post.

For the surface type I have: #pragma surface surf BlinnPhong alpha

As a workaround, I plugged specular into the Emission slot:

o.Emission = spec*_SpecIntensity*_SpecularColor*_MasterOpacity*_BubbleBrightness;

Here is the code I used to calculate the appropriate lighting information for specular:

half3 h = normalize(IN.lightDir + IN.viewDir); half diff = max (0, dot (o.Normal, IN.lightDir)); float nh = max (0, dot (o.Normal, h)); float spec = pow (nh, 40.0)*_SpecPower;

This seems to work but I would still like to get it working using o.Specular or o.Gloss if possible. Right now, nothing happens when I plug into those slots. I even tried using Fallback “Specular” like you suggested. I know it’s not much code to go off of, but if you have any more suggestions I would appreciate it.

Thank you, Alex

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 rutter · Nov 07, 2015 at 03:37 AM 0
Share

Ins$$anonymous$$d of posting an answer, remember that you can comment on someone's response or edit additional information into your original question.

avatar image MauveAvenger rutter · Nov 09, 2015 at 03:22 PM 0
Share

Thank you!

1 Reply

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

Answer by helarts · Nov 04, 2015 at 09:04 PM

With the shader code it would be easier to help, are you sure you are using a Lighting model that supports specular (#pragma surface surf BlinnPhong) ? You can try to add this in the properties:

 _SpecColor("Specular Color", Color) = (1,1,1,1)

and at the end of your shader:

 FallBack "Specular"

Edit:

Start from a shader already working the way you want or try to compare it with yours to see what you are missing, you can get unity's builtin shaders here: https://unity3d.com/get-unity/download/archive

In 'DefaultResourcesExtra' folder 'Alpha-Glossy.shader' or 'Alpha-BumpSpec.shader' should be a good starting point in this case.

You can also check "Simple Specular" custom lighting model on this page: http://docs.unity3d.com/Manual/SL-SurfaceShaderLightingExamples.html

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 MauveAvenger · Nov 09, 2015 at 03:24 PM 0
Share

Thanks! I'll try that out.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Why are Cubemaps and Specular highlights not equally blurry at the same Roughness / Glossyness value with standard pbr shader? 0 Answers

Specular map to decide reflection 0 Answers

Standard shader (specular setup) with Phong tessellation support 1 Answer

Where can we find the Specular/Base shader pass script ? 1 Answer

Can't set _SpecColor but can set _Color no problem - why? 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