Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
【Unity】リムライティングっぽいシェーダー(StandardShader版)
Shader "Custom/RimLightingStandard" {
Properties {
_MainColor ("MainColor", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_RimColor("RimColor",Color)=(1,1,1,1)
_RimPower("RimPower", Range(0.1, 10.0)) = 3.0
_RimAmplitude("RimAmplitude",Float)=1
_Alpha("Alpha",Range(0.0,1.0))=1
}
SubShader {
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
LOD 200
Blend SrcAlpha OneMinusSrcAlpha
Pass{
ZWrite ON
ColorMask 0
}
CGPROGRAM
#pragma surface surf Standard fullforwardshadows alpha:fade
#pragma target 3.0
sampler2D _MainTex;
fixed4 _MainColor;
fixed4 _RimColor;
half _RimPower;
float _RimAmplitude;
float _Alpha;
struct Input {
float2 uv_MainTex;
float3 worldPos;
float3 worldNormal;
float3 viewDir;
};
void surf (Input IN, inout SurfaceOutputStandard o) {
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _MainColor;
float3 normalDir = normalize(IN.worldNormal);
float3 viewDir = normalize(_WorldSpaceCameraPos.xyz-IN.worldPos.xyz);
float NVdot = 1 - dot(viewDir,normalDir);
float rim=pow(NVdot,_RimPower)*_RimAmplitude;
o.Albedo += rim*(1-abs(_Alpha*2-1))*_RimColor.rgb;
o.Alpha = _Alpha * (1 + rim);
}
ENDCG
}
FallBack "Diffuse"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment