Skip to content

Commit c63d426

Browse files
Adds 14 types of airlocks (#887)
Does what the title says! Co-authored-by: CosmicCoincidence <cosmiccoincidence1991@gmail.com>
1 parent 6d95aab commit c63d426

File tree

78 files changed

+25702
-9496
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+25702
-9496
lines changed
1.78 MB
Binary file not shown.

Assets/Art/Models/Structures/Doors/SS13Airlocks.fbx.meta

Lines changed: 97 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
2+
3+
Shader "Custom/GlassBackfaceCull"
4+
{
5+
6+
Properties
7+
{
8+
_MainTex("Texture", 2D) = "white" {}
9+
_Color("Color", Color) = (1, 1, 1, 1)
10+
_EdgeColor("Edge Color", Color) = (1, 1, 1, 1)
11+
_EdgeThickness("Silouette Dropoff Rate", float) = 1.0
12+
}
13+
14+
SubShader
15+
{
16+
Tags
17+
{
18+
"Queue" = "Transparent"
19+
}
20+
21+
Pass
22+
{
23+
ZWrite Off
24+
Blend SrcAlpha OneMinusSrcAlpha // standard alpha blending
25+
26+
CGPROGRAM
27+
28+
#pragma vertex vert
29+
#pragma fragment frag
30+
31+
// Properties
32+
sampler2D _MainTex;
33+
uniform float4 _Color;
34+
uniform float4 _EdgeColor;
35+
uniform float _EdgeThickness;
36+
37+
struct vertexInput
38+
{
39+
float4 vertex : POSITION;
40+
float3 normal : NORMAL;
41+
float3 texCoord : TEXCOORD0;
42+
};
43+
44+
struct vertexOutput
45+
{
46+
float4 pos : SV_POSITION;
47+
float3 normal : NORMAL;
48+
float3 texCoord : TEXCOORD0;
49+
float3 viewDir : TEXCOORD1;
50+
};
51+
52+
vertexOutput vert(vertexInput input)
53+
{
54+
vertexOutput output;
55+
56+
// convert input to world space
57+
output.pos = UnityObjectToClipPos(input.vertex);
58+
float4 normal4 = float4(input.normal, 0.0);
59+
output.normal = normalize(mul(normal4, unity_WorldToObject).xyz);
60+
output.viewDir = normalize(_WorldSpaceCameraPos - mul(unity_ObjectToWorld, input.vertex).xyz);
61+
62+
output.texCoord = input.texCoord;
63+
64+
return output;
65+
}
66+
67+
float4 frag(vertexOutput input) : COLOR
68+
{
69+
// sample texture for color
70+
float4 texColor = tex2D(_MainTex, input.texCoord.xy);
71+
72+
// apply silouette equation
73+
// based on how close normal is to being orthogonal to view vector
74+
// dot product is smaller the smaller the angle bw the vectors is
75+
// close to edge = closer to 0
76+
// far from edge = closer to 1
77+
float edgeFactor = abs(dot(input.viewDir, input.normal));
78+
79+
// apply edgeFactor to Albedo color & EdgeColor
80+
float oneMinusEdge = 1.0 - edgeFactor;
81+
float3 rgb = (_Color.rgb * edgeFactor) + (_EdgeColor * oneMinusEdge);
82+
rgb = min(float3(1, 1, 1), rgb); // clamp to real color vals
83+
rgb = rgb * texColor.rgb;
84+
85+
// apply edgeFactor to Albedo transparency & EdgeColor transparency
86+
// close to edge = more opaque EdgeColor & more transparent Albedo
87+
float opacity = min(1.0, _Color.a / edgeFactor);
88+
89+
// opacity^thickness means the edge color will be near 0 away from the edges
90+
// and escalate quickly in opacity towards the edges
91+
opacity = pow(opacity, _EdgeThickness);
92+
opacity = opacity * texColor.a;
93+
94+
float4 output = float4(rgb, opacity);
95+
return output;
96+
}
97+
98+
ENDCG
99+
}
100+
}
101+
102+
}

Assets/Art/Shaders/GlassBackfaceCull.shader.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)