system
April 24, 2011, 8:30pm
1
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.
system
April 24, 2011, 9:08pm
2
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...