Skip to content

Commit

Permalink
Adds 14 types of airlocks (#887)
Browse files Browse the repository at this point in the history
Does what the title says!

Co-authored-by: CosmicCoincidence <[email protected]>
  • Loading branch information
EikoBiko and cosmiccoincidence authored Mar 30, 2022
1 parent 6d95aab commit c63d426
Show file tree
Hide file tree
Showing 78 changed files with 25,702 additions and 9,496 deletions.
Binary file not shown.
97 changes: 97 additions & 0 deletions Assets/Art/Models/Structures/Doors/SS13Airlocks.fbx.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 102 additions & 0 deletions Assets/Art/Shaders/GlassBackfaceCull.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

Shader "Custom/GlassBackfaceCull"
{

Properties
{
_MainTex("Texture", 2D) = "white" {}
_Color("Color", Color) = (1, 1, 1, 1)
_EdgeColor("Edge Color", Color) = (1, 1, 1, 1)
_EdgeThickness("Silouette Dropoff Rate", float) = 1.0
}

SubShader
{
Tags
{
"Queue" = "Transparent"
}

Pass
{
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha // standard alpha blending

CGPROGRAM

#pragma vertex vert
#pragma fragment frag

// Properties
sampler2D _MainTex;
uniform float4 _Color;
uniform float4 _EdgeColor;
uniform float _EdgeThickness;

struct vertexInput
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float3 texCoord : TEXCOORD0;
};

struct vertexOutput
{
float4 pos : SV_POSITION;
float3 normal : NORMAL;
float3 texCoord : TEXCOORD0;
float3 viewDir : TEXCOORD1;
};

vertexOutput vert(vertexInput input)
{
vertexOutput output;

// convert input to world space
output.pos = UnityObjectToClipPos(input.vertex);
float4 normal4 = float4(input.normal, 0.0);
output.normal = normalize(mul(normal4, unity_WorldToObject).xyz);
output.viewDir = normalize(_WorldSpaceCameraPos - mul(unity_ObjectToWorld, input.vertex).xyz);

output.texCoord = input.texCoord;

return output;
}

float4 frag(vertexOutput input) : COLOR
{
// sample texture for color
float4 texColor = tex2D(_MainTex, input.texCoord.xy);

// apply silouette equation
// based on how close normal is to being orthogonal to view vector
// dot product is smaller the smaller the angle bw the vectors is
// close to edge = closer to 0
// far from edge = closer to 1
float edgeFactor = abs(dot(input.viewDir, input.normal));

// apply edgeFactor to Albedo color & EdgeColor
float oneMinusEdge = 1.0 - edgeFactor;
float3 rgb = (_Color.rgb * edgeFactor) + (_EdgeColor * oneMinusEdge);
rgb = min(float3(1, 1, 1), rgb); // clamp to real color vals
rgb = rgb * texColor.rgb;

// apply edgeFactor to Albedo transparency & EdgeColor transparency
// close to edge = more opaque EdgeColor & more transparent Albedo
float opacity = min(1.0, _Color.a / edgeFactor);

// opacity^thickness means the edge color will be near 0 away from the edges
// and escalate quickly in opacity towards the edges
opacity = pow(opacity, _EdgeThickness);
opacity = opacity * texColor.a;

float4 output = float4(rgb, opacity);
return output;
}

ENDCG
}
}

}
9 changes: 9 additions & 0 deletions Assets/Art/Shaders/GlassBackfaceCull.shader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c63d426

Please sign in to comment.