-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathDiffuseTwoSided.shader
62 lines (48 loc) · 1.24 KB
/
DiffuseTwoSided.shader
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// A basic shader to render both sides of a mesh
Shader "Game/Diffuse Two-Sided" {
Properties {
_Color("Main Color", Color) = (1, 1, 1, 1)
_MainTex("Base (RGB) Trans (A)", 2D) = "white" { }
}
SubShader {
Tags { "Queue"="Geometry" "IgnoreProjector"="False" "RenderType"="Opaque" }
// First Pass: Render back faces only
Cull Front
CGPROGRAM
#pragma surface surf Lambert vertex:vert
sampler2D _MainTex;
fixed4 _Color;
struct Input {
float4 color:COLOR;
float2 uv_MainTex;
};
void vert(inout appdata_full v, out Input o) {
UNITY_INITIALIZE_OUTPUT(Input, o);
// Flip normals when rendering back faces for correct lighting
v.normal = -v.normal;
}
void surf(Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * IN.color * _Color;
o.Albedo = c.rgb;
o.Alpha = 1.0;
}
ENDCG
// Second Pass: Render front faces as usual
Cull Back
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
fixed4 _Color;
struct Input {
float4 color:COLOR;
float2 uv_MainTex;
};
void surf(Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * IN.color * _Color;
o.Albedo = c.rgb;
o.Alpha = 1.0;
}
ENDCG
}
Fallback "Diffuse"
}