• 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 avoorhees · Aug 23, 2012 at 08:25 PM · specular

Add specular map to shader

Hi there,

I'm trying to figure out how to add a texture into my shader which uses the red channel for the specular level and the green channel for the specular polish/shininess. I would also want to the blue channel to be used for something...maybe emmissive mask, but that's a whole other story.

If anyone can help out, or point me toward some hints, that would be super awesome.

Thanks!

Comment
Add comment · Show 3
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 ScroodgeM · Aug 23, 2012 at 08:27 PM 0
Share

first of all post your shader source to help us help you.

avatar image DaveA · Aug 23, 2012 at 09:31 PM 0
Share

Have you tried Strumpy's Shader Editor?

avatar image avoorhees · Aug 23, 2012 at 09:33 PM 0
Share

I'm just using the Normal-BumpSpec shader as a starting point.

3 Replies

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

Answer by ScroodgeM · Aug 23, 2012 at 09:42 PM

simple compare differences with shader you point to

Shader "Unity Answers/Bumped Specular with own map" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} _BumpMap ("Normalmap", 2D) = "bump" {} _SpecMap ("Specular map", 2D) = "black" {} } SubShader { Tags { "RenderType"="Opaque" } LOD 400 CGPROGRAM #pragma surface surf BlinnPhong

sampler2D _MainTex; sampler2D _BumpMap; sampler2D _SpecMap; fixed4 _Color; half _Shininess;

struct Input { float2 uv_MainTex; float2 uv_BumpMap; float2 uv_SpecMap; };

void surf (Input IN, inout SurfaceOutput o) { fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); fixed4 specTex = tex2D(_SpecMap, IN.uv_SpecMap); o.Albedo = tex.rgb _Color.rgb; o.Gloss = specTex.r; o.Alpha = tex.a _Color.a; o.Specular = _Shininess * specTex.g; o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); } ENDCG }

FallBack "Specular" }

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 avoorhees · Aug 24, 2012 at 02:25 PM 0
Share

Wow, you have worked magic. Thanks so much!

avatar image ScroodgeM · Aug 25, 2012 at 10:43 PM 0
Share

accept answer as correct to close question.

avatar image BDX777 · Dec 24, 2013 at 08:54 PM 0
Share

$$anonymous$$an I wish this shader was built-in, maybe with a Self Illu$$anonymous$$ation version aswell.

avatar image
1

Answer by avoorhees · Aug 23, 2012 at 10:00 PM

 Shader "Bumped Specular" {
 Properties {
     _Color ("Main Color", Color) = (1,1,1,1)
     _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
     _Shininess ("Shininess", Range (0.03, 1)) = 0.078125
     _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
     _BumpMap ("Normalmap", 2D) = "bump" {}
 }
 SubShader { 
     Tags { "RenderType"="Opaque" }
     LOD 400
     
 CGPROGRAM
 #pragma surface surf BlinnPhong
 
 
 sampler2D _MainTex;
 sampler2D _BumpMap;
 fixed4 _Color;
 half _Shininess;
 
 struct Input {
     float2 uv_MainTex;
     float2 uv_BumpMap;
 };
 
 void surf (Input IN, inout SurfaceOutput o) {
     fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
     o.Albedo = tex.rgb * _Color.rgb;
     o.Gloss = tex.a;
     o.Alpha = tex.a * _Color.a;
     o.Specular = _Shininess;
     o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
 }
 ENDCG
 }
 
 FallBack "Specular"
 }
 
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 Pratap-Dafedar · May 29, 2015 at 07:28 AM

Hi ScroodgeM,

Did you try this with new Unity 5 shader.?

I think these two params are missing.

o.Gloss
o.Specular

  • Pratap Dafedar.

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 BDX777 · May 29, 2015 at 06:52 PM 0
Share

This question is from 2012, before Unity 5 was released to the public or even existed. Thanks for the extra answer though.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

11 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

Related Questions

Separate Shininess Map? 0 Answers

Beast Lightmap + Fake specuar / shininess 1 Answer

Specular Materials on iPhone or Android? 1 Answer

Specular & alpha mapping 1 Answer

Specular Transparency 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