-
-
Save ArieLeo/7e31bbea745734244def to your computer and use it in GitHub Desktop.
PBS surface shader
This file contains hidden or 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
Shader "Custom/SurfaceStandard" { | |
Properties { | |
_Color("Color", Color) = (1,1,1) | |
_MainTex("Diffuse", 2D) = "white" {} | |
[NoScaleOffset] _SpecGlossMap("Specular", 2D) = "white" {} | |
[NoScaleOffset] _BumpMap("Normal Map", 2D) = "bump" {} | |
_BumpScale("Scale", Float) = 1.0 | |
[NoScaleOffset] _Occlusion("Occlusion", 2D) = "white" {} | |
[NoScaleOffset] _EmissionMap("Emission", 2D) = "black" {} | |
} | |
SubShader { | |
Tags { "RenderType"="Opaque" } | |
LOD 200 | |
CGPROGRAM | |
#pragma surface surf StandardPBS fullforwardshadows | |
#pragma target 3.0 | |
#define _GLOSSYENV 1 | |
#include "UnityPBSLighting.cginc" | |
sampler2D _MainTex; | |
sampler2D _SpecGlossMap; | |
sampler2D _Occlusion; | |
sampler2D _EmissionMap; | |
sampler2D _BumpMap; | |
fixed4 _Color; | |
half _BumpScale; | |
struct Input { | |
float2 uv_MainTex; | |
}; | |
void surf (Input IN, inout SurfaceOutputPBS o) { | |
fixed4 diff = tex2D (_MainTex, IN.uv_MainTex) * _Color; | |
fixed4 spec = tex2D (_SpecGlossMap, IN.uv_MainTex); | |
o.Albedo = diff.rgb; | |
o.Specular = spec.rgb; | |
o.Smoothness = spec.a; | |
o.Alpha = diff.a; | |
o.Occlusion = tex2D(_Occlusion, IN.uv_MainTex).g; | |
o.Normal = normalize(UnpackScaleNormal(tex2D(_BumpMap, IN.uv_MainTex), _BumpScale)); | |
} | |
ENDCG | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment