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
1
Question by afuzzyllama · Jun 04, 2010 at 06:34 PM · shaderspecularoutputincorrect

Specular property isn't working in ShaderLab

I'm working through the Unity Shader presentation, but I'm running into a problem. With the following code I only get a diffuse output, when I should be getting a specular one:

Shader "Tutorial/Ambient Diffuse Specular" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Spec Color", Color) = (1,1,1,0) _Shininess ("Shininess", Range (0.1, 1)) = 0.7 }

SubShader { Pass { Material { Diffuse [_Color] Ambient [_Color] Shininess [_Shininess] Specular [_SpecColor] } Lighting On } } }

I'm pretty sure this code is right, and I'm running a Nvida 9000 series card so I don't think the shader ability of the card is to blame. Is there some setting I'm not thinking about that wouldn't allow for specular output to be rendered?

Thanks!

Comment
Add comment · Show 8
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 afuzzyllama · Jun 04, 2010 at 07:35 PM 0
Share

After playing around with this a little more, I have found that the specularity is actually enlarged on the back half but when I start to move the object out of the center it goes away. When I bring the object to the edge of the camera view... the specularity shows up and enlarges quickly. $$anonymous$$aybe there is something with the glstate/ObjSpaceLightDir/ObjSpaceViewDir in my scene/project/unity?

avatar image afuzzyllama · Jun 04, 2010 at 08:43 PM 0
Share

I don't know if this is the solution but when I set the texture and then made it none the specularity effect started to happen.

avatar image dyamanoha · Jun 01, 2012 at 09:21 PM 0
Share

This is still an issue as of 3.5.2f2.

avatar image sdgd dyamanoha · Oct 27, 2013 at 08:15 PM 0
Share

please don't post answer as comment!!!

avatar image WhendricSo · Sep 15, 2012 at 05:49 PM 0
Share

I am also having this problem.

Specifically, I would like to have no texture work done for certain geometry on the GPU, but I need vertex-only specular for that geometry.

Is there a workaround that does not include a SetTexture command?

avatar image mepwn12 · Oct 27, 2013 at 08:14 PM 0
Share

still an issue as of Unity 4.x :c

avatar image sdgd mepwn12 · Oct 27, 2013 at 08:16 PM 0
Share

please don't post answer as comment!!!

Show more comments

3 Replies

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

Answer by skovacs1 · Jun 29, 2010 at 06:09 PM

Hey, you're right. I never noticed. wtf?

I just ran some tests - lots of them. It appears that like yourself, in my copy of Unity 2.6 Pro on Windows at the time of this writing, none of the ShaderLab-based-shaders seem to do specular without a SetTexture call multiplying the primary. This should be corrected. I have confirmed that all of the built-in VertexLit shaders have such a SetTexture call, which is why they all work.

If you're looking to do it without the need for a texture in the shader, I looked at the built-in "Specular" shader and without the texture stuff, it looks like:

SubShader { Pass { Tags {"LightMode" = "Vertex"} Lighting On Material { Ambient [_Color] Diffuse [_Color] Specular [_SpecColor] Shininess [_Shininess] } SeparateSpecular On

CGPROGRAM #pragma fragment frag #pragma fragmentoption ARB_fog_exp2 #pragma fragmentoption ARB_precision_hint_fastest

include "UnityCG.cginc"

uniform sampler2D _MainTex;

half4 frag (v2f_vertex_lit i) : COLOR { return VertexLight( i, _MainTex ); } ENDCG }

 //Pixel Lights...

So, to answer your question(?), ShaderLab does not seem to be applying the specular component without a texture anymore. If you don't want a texture in your shader, you seem to need the above CGShader to perform the vertex lighting calculations. This was not how it used to be as per the Unite08 course you seem to have gotten your shader from and given Aras' above answer, it doesn't seem like it was intended to be this way.

Comment
Add comment · Show 3 · 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 afuzzyllama · Jun 30, 2010 at 12:36 PM 0
Share

That was the conclusion I made after awhile. I guess you apply the texture then for a quick fix... otherwise hope they fix it in 3.0 ^^

avatar image Hendrys · Apr 23, 2011 at 08:31 PM 0
Share

I'm Using now Unity3.3. But it seems we have the same problem. When i Use the exact code you posted (the one on the Unite 08 presentation). I still don't get the Specular color applied. Why is that?, is there a solution that doesn't require me to write a vertex program?, please Help.

Cheers.

avatar image Hendrys Hendrys · Apr 23, 2011 at 08:51 PM 0
Share

Solved: I Used a SetTexture statement,

SetTexture [_$$anonymous$$ainTex] { Combine texture primary DOUBLE, texture primary }

I declared a _$$anonymous$$ainTex property also, it worked.

avatar image
0

Answer by Murcho · Jun 05, 2010 at 03:36 AM

Without getting in and testing it myself, the first thing that pops out to me is that your alpha value for the _SpecColor property is set to 0. This could possibly be masking out the entire specular effect.

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 Jessy · Jun 05, 2010 at 04:56 AM 0
Share

No, alpha doesn't come into play.

avatar image afuzzyllama · Jun 06, 2010 at 01:14 PM 0
Share

Even when setting the alpha to 1 it doesn't change anything. I just can't get ShaderLab or any other shaders to work properly in Unity =/

avatar image
0

Answer by Aras · Jun 08, 2010 at 08:43 AM

Does adding "SeparateSpecular On" help?

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 afuzzyllama · Jun 09, 2010 at 05:28 AM 0
Share

Unfortunately no. It seems when I set the texture it works... otherwise it just does a diffuse shader.

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

Shader alpha setting being ignored? 1 Answer

Cutout + Specularmask-shader error: "Material doesn't have a color property" 0 Answers

Adding Spheremap reflection and Gloss/Shininess controls to a Sruface Shader 0 Answers

specular shader alpha not working? 0 Answers

Depth issues with a 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