Last active
February 2, 2022 17:12
-
-
Save slipster216/88d2ecff0bd49098874a7f801bcef573 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN_OPTIONS | |
Workflow "Unlit" | |
END_OPTIONS | |
BEGIN_PROPERTIES | |
_Matcap("Matcap Texture", 2D) = "white" {} | |
END_PROPERTIES | |
BEGIN_CODE | |
TEXTURE2D(_Matcap); | |
SAMPLER(sampler_Matcap); | |
void SurfaceFunction(inout Surface o, ShaderData d) | |
{ | |
float3 up = mul((float3x3)UNITY_MATRIX_I_V, float3(0,1,0)); | |
float3 right = normalize(cross(up, d.worldSpaceViewDir)); | |
up = cross(d.worldSpaceViewDir, right); | |
float2 matcapUV = mul(float3x3(right, up, d.worldSpaceViewDir), d.worldSpaceNormal).xy; | |
matcapUV = matcapUV * 0.5 + 0.5; | |
o.Albedo *= SAMPLE_TEXTURE2D(_Matcap, sampler_Matcap, matcapUV).rgb; | |
} | |
END_CODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment