- Home /
Cartoon specular, regular diffuse, fresnel reflective?
I'm looking to get something that looks exactly like this:
I don't want to cheat and use a cubemap for the specular, since I do want the highlight to respond to lightsources. Doing it that way would also conflict with the fresnel.
I'm new to shader coding, just so you know.
http://www.google.com/search?q=node+based+shader+unity3d&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a I know their are a couple out there, and it can aid you in doing shaders, but I know nothing about them, so can't help more than this lol.
Answer by Irsan · Apr 24, 2011 at 09:08 PM
Oh, looks like poking around the internet and messing with a few shaders yielded a nice result, although it lacks the cartoon specular.
Shader "Example/RimWorldRefl" { Properties { _MainTex ("Texture", 2D) = "white" {} _Cube ("Cubemap", CUBE) = "" {} _RimPower ("Rim Power", Range(0.5,8.0)) = 3.0
}
SubShader {
Tags { "RenderType" = "Opaque" }
CGPROGRAM
#pragma surface surf Lambert
struct Input {
float2 uv_MainTex;
float3 worldRefl;
float3 viewDir;
};
sampler2D _MainTex;
samplerCUBE _Cube;
float _RimPower;
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb * 0.1;
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
o.Emission = texCUBE (_Cube, IN.worldRefl).rgb * pow(rim,_RimPower);
}
ENDCG
}
Fallback "Diffuse"
}
Can someone check this code to see if there's anything worthless? All I need now is that pesky cartoon specular...
Your answer
Follow this Question
Related Questions
Gem Shader doesn't work on Unity Iphone? 2 Answers
Outlined Specular shader? 0 Answers
Custom Shader: Using Normal, Diffuse, Gloss, and Specular Maps 0 Answers
change terrain built in shaders 1 Answer