3ds Max Blinn Specular level adjustment to Unity shader?

Hi!

When I’m creating a model in 3ds Max and using the default Blinn-shader, I’m able to adjust the specular level of the material which makes nice highlights to the model in addition to Specular Color.

However, I’m not able to do same effect with Unity default shaders. For example, the vertex lit has only colors for Diffuse, Specular (which isn’t the same), Emissive and a Shininess-slider, which equals to the Glossiness of 3ds Max Blinn. Even with the Specular-shader I’m not able to achieve similar result like with Blinn Specular Level.

My question is it possible to create my own Unity-shader with that same specular level function like in Blinn? I don’t have time and resources to find out the solution all by myself so some help and answers would be very valuable. :slight_smile: Thank you in advance!

The alpha channel of the Diffuse will end up controlling the specular level and the “Shininess” slider controls the gloss amount. The “Specular Color” controls the colour of the specular highlight.

Unity’s specular/gloss is all a bit mixed up. Internal to Surface Shaders, the two values are named opposite (it calls specular “Gloss” and gloss “Specular”) but the values are also plugged in opposite (specular goes to “Gloss” and gloss goes to “Specular”) so it ends up being correct.

Thanks for the reply, Farfarer!

However, I’m not quite sure did I understand your post right. The Alpha-slider of Diffuse color doesn’t seem to affect that Specular level at all. Or did you mean the Alpha channel of the Diffuse-texture, not color? In my project the shader of most of the objects is just diffuse color and not any textures at all, so the Specular Level would be better to adjust with slider or numerical values like in Max, and vertex lit would be the best shader using it because it is so lightweight.

What am I trying to achieve is this:

Left image is from Max. The object is using Blinn material with white Specular Color and 100 Specular Level. Right image is from Unity and the object has vertex lit shader with white specular color. I would like to have the same effect in Unity too.

I noticed that if I put a bright light near the object in Unity, the highlights is like in 3ds Max but the Specular level has to be adjustable with shader, not the lighting of the scene. So I figured out that somehow I have to put the specular color “whiter than white”, override the specular color. In 3ds Max it’s possible, the range of Specular level goes from 0 to 999, so I think it’s possible in Unity too.

Hi!

After some researching and testing I found a way to create a separate specular level adjustment for the vertexlit shader.

However, because it has been created with another pass, it doubles the draw calls, tris and verts of the object. I think that’s fine because most of the Unity’s shaders make two draw calls, but when I’m using my shader for example with cubemap, it makes one more draw call so the final amount is three with tripled verts and tris.

My question is, should I be worried about the three draw calls that some of the shaders make? How careful should I be with using that kind of shaders? Should I use them where they are absolutely necessary or can I use them wherever I want?

Here’s the code for Unity 2.6:

Shader "VertexLit SpecLevel" {

Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _SpecColor ("Spec Color", Color) = (1,1,1,1)
	_SpecLevel ("Spec Strength", Range (1, 20)) = 1
	_Emission ("Emissive Color", Color) = (0,0,0,0)
    _Shininess ("Shininess", Range (0.03, 1)) = 0.7
    _MainTex ("Base (RGB)", 2D) = "white" {}

}

Category {
    Tags { "RenderType"="Opaque" }
    Blend AppSrcAdd AppDstAdd
    Fog { Color [_AddFog] }

    SubShader {
	
//Normal rendering pass	
		Pass {
		Material {
			Diffuse [_Color]
			Ambient [_Color]
			Emission [_Emission]
		} 
		Lighting On
		SetTexture [_MainTex] {
			Combine texture * primary DOUBLE, texture * primary
		} 
	}
 
 
//Specular rendering pass 
        Pass {
            Lighting On
            Material {
                Specular [_SpecColor]
                Shininess [_Shininess]
            }
            SeparateSpecular On
CGPROGRAM
#pragma fragment frag
#pragma fragmentoption ARB_fog_exp2
#pragma fragmentoption ARB_precision_hint_fastest

#include "UnityCG.cginc"

struct v2f {
    float2 uv : TEXCOORD0;
    float4 diff : COLOR0;
    float4 spec : COLOR1;
};

uniform sampler2D _MainTex : register(s0);
uniform float4 _SpecColor;
uniform float _SpecLevel;

half4 frag (v2f i) : COLOR
{
    half4 temp = tex2D (_MainTex, i.uv);   
    half4 c;
    c.xyz = (temp.xyz * i.diff.xyz + temp.w * i.spec.xyz ) * _SpecLevel;
    c.w = temp.w * (i.diff.w + Luminance(i.spec.xyz) * _SpecColor.a);
    return c;
}
ENDCG
            SetTexture[_MainTex] {}
        }  
    }
}

FallBack "VertexLit", 1
}