Merge branch 'develop' into feature-text
commit
a9b05a677e
@ -1,130 +0,0 @@
|
||||
Shader "ConformalDecals/Feature/Bumped"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[Header(Texture Maps)]
|
||||
_Decal("Decal Texture", 2D) = "gray" {}
|
||||
_DecalBumpMap("Decal Bump Map", 2D) = "bump" {}
|
||||
|
||||
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
|
||||
_DecalOpacity("Opacity", Range(0,1) ) = 1
|
||||
_Background("Background Color", Color) = (0.9,0.9,0.9,0.7)
|
||||
|
||||
[Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull", int) = 2
|
||||
[Toggle(DECAL_PREVIEW)] _Preview ("Preview", int) = 0
|
||||
|
||||
[Header(Effects)]
|
||||
[PerRendererData]_Opacity("_Opacity", Range(0,1) ) = 1
|
||||
[PerRendererData]_Color("_Color", Color) = (1,1,1,1)
|
||||
[PerRendererData]_RimFalloff("_RimFalloff", Range(0.01,5) ) = 0.1
|
||||
[PerRendererData]_RimColor("_RimColor", Color) = (0,0,0,0)
|
||||
[PerRendererData]_UnderwaterFogFactor ("Underwater Fog Factor", Range(0,1)) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Geometry+100" }
|
||||
Cull [_Cull]
|
||||
Ztest LEqual
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD"
|
||||
Tags { "LightMode" = "ForwardBase" }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_forward
|
||||
#pragma fragment frag_forward
|
||||
|
||||
#pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap
|
||||
#pragma multi_compile DECAL_PROJECT DECAL_PREVIEW
|
||||
|
||||
sampler2D _Decal;
|
||||
sampler2D _DecalBumpMap;
|
||||
|
||||
float4 _Decal_ST;
|
||||
float4 _DecalBumpMap_ST;
|
||||
|
||||
float _RimFalloff;
|
||||
float4 _RimColor;
|
||||
|
||||
#define DECAL_NORMAL
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "LightingKSP.cginc"
|
||||
#include "DecalsCommon.cginc"
|
||||
|
||||
void surf (DecalSurfaceInput IN, inout SurfaceOutput o)
|
||||
{
|
||||
float4 color = tex2D(_Decal, IN.uv_decal);
|
||||
float3 normal = UnpackNormalDXT5nm(tex2D(_DecalBumpMap, IN.uv_bump));
|
||||
|
||||
decalClipAlpha(color.a - _Cutoff);
|
||||
|
||||
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal));
|
||||
float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
|
||||
|
||||
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
||||
o.Alpha = color.a * _DecalOpacity;
|
||||
o.Emission = emission;
|
||||
o.Normal = normal;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD"
|
||||
Tags { "LightMode" = "ForwardAdd" }
|
||||
Blend One One
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_forward
|
||||
#pragma fragment frag_forward
|
||||
|
||||
#pragma multi_compile_fwdadd nolightmap nodirlightmap nodynlightmap
|
||||
#pragma multi_compile DECAL_PROJECT DECAL_PREVIEW
|
||||
|
||||
sampler2D _Decal;
|
||||
sampler2D _DecalBumpMap;
|
||||
|
||||
float4 _Decal_ST;
|
||||
float4 _DecalBumpMap_ST;
|
||||
|
||||
float _RimFalloff;
|
||||
float4 _RimColor;
|
||||
|
||||
#define DECAL_NORMAL
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "LightingKSP.cginc"
|
||||
#include "DecalsCommon.cginc"
|
||||
|
||||
void surf (DecalSurfaceInput IN, inout SurfaceOutput o)
|
||||
{
|
||||
float4 color = tex2D(_Decal, IN.uv_decal);
|
||||
float3 normal = UnpackNormal(tex2D(_DecalBumpMap, IN.uv_bump));
|
||||
|
||||
decalClipAlpha(color.a - _Cutoff);
|
||||
|
||||
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal));
|
||||
float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
|
||||
|
||||
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
||||
o.Alpha = color.a * _DecalOpacity;
|
||||
o.Emission = emission;
|
||||
o.Normal = normal;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// shadow casting support
|
||||
UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"
|
||||
}
|
||||
}
|
@ -1,143 +0,0 @@
|
||||
Shader "ConformalDecals/Paint/Diffuse"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[Header(Texture Maps)]
|
||||
_Decal("Decal Texture", 2D) = "gray" {}
|
||||
_BumpMap("Bump Map", 2D) = "bump" {}
|
||||
|
||||
_EdgeWearStrength("Edge Wear Strength", Range(0,500)) = 100
|
||||
_EdgeWearOffset("Edge Wear Offset", Range(0,1)) = 0.1
|
||||
|
||||
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
|
||||
_DecalOpacity("Opacity", Range(0,1) ) = 1
|
||||
_Background("Background Color", Color) = (0.9,0.9,0.9,0.7)
|
||||
|
||||
[Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull", int) = 2
|
||||
[Toggle(DECAL_PREVIEW)] _Preview ("Preview", int) = 0
|
||||
|
||||
[Header(Effects)]
|
||||
[PerRendererData]_Opacity("_Opacity", Range(0,1) ) = 1
|
||||
[PerRendererData]_Color("_Color", Color) = (1,1,1,1)
|
||||
[PerRendererData]_RimFalloff("_RimFalloff", Range(0.01,5) ) = 0.1
|
||||
[PerRendererData]_RimColor("_RimColor", Color) = (0,0,0,0)
|
||||
[PerRendererData]_UnderwaterFogFactor ("Underwater Fog Factor", Range(0,1)) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Geometry+100" }
|
||||
Cull [_Cull]
|
||||
Ztest LEqual
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD"
|
||||
Tags { "LightMode" = "ForwardBase" }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_forward
|
||||
#pragma fragment frag_forward
|
||||
|
||||
#pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap
|
||||
#pragma multi_compile __ DECAL_PREVIEW
|
||||
|
||||
sampler2D _Decal;
|
||||
|
||||
float4 _Decal_ST;
|
||||
|
||||
float _EdgeWearStrength;
|
||||
float _EdgeWearOffset;
|
||||
|
||||
float _RimFalloff;
|
||||
float4 _RimColor;
|
||||
|
||||
#define DECAL_BASE_NORMAL
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "LightingKSP.cginc"
|
||||
#include "DecalsCommon.cginc"
|
||||
|
||||
void surf (DecalSurfaceInput IN, inout SurfaceOutput o)
|
||||
{
|
||||
float4 color = tex2D(_Decal, IN.uv_decal);
|
||||
|
||||
decalClipAlpha(color.a - _Cutoff);
|
||||
|
||||
float3 normal = IN.normal;
|
||||
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal));
|
||||
float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
|
||||
|
||||
float wearFactor = 1 - normal.z;
|
||||
float wearFactorAlpha = saturate(_EdgeWearStrength * wearFactor);
|
||||
|
||||
color.a *= saturate(1 + _EdgeWearOffset - saturate(_EdgeWearStrength * wearFactor));
|
||||
|
||||
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
||||
o.Alpha = color.a * _DecalOpacity;
|
||||
o.Emission = emission;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD"
|
||||
Tags { "LightMode" = "ForwardAdd" }
|
||||
Blend One One
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_forward
|
||||
#pragma fragment frag_forward
|
||||
|
||||
#pragma multi_compile_fwdadd nolightmap nodirlightmap nodynlightmap
|
||||
#pragma multi_compile __ DECAL_PREVIEW
|
||||
|
||||
sampler2D _Decal;
|
||||
|
||||
float4 _Decal_ST;
|
||||
|
||||
float _EdgeWearStrength;
|
||||
float _EdgeWearOffset;
|
||||
|
||||
float _RimFalloff;
|
||||
float4 _RimColor;
|
||||
|
||||
#define DECAL_BASE_NORMAL
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "LightingKSP.cginc"
|
||||
#include "DecalsCommon.cginc"
|
||||
|
||||
void surf (DecalSurfaceInput IN, inout SurfaceOutput o)
|
||||
{
|
||||
float4 color = tex2D(_Decal, IN.uv_decal);
|
||||
|
||||
decalClipAlpha(color.a - _Cutoff);
|
||||
|
||||
float3 normal = IN.normal;
|
||||
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal));
|
||||
float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
|
||||
|
||||
float wearFactor = 1 - normal.z;
|
||||
float wearFactorAlpha = saturate(_EdgeWearStrength * wearFactor);
|
||||
|
||||
color.a *= saturate(1 + _EdgeWearOffset - saturate(_EdgeWearStrength * wearFactor));
|
||||
|
||||
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
||||
o.Alpha = color.a * _DecalOpacity;
|
||||
o.Emission = emission;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// shadow casting support
|
||||
UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"
|
||||
}
|
||||
}
|
@ -1,159 +0,0 @@
|
||||
Shader "ConformalDecals/Paint/DiffuseSDF"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[Header(Texture Maps)]
|
||||
_Decal("Decal Texture", 2D) = "gray" {}
|
||||
_BumpMap("Bump Map", 2D) = "bump" {}
|
||||
|
||||
_EdgeWearStrength("Edge Wear Strength", Range(0,500)) = 100
|
||||
_EdgeWearOffset("Edge Wear Offset", Range(0,1)) = 0.1
|
||||
|
||||
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
|
||||
_Smoothness ("SDF smoothness", Range(0,1)) = 0.15
|
||||
_SmoothnessMipScale ("Smoothness fadeout", Range(0,1)) = 0.1
|
||||
_DecalOpacity("Opacity", Range(0,1) ) = 1
|
||||
_Background("Background Color", Color) = (0.9,0.9,0.9,0.7)
|
||||
|
||||
[Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull", int) = 2
|
||||
[Toggle(DECAL_PREVIEW)] _Preview ("Preview", int) = 0
|
||||
|
||||
[Header(Effects)]
|
||||
[PerRendererData]_Opacity("_Opacity", Range(0,1) ) = 1
|
||||
[PerRendererData]_Color("_Color", Color) = (1,1,1,1)
|
||||
[PerRendererData]_RimFalloff("_RimFalloff", Range(0.01,5) ) = 0.1
|
||||
[PerRendererData]_RimColor("_RimColor", Color) = (0,0,0,0)
|
||||
[PerRendererData]_UnderwaterFogFactor ("Underwater Fog Factor", Range(0,1)) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Geometry+100" }
|
||||
Cull [_Cull]
|
||||
Ztest LEqual
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD"
|
||||
Tags { "LightMode" = "ForwardBase" }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_forward
|
||||
#pragma fragment frag_forward
|
||||
|
||||
#pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap
|
||||
#pragma multi_compile __ DECAL_PREVIEW
|
||||
|
||||
sampler2D _Decal;
|
||||
|
||||
float4 _Decal_ST;
|
||||
float4 _Decal_TexelSize;
|
||||
|
||||
float _Smoothness;
|
||||
float _SmoothnessMipScale;
|
||||
|
||||
float _EdgeWearStrength;
|
||||
float _EdgeWearOffset;
|
||||
|
||||
float _RimFalloff;
|
||||
float4 _RimColor;
|
||||
|
||||
#define DECAL_BASE_NORMAL
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "LightingKSP.cginc"
|
||||
#include "DecalsCommon.cginc"
|
||||
|
||||
void surf (DecalSurfaceInput IN, inout SurfaceOutput o)
|
||||
{
|
||||
float4 color = tex2D(_Decal, IN.uv_decal);
|
||||
float3 normal = IN.normal;
|
||||
|
||||
float smoothScale = (1 - saturate(1-(CalcMipLevel(IN.uv_decal * _Decal_TexelSize.zw) * _SmoothnessMipScale))) / 2;
|
||||
color.a = smoothstep(_Cutoff - smoothScale, saturate(_Smoothness + smoothScale + _Cutoff), color.a);
|
||||
|
||||
decalClipAlpha(color.a);
|
||||
|
||||
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal));
|
||||
float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
|
||||
|
||||
float wearFactor = 1 - normal.z;
|
||||
float wearFactorAlpha = saturate(_EdgeWearStrength * wearFactor);
|
||||
|
||||
color.a *= saturate(1 + _EdgeWearOffset - saturate(_EdgeWearStrength * wearFactor));
|
||||
|
||||
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
||||
o.Alpha = color.a * _DecalOpacity;
|
||||
o.Emission = emission;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD"
|
||||
Tags { "LightMode" = "ForwardAdd" }
|
||||
Blend One One
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_forward
|
||||
#pragma fragment frag_forward
|
||||
|
||||
#pragma multi_compile_fwdadd nolightmap nodirlightmap nodynlightmap
|
||||
#pragma multi_compile __ DECAL_PREVIEW
|
||||
|
||||
sampler2D _Decal;
|
||||
|
||||
float4 _Decal_ST;
|
||||
float4 _Decal_TexelSize;
|
||||
|
||||
float _Smoothness;
|
||||
float _SmoothnessMipScale;
|
||||
|
||||
float _EdgeWearStrength;
|
||||
float _EdgeWearOffset;
|
||||
|
||||
float _RimFalloff;
|
||||
float4 _RimColor;
|
||||
|
||||
#define DECAL_BASE_NORMAL
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "LightingKSP.cginc"
|
||||
#include "DecalsCommon.cginc"
|
||||
|
||||
void surf (DecalSurfaceInput IN, inout SurfaceOutput o)
|
||||
{
|
||||
float4 color = tex2D(_Decal, IN.uv_decal);
|
||||
float3 normal = IN.normal;
|
||||
|
||||
float smoothScale = (1 - saturate(1-(CalcMipLevel(IN.uv_decal * _Decal_TexelSize.zw) * _SmoothnessMipScale))) / 2;
|
||||
color.a = smoothstep(_Cutoff - smoothScale, saturate(_Smoothness + smoothScale + _Cutoff), color.a);
|
||||
|
||||
decalClipAlpha(color.a);
|
||||
|
||||
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal));
|
||||
float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
|
||||
|
||||
float wearFactor = 1 - normal.z;
|
||||
float wearFactorAlpha = saturate(_EdgeWearStrength * wearFactor);
|
||||
|
||||
color.a *= saturate(1 + _EdgeWearOffset - saturate(_EdgeWearStrength * wearFactor));
|
||||
|
||||
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
||||
o.Alpha = color.a * _DecalOpacity;
|
||||
o.Emission = emission;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// shadow casting support
|
||||
UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"
|
||||
}
|
||||
}
|
@ -1,165 +0,0 @@
|
||||
Shader "ConformalDecals/Paint/Specular"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[Header(Texture Maps)]
|
||||
_Decal("Decal Texture", 2D) = "gray" {}
|
||||
_BumpMap("Bump Map", 2D) = "bump" {}
|
||||
_SpecMap("Specular Map", 2D) = "black" {}
|
||||
|
||||
_EdgeWearStrength("Edge Wear Strength", Range(0,500)) = 100
|
||||
_EdgeWearOffset("Edge Wear Offset", Range(0,1)) = 0.1
|
||||
|
||||
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
|
||||
_DecalOpacity("Opacity", Range(0,1) ) = 1
|
||||
_Background("Background Color", Color) = (0.9,0.9,0.9,0.7)
|
||||
|
||||
[Header(Specularity)]
|
||||
_SpecColor ("_SpecColor", Color) = (0.25, 0.25, 0.25, 1)
|
||||
_Shininess ("Shininess", Range (0.03, 10)) = 0.3
|
||||
|
||||
[Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull", int) = 2
|
||||
[Toggle(DECAL_PREVIEW)] _Preview ("Preview", int) = 0
|
||||
|
||||
[Header(Effects)]
|
||||
[PerRendererData]_Opacity("_Opacity", Range(0,1) ) = 1
|
||||
[PerRendererData]_Color("_Color", Color) = (1,1,1,1)
|
||||
[PerRendererData]_RimFalloff("_RimFalloff", Range(0.01,5) ) = 0.1
|
||||
[PerRendererData]_RimColor("_RimColor", Color) = (0,0,0,0)
|
||||
[PerRendererData]_UnderwaterFogFactor ("Underwater Fog Factor", Range(0,1)) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Geometry+100" }
|
||||
Cull [_Cull]
|
||||
Ztest LEqual
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD"
|
||||
Tags { "LightMode" = "ForwardBase" }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_forward
|
||||
#pragma fragment frag_forward
|
||||
|
||||
#pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap
|
||||
#pragma multi_compile __ DECAL_PREVIEW
|
||||
|
||||
sampler2D _Decal;
|
||||
sampler2D _SpecMap;
|
||||
|
||||
float4 _Decal_ST;
|
||||
float4 _SpecMap_ST;
|
||||
|
||||
float _EdgeWearStrength;
|
||||
float _EdgeWearOffset;
|
||||
|
||||
half _Shininess;
|
||||
|
||||
float _RimFalloff;
|
||||
float4 _RimColor;
|
||||
|
||||
#define DECAL_BASE_NORMAL
|
||||
#define DECAL_SPECULAR
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "LightingKSP.cginc"
|
||||
#include "DecalsCommon.cginc"
|
||||
|
||||
void surf (DecalSurfaceInput IN, inout SurfaceOutput o)
|
||||
{
|
||||
float4 color = tex2D(_Decal, IN.uv_decal);
|
||||
float3 specular = tex2D(_SpecMap, IN.uv_spec);
|
||||
|
||||
decalClipAlpha(color.a - _Cutoff);
|
||||
|
||||
float3 normal = IN.normal;
|
||||
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal));
|
||||
float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
|
||||
|
||||
float wearFactor = 1 - normal.z;
|
||||
float wearFactorAlpha = saturate(_EdgeWearStrength * wearFactor);
|
||||
|
||||
color.a *= saturate(1 + _EdgeWearOffset - saturate(_EdgeWearStrength * wearFactor));
|
||||
color.a *= _DecalOpacity;
|
||||
|
||||
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
||||
o.Alpha = color.a;
|
||||
o.Emission = emission;
|
||||
o.Specular = _Shininess;
|
||||
o.Gloss = specular.r * color.a;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD"
|
||||
Tags { "LightMode" = "ForwardAdd" }
|
||||
Blend One One
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_forward
|
||||
#pragma fragment frag_forward
|
||||
|
||||
#pragma multi_compile_fwdadd nolightmap nodirlightmap nodynlightmap
|
||||
#pragma multi_compile __ DECAL_PREVIEW
|
||||
|
||||
sampler2D _Decal;
|
||||
sampler2D _SpecMap;
|
||||
|
||||
float4 _Decal_ST;
|
||||
float4 _SpecMap_ST;
|
||||
|
||||
float _EdgeWearStrength;
|
||||
float _EdgeWearOffset;
|
||||
|
||||
half _Shininess;
|
||||
|
||||
float _RimFalloff;
|
||||
float4 _RimColor;
|
||||
|
||||
#define DECAL_BASE_NORMAL
|
||||
#define DECAL_SPECULAR
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "LightingKSP.cginc"
|
||||
#include "DecalsCommon.cginc"
|
||||
|
||||
void surf (DecalSurfaceInput IN, inout SurfaceOutput o)
|
||||
{
|
||||
float4 color = tex2D(_Decal, IN.uv_decal);
|
||||
float3 specular = tex2D(_SpecMap, IN.uv_spec);
|
||||
float3 normal = IN.normal;
|
||||
|
||||
decalClipAlpha(color.a - _Cutoff);
|
||||
|
||||
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal));
|
||||
float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
|
||||
|
||||
float wearFactor = 1 - normal.z;
|
||||
float wearFactorAlpha = saturate(_EdgeWearStrength * wearFactor);
|
||||
|
||||
color.a *= saturate(1 + _EdgeWearOffset - saturate(_EdgeWearStrength * wearFactor));
|
||||
|
||||
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
||||
o.Alpha = color.a * _DecalOpacity;
|
||||
o.Emission = emission;
|
||||
o.Specular = _Shininess;
|
||||
o.Gloss = specular.r;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// shadow casting support
|
||||
UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"
|
||||
}
|
||||
}
|
@ -1,180 +0,0 @@
|
||||
Shader "ConformalDecals/Paint/SpecularSDF"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[Header(Texture Maps)]
|
||||
_Decal("Decal Texture", 2D) = "gray" {}
|
||||
_BumpMap("Bump Map", 2D) = "bump" {}
|
||||
_SpecMap("Specular Map", 2D) = "black" {}
|
||||
|
||||
_EdgeWearStrength("Edge Wear Strength", Range(0,500)) = 100
|
||||
_EdgeWearOffset("Edge Wear Offset", Range(0,1)) = 0.1
|
||||
|
||||
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
|
||||
_Smoothness ("SDF smoothness", Range(0,1)) = 0.15
|
||||
_SmoothnessMipScale ("Smoothness fadeout", Range(0,1)) = 0.1
|
||||
_DecalOpacity("Opacity", Range(0,1) ) = 1
|
||||
_Background("Background Color", Color) = (0.9,0.9,0.9,0.7)
|
||||
|
||||
[Header(Specularity)]
|
||||
_SpecColor ("_SpecColor", Color) = (0.25, 0.25, 0.25, 1)
|
||||
_Shininess ("Shininess", Range (0.03, 10)) = 0.3
|
||||
|
||||
[Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull", int) = 2
|
||||
[Toggle(DECAL_PREVIEW)] _Preview ("Preview", int) = 0
|
||||
|
||||
[Header(Effects)]
|
||||
[PerRendererData]_Opacity("_Opacity", Range(0,1) ) = 1
|
||||
[PerRendererData]_Color("_Color", Color) = (1,1,1,1)
|
||||
[PerRendererData]_RimFalloff("_RimFalloff", Range(0.01,5) ) = 0.1
|
||||
[PerRendererData]_RimColor("_RimColor", Color) = (0,0,0,0)
|
||||
[PerRendererData]_UnderwaterFogFactor ("Underwater Fog Factor", Range(0,1)) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Geometry+100" }
|
||||
Cull [_Cull]
|
||||
Ztest LEqual
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD"
|
||||
Tags { "LightMode" = "ForwardBase" }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_forward
|
||||
#pragma fragment frag_forward
|
||||
|
||||
#pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap
|
||||
#pragma multi_compile __ DECAL_PREVIEW
|
||||
|
||||
sampler2D _Decal;
|
||||
sampler2D _SpecMap;
|
||||
|
||||
float4 _Decal_ST;
|
||||
float4 _Decal_TexelSize;
|
||||
float4 _SpecMap_ST;
|
||||
|
||||
float _Smoothness;
|
||||
float _SmoothnessMipScale;
|
||||
|
||||
float _EdgeWearStrength;
|
||||
float _EdgeWearOffset;
|
||||
|
||||
half _Shininess;
|
||||
|
||||
float _RimFalloff;
|
||||
float4 _RimColor;
|
||||
|
||||
#define DECAL_BASE_NORMAL
|
||||
#define DECAL_SPECULAR
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "LightingKSP.cginc"
|
||||
#include "DecalsCommon.cginc"
|
||||
|
||||
void surf (DecalSurfaceInput IN, inout SurfaceOutput o)
|
||||
{
|
||||
float4 color = tex2D(_Decal, IN.uv_decal);
|
||||
float3 specular = tex2D(_SpecMap, IN.uv_spec);
|
||||
float3 normal = IN.normal;
|
||||
|
||||
float smoothScale = (1 - saturate(1-(CalcMipLevel(IN.uv_decal * _Decal_TexelSize.zw) * _SmoothnessMipScale))) / 2;
|
||||
color.a = smoothstep(_Cutoff - smoothScale, saturate(_Smoothness + smoothScale + _Cutoff), color.a);
|
||||
|
||||
decalClipAlpha(color.a);
|
||||
|
||||
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal));
|
||||
float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
|
||||
|
||||
float wearFactor = 1 - normal.z;
|
||||
float wearFactorAlpha = saturate(_EdgeWearStrength * wearFactor);
|
||||
|
||||
color.a *= saturate(1 + _EdgeWearOffset - saturate(_EdgeWearStrength * wearFactor));
|
||||
|
||||
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
||||
o.Alpha = color.a * _DecalOpacity;
|
||||
o.Emission = emission;
|
||||
o.Specular = _Shininess;
|
||||
o.Gloss = specular.r;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD"
|
||||
Tags { "LightMode" = "ForwardAdd" }
|
||||
Blend One One
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_forward
|
||||
#pragma fragment frag_forward
|
||||
|
||||
#pragma multi_compile_fwdadd nolightmap nodirlightmap nodynlightmap
|
||||
#pragma multi_compile __ DECAL_PREVIEW
|
||||
|
||||
sampler2D _Decal;
|
||||
sampler2D _SpecMap;
|
||||
|
||||
float4 _Decal_ST;
|
||||
float4 _Decal_TexelSize;
|
||||
float4 _SpecMap_ST;
|
||||
|
||||
float _Smoothness;
|
||||
float _SmoothnessMipScale;
|
||||
|
||||
float _EdgeWearStrength;
|
||||
float _EdgeWearOffset;
|
||||
|
||||
half _Shininess;
|
||||
|
||||
float _RimFalloff;
|
||||
float4 _RimColor;
|
||||
|
||||
#define DECAL_BASE_NORMAL
|
||||
#define DECAL_SPECULAR
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "LightingKSP.cginc"
|
||||
#include "DecalsCommon.cginc"
|
||||
|
||||
void surf (DecalSurfaceInput IN, inout SurfaceOutput o)
|
||||
{
|
||||
float4 color = tex2D(_Decal, IN.uv_decal);
|
||||
float3 specular = tex2D(_SpecMap, IN.uv_spec);
|
||||
float3 normal = IN.normal;
|
||||
|
||||
float smoothScale = (1 - saturate(1-(CalcMipLevel(IN.uv_decal * _Decal_TexelSize.zw) * _SmoothnessMipScale))) / 2;
|
||||
color.a = smoothstep(_Cutoff - smoothScale, saturate(_Smoothness + smoothScale + _Cutoff), color.a);
|
||||
|
||||
decalClipAlpha(color.a);
|
||||
|
||||
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal));
|
||||
float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
|
||||
|
||||
float wearFactor = 1 - normal.z;
|
||||
float wearFactorAlpha = saturate(_EdgeWearStrength * wearFactor);
|
||||
|
||||
color.a *= saturate(1 + _EdgeWearOffset - saturate(_EdgeWearStrength * wearFactor));
|
||||
|
||||
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
||||
o.Alpha = color.a * _DecalOpacity;
|
||||
o.Emission = emission;
|
||||
o.Specular = _Shininess;
|
||||
o.Gloss = specular.r;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// shadow casting support
|
||||
UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
#ifndef DECALS_LIGHTING_INCLUDED
|
||||
#define DECALS_LIGHTING_INCLUDED
|
||||
|
||||
// modifed version of the KSP BlinnPhong because it does some weird things
|
||||
inline fixed4 LightingBlinnPhongDecal(SurfaceOutput s, fixed3 lightDir, half3 viewDir, fixed atten)
|
||||
{
|
||||
s.Normal = normalize(s.Normal);
|
||||
half3 h = normalize(lightDir + viewDir);
|
||||
|
||||
fixed diff = max(0, dot(s.Normal, lightDir));
|
||||
|
||||
float nh = max(0, dot(s.Normal, h));
|
||||
float spec = pow(nh, s.Specular*128.0) * s.Gloss;
|
||||
|
||||
fixed4 c = 0;
|
||||
c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * _SpecColor.rgb * spec) * (atten);
|
||||
return c;
|
||||
}
|
||||
|
||||
// KSP underwater fog function
|
||||
float4 UnderwaterFog(float3 worldPos, float3 color)
|
||||
{
|
||||
float3 toPixel = worldPos - _LocalCameraPos.xyz;
|
||||
float toPixelLength = length(toPixel);
|
||||
|
||||
float underwaterDetection = _UnderwaterFogFactor * _LocalCameraDir.w;
|
||||
float albedoLerpValue = underwaterDetection * (_UnderwaterMaxAlbedoFog * saturate(toPixelLength * _UnderwaterAlbedoDistanceScalar));
|
||||
float alphaFactor = 1 - underwaterDetection * (_UnderwaterMaxAlphaFog * saturate((toPixelLength - _UnderwaterMinAlphaFogDistance) * _UnderwaterAlphaDistanceScalar));
|
||||
|
||||
return float4(lerp(color, _UnderwaterFogColor.rgb, albedoLerpValue), alphaFactor);
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,183 @@
|
||||
#ifndef DECALS_SURFACE_INCLUDED
|
||||
#define DECALS_SURFACE_INCLUDED
|
||||
|
||||
#include "DecalsCommon.cginc"
|
||||
#include "DecalsLighting.cginc"
|
||||
|
||||
// declare surf function,
|
||||
// this must be defined in any shader using this cginc
|
||||
void surf (DecalSurfaceInput IN, inout SurfaceOutput o);
|
||||
|
||||
v2f vert_forward(appdata_decal v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_INITIALIZE_OUTPUT(v2f,o);
|
||||
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.normal = v.normal;
|
||||
|
||||
#ifdef DECAL_PREVIEW
|
||||
o.uv_decal = v.texcoord;
|
||||
#else
|
||||
o.uv_decal = mul (_ProjectionMatrix, v.vertex);
|
||||
#endif //DECAL_PREVIEW
|
||||
|
||||
#ifdef DECAL_BASE_NORMAL
|
||||
o.uv_base = TRANSFORM_TEX(v.texcoord, _BumpMap);
|
||||
#endif //DECAL_BASE_NORMAL
|
||||
|
||||
float3 worldPosition = mul(unity_ObjectToWorld, v.vertex).xyz;
|
||||
float3 worldNormal = UnityObjectToWorldNormal(v.normal);
|
||||
|
||||
#if defined(DECAL_BASE_NORMAL) || defined(DECAL_PREVIEW)
|
||||
// use tangent of base geometry
|
||||
fixed3 worldTangent = UnityObjectToWorldDir(v.tangent.xyz);
|
||||
fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w;
|
||||
fixed3 worldBinormal = cross(worldNormal, worldTangent) * tangentSign;
|
||||
#else
|
||||
// use tangent of projector
|
||||
fixed3 decalTangent = UnityObjectToWorldDir(_DecalTangent);
|
||||
fixed3 worldBinormal = cross(decalTangent, worldNormal);
|
||||
fixed3 worldTangent = cross(worldNormal, worldBinormal);
|
||||
#endif //defined(DECAL_BASE_NORMAL) || defined(DECAL_PREVIEW)
|
||||
|
||||
o.tSpace0 = float4(worldTangent.x, worldBinormal.x, worldNormal.x, worldPosition.x);
|
||||
o.tSpace1 = float4(worldTangent.y, worldBinormal.y, worldNormal.y, worldPosition.y);
|
||||
o.tSpace2 = float4(worldTangent.z, worldBinormal.z, worldNormal.z, worldPosition.z);
|
||||
|
||||
// forward base pass specific lighting code
|
||||
#ifdef UNITY_PASS_FORWARDBASE
|
||||
// SH/ambient light
|
||||
#if UNITY_SHOULD_SAMPLE_SH
|
||||
float3 shlight = ShadeSH9 (float4(worldNormal,1.0));
|
||||
o.vlight = shlight;
|
||||
#else
|
||||
o.vlight = 0.0;
|
||||
#endif // UNITY_SHOULD_SAMPLE_SH
|
||||
|
||||
// vertex light
|
||||
#ifdef VERTEXLIGHT_ON
|
||||
o.vlight += Shade4PointLights (
|
||||
unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0,
|
||||
unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb,
|
||||
unity_4LightAtten0, worldPosition, worldNormal );
|
||||
#endif // VERTEXLIGHT_ON
|
||||
#endif // UNITY_PASS_FORWARDBASE
|
||||
|
||||
// pass shadow and, possibly, light cookie coordinates to pixel shader
|
||||
UNITY_TRANSFER_LIGHTING(o, 0.0);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag_forward(v2f IN) : SV_Target
|
||||
{
|
||||
#ifdef DECAL_PREVIEW
|
||||
fixed4 uv_projected = IN.uv_decal;
|
||||
#else
|
||||
// perform decal projection
|
||||
fixed4 uv_projected = UNITY_PROJ_COORD(IN.uv_decal);
|
||||
|
||||
clip(uv_projected.xyz + CLIP_MARGIN);
|
||||
clip(CLIP_MARGIN + (1-uv_projected.xyz));
|
||||
#endif //DECAL_PREVIEW
|
||||
|
||||
// declare data
|
||||
DecalSurfaceInput i;
|
||||
SurfaceOutput o;
|
||||
|
||||
// setup world-space TBN vectors
|
||||
UNITY_EXTRACT_TBN(IN);
|
||||
|
||||
float3 worldPosition = float3(IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w);
|
||||
float3 worldTangent = float3(IN.tSpace0.x, IN.tSpace1.x, IN.tSpace2.x);
|
||||
|
||||
// setup world-space light and view direction vectors
|
||||
#ifndef USING_DIRECTIONAL_LIGHT
|
||||
fixed3 lightDir = normalize(UnityWorldSpaceLightDir(worldPosition));
|
||||
#else
|
||||
fixed3 lightDir = _WorldSpaceLightPos0.xyz;
|
||||
#endif
|
||||
float3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPosition));
|
||||
float3 viewDir = _unity_tbn_0 * worldViewDir.x + _unity_tbn_1 * worldViewDir.y + _unity_tbn_2 * worldViewDir.z;
|
||||
|
||||
// initialize surface input
|
||||
UNITY_INITIALIZE_OUTPUT(DecalSurfaceInput, i)
|
||||
i.uv_decal = TRANSFORM_TEX(uv_projected, _Decal);
|
||||
i.uv = uv_projected;
|
||||
|
||||
#ifdef DECAL_BUMPMAP
|
||||
i.uv_bumpmap = TRANSFORM_TEX(uv_projected, _BumpMap);
|
||||
#endif //DECAL_BUMPMAP
|
||||
|
||||
#ifdef DECAL_SPECMAP
|
||||
i.uv_specmap = TRANSFORM_TEX(uv_projected, _SpecMap);
|
||||
#endif //DECAL_SPECMAP
|
||||
|
||||
#ifdef DECAL_EMISSIVE
|
||||
i.uv_emissive = TRANSFORM_TEX(uv_projected, _Emissive);
|
||||
#endif //DECAL_EMISSIVE
|
||||
|
||||
#ifdef DECAL_BASE_NORMAL
|
||||
#ifdef DECAL_PREVIEW
|
||||
i.normal = fixed3(0,0,1);
|
||||
#else
|
||||
i.normal = UnpackNormalDXT5nm(tex2D(_BumpMap, IN.uv_base));
|
||||
#endif //DECAL_PREVIEW
|
||||
#endif //DECAL_BASE_NORMAL
|
||||
|
||||
i.vertex_normal = IN.normal;
|
||||
i.viewDir = viewDir;
|
||||
i.worldPosition = worldPosition;
|
||||
|
||||
// initialize surface output
|
||||
o.Albedo = 0.0;
|
||||
o.Emission = 0.0;
|
||||
o.Specular = 0.0;
|
||||
o.Alpha = 0.0;
|
||||
o.Gloss = 0.0;
|
||||
o.Normal = fixed3(0,0,1);
|
||||
|
||||
// call surface function
|
||||
surf(i, o);
|
||||
|
||||
#ifdef DECAL_PREVIEW
|
||||
if (any(IN.uv_decal > 1) || any(IN.uv_decal < 0)) o.Alpha = 0;
|
||||
|
||||
o.Albedo = lerp(_Background.rgb, o.Albedo, o.Alpha) * _Color.rgb;
|
||||
o.Normal = lerp(float3(0,0,1), o.Normal, o.Alpha);
|
||||
o.Gloss = lerp(_Background.a, o.Gloss, o.Alpha);
|
||||
o.Emission = lerp(0, o.Emission, o.Alpha);
|
||||
o.Alpha = _Opacity;
|
||||
#endif //DECAL_PREVIEW
|
||||
|
||||
// compute lighting & shadowing factor
|
||||
UNITY_LIGHT_ATTENUATION(atten, IN, worldPosition)
|
||||
|
||||
// compute world normal
|
||||
float3 WorldNormal;
|
||||
WorldNormal.x = dot(_unity_tbn_0, o.Normal);
|
||||
WorldNormal.y = dot(_unity_tbn_1, o.Normal);
|
||||
WorldNormal.z = dot(_unity_tbn_2, o.Normal);
|
||||
WorldNormal = normalize(WorldNormal);
|
||||
o.Normal = WorldNormal;
|
||||
|
||||
//call modified KSP lighting function
|
||||
float4 c = LightingBlinnPhongDecal(o, lightDir, worldViewDir, atten);
|
||||
|
||||
// Forward base emission and ambient/vertex lighting
|
||||
#ifdef UNITY_PASS_FORWARDBASE
|
||||
c.rgb += o.Emission;
|
||||
c.rgb += o.Albedo * IN.vlight;
|
||||
c.a = o.Alpha;
|
||||
#endif //UNITY_PASS_FORWARDBASE
|
||||
|
||||
// Forward add multiply by alpha
|
||||
#ifdef UNITY_PASS_FORWARDADD
|
||||
c.rgb *= o.Alpha;
|
||||
#endif
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,38 @@
|
||||
void surf(DecalSurfaceInput IN, inout SurfaceOutput o) {
|
||||
float4 color = tex2D(_Decal, IN.uv_decal);
|
||||
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
||||
o.Alpha = _DecalOpacity;
|
||||
|
||||
#ifdef DECAL_BASE_NORMAL
|
||||
float3 normal = IN.normal;
|
||||
float wearFactor = 1 - normal.z;
|
||||
float wearFactorAlpha = saturate(_EdgeWearStrength * wearFactor);
|
||||
o.Alpha *= saturate(1 + _EdgeWearOffset - saturate(_EdgeWearStrength * wearFactor));
|
||||
#endif
|
||||
|
||||
#ifdef DECAL_BUMPMAP
|
||||
o.Normal = tex2D(_BumpMap, IN.uv_bumpmap);
|
||||
#endif
|
||||
|
||||
#ifdef DECAL_SPECMAP
|
||||
float4 specular = tex2D(_SpecMap, IN.uv_specmap);
|
||||
o.Gloss = specular.r;
|
||||
o.Specular = _Shininess;
|
||||
#endif
|
||||
|
||||
half rim = 1.0 - saturate(dot(normalize(IN.viewDir), o.Normal));
|
||||
o.Emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
|
||||
|
||||
#ifdef DECAL_EMISSIVE
|
||||
o.Emission += tex2D(_Emissive, IN.uv_emissive).rgb * _Emissive_Color.rgb * _Emissive_Color.a;
|
||||
#endif
|
||||
|
||||
float dist = BoundsDist(IN.uv, IN.vertex_normal, _DecalNormal);
|
||||
#ifdef DECAL_SDF_ALPHA
|
||||
float decalDist = _Cutoff - color.a;
|
||||
o.Alpha *= SDFAA(max(decalDist, dist));
|
||||
#else
|
||||
o.Alpha *= SDFAA(dist);
|
||||
o.Alpha *= color.a;
|
||||
#endif
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
Shader "ConformalDecals/Decal/Standard"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[Header(Decal)]
|
||||
_Decal("Decal Texture", 2D) = "gray" {}
|
||||
[Toggle(DECAL_SDF_ALPHA)] _Decal_SDF_Alpha ("SDF in Alpha", int) = 0
|
||||
|
||||
|
||||
[Header(Normal)]
|
||||
[Toggle(DECAL_BASE_NORMAL)] _BaseNormal ("Use Base Normal", int) = 0
|
||||
[Toggle(DECAL_BUMPMAP)] _Decal_BumpMap ("Has BumpMap", int) = 0
|
||||
_BumpMap("Bump Map", 2D) = "bump" {}
|
||||
_EdgeWearStrength("Edge Wear Strength", Range(0,500)) = 100
|
||||
_EdgeWearOffset("Edge Wear Offset", Range(0,1)) = 0.1
|
||||
|
||||
[Header(Specularity)]
|
||||
[Toggle(DECAL_SPECMAP)] _Decal_SpecMap ("Has SpecMap", int) = 0
|
||||
_SpecMap ("Specular Map)", 2D) = "black" {}
|
||||
_SpecColor ("_SpecColor", Color) = (0.25, 0.25, 0.25, 1)
|
||||
_Shininess ("Shininess", Range (0.03, 10)) = 0.3
|
||||
|
||||
[Header(Emissive)]
|
||||
[Toggle(DECAL_EMISSIVE)] _Decal_Emissive ("Has Emissive", int) = 0
|
||||
_Emissive("_Emissive", 2D) = "black" {}
|
||||
_EmissiveColor("_EmissiveColor", Color) = (0,0,0,1)
|
||||
|
||||
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
|
||||
_DecalOpacity("Opacity", Range(0,1) ) = 1
|
||||
_Background("Background Color", Color) = (0.9,0.9,0.9,0.7)
|
||||
|
||||
[Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull", int) = 2
|
||||
[Toggle] _ZWrite ("ZWrite", Float) = 1.0
|
||||
|
||||
[Toggle(DECAL_PREVIEW)] _Preview ("Preview", int) = 0
|
||||
|
||||
[Header(Effects)]
|
||||
[PerRendererData]_Opacity("_Opacity", Range(0,1) ) = 1
|
||||
[PerRendererData]_Color("_Color", Color) = (1,1,1,1)
|
||||
[PerRendererData]_RimFalloff("_RimFalloff", Range(0.01,5) ) = 0.1
|
||||
[PerRendererData]_RimColor("_RimColor", Color) = (0,0,0,0)
|
||||
[PerRendererData]_UnderwaterFogFactor ("Underwater Fog Factor", Range(0,1)) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Geometry+100" "IgnoreProjector" = "true" "DisableBatching" = "true"}
|
||||
Cull [_Cull]
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD"
|
||||
Tags { "LightMode" = "ForwardBase" }
|
||||
ZWrite [_ZWrite]
|
||||
ZTest LEqual
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_forward
|
||||
#pragma fragment frag_forward
|
||||
|
||||
#pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap
|
||||
#pragma skip_variants SHADOWS_DEPTH SHADOWS_CUBE SHADOWS_SHADOWMASK LIGHTMAP_SHADOW_MIXING POINT_COOKIE
|
||||
#pragma multi_compile_local __ DECAL_PREVIEW
|
||||
#pragma multi_compile_local __ DECAL_BASE_NORMAL DECAL_BUMPMAP
|
||||
#pragma multi_compile_local __ DECAL_SPECMAP
|
||||
#pragma multi_compile_local __ DECAL_EMISSIVE
|
||||
#pragma multi_compile_local __ DECAL_SDF_ALPHA
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "DecalsCommon.cginc"
|
||||
#include "DecalsSurface.cginc"
|
||||
#include "StandardDecal.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD"
|
||||
Tags { "LightMode" = "ForwardAdd" }
|
||||
ZWrite Off
|
||||
ZTest LEqual
|
||||
Blend One One
|
||||
Offset -1, -1
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_forward
|
||||
#pragma fragment frag_forward
|
||||
|
||||
#pragma multi_compile_fwdadd nolightmap nodirlightmap nodynlightmap
|
||||
#pragma skip_variants SHADOWS_DEPTH SHADOWS_CUBE SHADOWS_SHADOWMASK LIGHTMAP_SHADOW_MIXING POINT_COOKIE
|
||||
#pragma multi_compile_local __ DECAL_PREVIEW
|
||||
#pragma multi_compile_local __ DECAL_BASE_NORMAL DECAL_BUMPMAP
|
||||
#pragma multi_compile_local __ DECAL_SPECMAP
|
||||
#pragma multi_compile_local __ DECAL_EMISSIVE
|
||||
#pragma multi_compile_local __ DECAL_SDF_ALPHA
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "DecalsCommon.cginc"
|
||||
#include "DecalsSurface.cginc"
|
||||
#include "StandardDecal.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// shadow casting support
|
||||
UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 470 KiB |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,537 @@
|
||||
PART
|
||||
{
|
||||
name = conformaldecals-munar
|
||||
module = Part
|
||||
author = Andrew Cassidy
|
||||
MODEL
|
||||
{
|
||||
model = ConformalDecals/Assets/decal-blank
|
||||
scale = 1.0, 1.0, 1.0
|
||||
}
|
||||
rescaleFactor = 1
|
||||
|
||||
// Attachment
|
||||
attachRules = 1,1,0,0,1
|
||||
node_attach = 0.0, 0.0, 0.05, 0.0, 0.0, -1.0
|
||||
|
||||
// Tech
|
||||
TechRequired = start
|
||||
|
||||
// Info
|
||||
cost = 75
|
||||
category = Structural
|
||||
|
||||
// CDL-3 Surface Base Decal
|
||||
title = #LOC_ConformalDecals_munar-title
|
||||
|
||||
// Peel-N-Stik Adhesive Decals
|
||||
manufacturer = #LOC_ConformalDecals_agent-peel-n-stick_title
|
||||
|
||||
// Munar Industries Ltd. saw the wild success of the CDL-2 decal, and wanted to develop a decal set for their own line of Heluim mining bases. These decals are more explicit than the Semiotic Standard and aimed at the hazards that come with more advanced techonologies. (Based on the work of Gavin Rothery)
|
||||
description = #LOC_ConformalDecals_munar-description
|
||||
|
||||
// conformal decal sticker Moon munar lunar industries Gavin Rothery Sarang
|
||||
tags = #LOC_ConformalDecals_munar-tags
|
||||
|
||||
bulkheadProfiles = srf
|
||||
|
||||
// Parameters
|
||||
mass = 0.0005
|
||||
dragModel = NONE
|
||||
angularDrag = 0.0
|
||||
crashTolerance = 10
|
||||
maxTemp = 2000
|
||||
breakingForce = 350
|
||||
breakingTorque = 150
|
||||
physicalSignificance = NONE
|
||||
|
||||
MODULE
|
||||
{
|
||||
name = ModuleConformalDecal
|
||||
|
||||
useBaseNormal = true
|
||||
|
||||
tile = -1, -1, 0, 0
|
||||
tileSize = 96, 96
|
||||
tileIndex = 0
|
||||
|
||||
defaultScale = 0.1
|
||||
defaultDepth = 0.1
|
||||
defaultOpacity = 0.8
|
||||
defaultCutoff = 0
|
||||
|
||||
scaleRange = 0.05, 0.5
|
||||
scaleMode = MINIMUM
|
||||
cutoffAdjustable = false
|
||||
|
||||
shader = ConformalDecals/Decal/Standard
|
||||
|
||||
TEXTURE {
|
||||
name = _Decal
|
||||
textureUrl = ConformalDecals/Parts/Munar/Munar-Atlas
|
||||
isMain = true
|
||||
autoTile = true
|
||||
}
|
||||
|
||||
TEXTURE {
|
||||
name = _SpecMap
|
||||
textureUrl = ConformalDecals/Assets/Decal-Spec
|
||||
autoScale = true
|
||||
}
|
||||
}
|
||||
|
||||
MODULE {
|
||||
name = ModuleB9PartSwitch
|
||||
|
||||
SUBTYPE {
|
||||
name = severe-danger
|
||||
title = #LOC_ConformalDecals_munar-variant-severe-danger
|
||||
primaryColor = #2B250D
|
||||
secondaryColor = #F78000
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tileIndex = 0 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = danger
|
||||
title = #LOC_ConformalDecals_munar-variant-danger
|
||||
primaryColor = #93927E
|
||||
secondaryColor = #2B250D
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tileIndex = 2 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = hazard
|
||||
title = #LOC_ConformalDecals_munar-variant-hazard
|
||||
primaryColor = #2B250D
|
||||
secondaryColor = #CC1F01
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tileIndex = 6 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = warning
|
||||
title = #LOC_ConformalDecals_munar-variant-warning
|
||||
primaryColor = #2B250D
|
||||
secondaryColor = #93927E
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tileIndex = 5 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = bulkhead
|
||||
title = #LOC_ConformalDecals_munar-variant-bulkhead
|
||||
primaryColor = #93927E
|
||||
secondaryColor = White
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tileIndex = 7 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SUBTYPE {
|
||||
name = hatch
|
||||
title = #LOC_ConformalDecals_munar-variant-hatch
|
||||
primaryColor = #93927E
|
||||
secondaryColor = White
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tileIndex = 3 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = pressure-hatch
|
||||
title = #LOC_ConformalDecals_munar-variant-pressure-hatch
|
||||
primaryColor = #93927E
|
||||
secondaryColor = White
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tileIndex = 4 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = door
|
||||
title = #LOC_ConformalDecals_munar-variant-door
|
||||
primaryColor = #93927E
|
||||
secondaryColor = White
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tileIndex = 5 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = door-danger
|
||||
title = #LOC_ConformalDecals_munar-variant-door-danger
|
||||
primaryColor = #2B250D
|
||||
secondaryColor = #CC1F01
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
tile = 960, 0, 64, 96
|
||||
scaleMode = HEIGHT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = airlock-interior
|
||||
title = #LOC_ConformalDecals_munar-variant-airlock-interior
|
||||
primaryColor = #93927E
|
||||
secondaryColor = White
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tile = 866, 96, 142, 96 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = airlock-exterior
|
||||
title = #LOC_ConformalDecals_munar-variant-airlock-exterior
|
||||
primaryColor = #CC1F01
|
||||
secondaryColor = #2B250D
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tile = 768, 96, 142, 96 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = check-seals
|
||||
title = #LOC_ConformalDecals_munar-variant-check-seals
|
||||
primaryColor = White
|
||||
secondaryColor = #93927E
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tileIndex = 8 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = pressure-seal
|
||||
title = #LOC_ConformalDecals_munar-variant-pressure-seal
|
||||
primaryColor = White
|
||||
secondaryColor = #93927E
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tileIndex = 9 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = vacuum
|
||||
title = #LOC_ConformalDecals_munar-variant-vacuum
|
||||
primaryColor = #93927E
|
||||
secondaryColor = #2B250D
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tileIndex = 17 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = gas-mask
|
||||
title = #LOC_ConformalDecals_munar-variant-gas-mask
|
||||
primaryColor = #93927E
|
||||
secondaryColor = White
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tile = 96, 320, 96, 116 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = oxygen-rich
|
||||
title = #LOC_ConformalDecals_munar-variant-oxygen-rich
|
||||
primaryColor = #CC1F01
|
||||
secondaryColor = #2B250D
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tile = 288, 416, 96, 96 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = robotic-work
|
||||
title = #LOC_ConformalDecals_munar-variant-robotic-work
|
||||
primaryColor = #F78000
|
||||
secondaryColor = #2B250D
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tileIndex = 10 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = explosion
|
||||
title = #LOC_ConformalDecals_munar-variant-explosion
|
||||
primaryColor = #F78000
|
||||
secondaryColor = #2B250D
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tile = 0, 320, 96, 116 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = radiation
|
||||
title = #LOC_ConformalDecals_munar-variant-radiation
|
||||
primaryColor = #F78000
|
||||
secondaryColor = #2B250D
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tileIndex = 1 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = antimatter
|
||||
title = #LOC_ConformalDecals_munar-variant-antimatter
|
||||
primaryColor = #F78000
|
||||
secondaryColor = #2B250D
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tileIndex = 11 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = high-voltage
|
||||
title = #LOC_ConformalDecals_munar-variant-high-voltage
|
||||
primaryColor = #93927E
|
||||
secondaryColor = White
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tileIndex = 13 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = extreme-voltage
|
||||
title = #LOC_ConformalDecals_munar-variant-extreme-voltage
|
||||
primaryColor = #2B250D
|
||||
secondaryColor = White
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tileIndex = 14 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = explosive-bolts
|
||||
title = #LOC_ConformalDecals_munar-variant-explosive-bolts
|
||||
primaryColor = #93927E
|
||||
secondaryColor = #CC1F01
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tileIndex = 15 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = autonomous-device
|
||||
title = #LOC_ConformalDecals_munar-variant-autonomous-device
|
||||
primaryColor = #2B250D
|
||||
secondaryColor = White
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tileIndex = 16 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = gravity-adjust
|
||||
title = #LOC_ConformalDecals_munar-variant-gravity-adjust
|
||||
primaryColor = White
|
||||
secondaryColor = #CC1F01
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tile = 288, 320, 96, 96 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = electromagnetic
|
||||
title = #LOC_ConformalDecals_munar-variant-electromagnetic
|
||||
primaryColor = #93927E
|
||||
secondaryColor = White
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
tile = 967, 195, 50, 90
|
||||
scaleMode = HEIGHT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = mind-step
|
||||
title = #LOC_ConformalDecals_munar-variant-mind-step
|
||||
primaryColor = #93927E
|
||||
secondaryColor = White
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tile = 1, 447, 230, 64 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = class-1
|
||||
title = #LOC_ConformalDecals_munar-variant-class-1
|
||||
primaryColor = #CC1F01
|
||||
secondaryColor = #93927E
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tile = 0, 192, 96, 128 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = class-2
|
||||
title = #LOC_ConformalDecals_munar-variant-class-2
|
||||
primaryColor = #93927E
|
||||
secondaryColor = #CC1F01
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tile = 96, 192, 96, 128 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = class-3
|
||||
title = #LOC_ConformalDecals_munar-variant-class-3
|
||||
primaryColor = #93927E
|
||||
secondaryColor = #93927E
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tile = 192, 192, 96, 128 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = class-4
|
||||
title = #LOC_ConformalDecals_munar-variant-class-4
|
||||
primaryColor = #93927E
|
||||
secondaryColor = #93927E
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tile = 288, 192, 96, 128 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = class-5
|
||||
title = #LOC_ConformalDecals_munar-variant-class-5
|
||||
primaryColor = #93927E
|
||||
secondaryColor = White
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tile = 384, 192, 96, 128 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = class-6
|
||||
title = #LOC_ConformalDecals_munar-variant-class-6
|
||||
primaryColor = #93927E
|
||||
secondaryColor = White
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tile = 480, 192, 96, 128 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = class-7
|
||||
title = #LOC_ConformalDecals_munar-variant-class-7
|
||||
primaryColor = #F78000
|
||||
secondaryColor = #93927E
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tile = 576, 192, 96, 128 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = class-8
|
||||
title = #LOC_ConformalDecals_munar-variant-class-8
|
||||
primaryColor = #93927E
|
||||
secondaryColor = #F78000
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tile = 672, 192, 96, 128 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = class-9
|
||||
title = #LOC_ConformalDecals_munar-variant-class-9
|
||||
primaryColor = #93927E
|
||||
secondaryColor = #F78000
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tile = 768, 192, 96, 128 }
|
||||
}
|
||||
}
|
||||
|
||||
SUBTYPE {
|
||||
name = class-10
|
||||
title = #LOC_ConformalDecals_munar-variant-class-10
|
||||
primaryColor = #F78000
|
||||
secondaryColor = White
|
||||
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA { tile = 864, 192, 96, 128 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -1,79 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals.MaterialModifiers {
|
||||
public abstract class MaterialProperty : ScriptableObject {
|
||||
public string PropertyName {
|
||||
get => _propertyName;
|
||||
set {
|
||||
_propertyName = value;
|
||||
_propertyID = Shader.PropertyToID(_propertyName);
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] protected int _propertyID;
|
||||
[SerializeField] protected string _propertyName;
|
||||
|
||||
public virtual void ParseNode(ConfigNode node) {
|
||||
if (node == null) throw new ArgumentNullException(nameof(node));
|
||||
|
||||
PropertyName = node.GetValue("name");
|
||||
Debug.Log($"Parsing material property {_propertyName}");
|
||||
}
|
||||
|
||||
public abstract void Modify(Material material);
|
||||
|
||||
private delegate bool TryParseDelegate<T>(string valueString, out T value);
|
||||
|
||||
protected bool ParsePropertyBool(ConfigNode node, string valueName, bool isOptional = false, bool defaultValue = false) {
|
||||
return ParsePropertyValue(node, valueName, bool.TryParse, isOptional, defaultValue);
|
||||
}
|
||||
|
||||
protected float ParsePropertyFloat(ConfigNode node, string valueName, bool isOptional = false, float defaultValue = 0.0f) {
|
||||
return ParsePropertyValue(node, valueName, float.TryParse, isOptional, defaultValue);
|
||||
}
|
||||
|
||||
protected int ParsePropertyInt(ConfigNode node, string valueName, bool isOptional = false, int defaultValue = 0) {
|
||||
return ParsePropertyValue(node, valueName, int.TryParse, isOptional, defaultValue);
|
||||
}
|
||||
|
||||
protected Color ParsePropertyColor(ConfigNode node, string valueName, bool isOptional = false, Color defaultValue = default) {
|
||||
return ParsePropertyValue(node, valueName, ParseExtensions.TryParseColor, isOptional, defaultValue);
|
||||
}
|
||||
|
||||
protected Rect ParsePropertyRect(ConfigNode node, string valueName, bool isOptional = false, Rect defaultValue = default) {
|
||||
return ParsePropertyValue(node, valueName, ParseExtensions.TryParseRect, isOptional, defaultValue);
|
||||
}
|
||||
|
||||
protected Vector2 ParsePropertyVector2(ConfigNode node, string valueName, bool isOptional = false, Vector2 defaultValue = default) {
|
||||
return ParsePropertyValue(node, valueName, ParseExtensions.TryParseVector2, isOptional, defaultValue);
|
||||
}
|
||||
|
||||
private T ParsePropertyValue<T>(ConfigNode node, string valueName, TryParseDelegate<T> tryParse, bool isOptional = false, T defaultValue = default) {
|
||||
string valueString = node.GetValue(valueName);
|
||||
|
||||
if (isOptional) {
|
||||
if (string.IsNullOrEmpty(valueString)) return defaultValue;
|
||||
}
|
||||
else {
|
||||
if (valueString == null)
|
||||
throw new FormatException($"Missing {typeof(T)} value for {valueName} in property '{PropertyName}'");
|
||||
|
||||
if (valueString == string.Empty)
|
||||
throw new FormatException($"Empty {typeof(T)} value for {valueName} in property '{PropertyName}'");
|
||||
}
|
||||
|
||||
if (tryParse(valueString, out var value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (isOptional) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
else {
|
||||
throw new FormatException($"Improperly formatted {typeof(T)} value for {valueName} in property '{PropertyName}' : '{valueString}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +1,19 @@
|
||||
using System;
|
||||
using ConformalDecals.Util;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals.MaterialModifiers {
|
||||
namespace ConformalDecals.MaterialProperties {
|
||||
public class MaterialColorProperty : MaterialProperty {
|
||||
[SerializeField] public Color color;
|
||||
[SerializeField] public Color32 color = new Color32(0, 0, 0, byte.MaxValue);
|
||||
|
||||
public override void ParseNode(ConfigNode node) {
|
||||
base.ParseNode(node);
|
||||
|
||||
color = ParsePropertyColor(node, "color", true, color);
|
||||
ParseUtil.ParseColor32Indirect(ref color, node, "color");
|
||||
}
|
||||
|
||||
public override void Modify(Material material) {
|
||||
if (material == null) throw new ArgumentNullException("material cannot be null");
|
||||
if (material == null) throw new ArgumentNullException(nameof(material));
|
||||
|
||||
material.SetColor(_propertyID, color);
|
||||
}
|
@ -1,18 +1,19 @@
|
||||
using System;
|
||||
using ConformalDecals.Util;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals.MaterialModifiers {
|
||||
namespace ConformalDecals.MaterialProperties {
|
||||
public class MaterialFloatProperty : MaterialProperty {
|
||||
[SerializeField] public float value;
|
||||
|
||||
public override void ParseNode(ConfigNode node) {
|
||||
base.ParseNode(node);
|
||||
|
||||
value = ParsePropertyFloat(node, "value", true, value);
|
||||
ParseUtil.ParseFloatIndirect(ref value, node, "value");
|
||||
}
|
||||
|
||||
public override void Modify(Material material) {
|
||||
if (material == null) throw new ArgumentNullException("material cannot be null");
|
||||
if (material == null) throw new ArgumentNullException(nameof(material));
|
||||
|
||||
material.SetFloat(_propertyID, value);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using ConformalDecals.Util;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals.MaterialProperties {
|
||||
public class MaterialKeywordProperty : MaterialProperty {
|
||||
[SerializeField] public bool value = true;
|
||||
|
||||
public override void ParseNode(ConfigNode node) {
|
||||
base.ParseNode(node);
|
||||
|
||||
ParseUtil.ParseBoolIndirect(ref value, node, "value");
|
||||
}
|
||||
|
||||
public override void Modify(Material material) {
|
||||
if (value) material.EnableKeyword(_propertyName);
|
||||
else material.DisableKeyword(_propertyName);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals.MaterialProperties {
|
||||
public abstract class MaterialProperty : ScriptableObject {
|
||||
public string PropertyName {
|
||||
get => _propertyName;
|
||||
set {
|
||||
_propertyName = value;
|
||||
_propertyID = Shader.PropertyToID(_propertyName);
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] protected int _propertyID;
|
||||
[SerializeField] protected string _propertyName;
|
||||
|
||||
public abstract void Modify(Material material);
|
||||
|
||||
public virtual void ParseNode(ConfigNode node) {
|
||||
if (node == null) throw new ArgumentNullException(nameof(node));
|
||||
|
||||
PropertyName = node.GetValue("name");
|
||||
}
|
||||
|
||||
public virtual void Remove(Material material) { }
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals.Test {
|
||||
public class TestLayers : PartModule {
|
||||
|
||||
[KSPField(guiActive = true)]
|
||||
public int layer = 2;
|
||||
|
||||
public override void OnStart(StartState state) {
|
||||
base.OnStart(state);
|
||||
|
||||
|
||||
Part.layerMask.value |= (1 << 3);
|
||||
}
|
||||
|
||||
public void Update() {
|
||||
foreach (var collider in GameObject.FindObjectsOfType<Collider>()) {
|
||||
if (collider.gameObject.layer == 3) {
|
||||
Debug.Log($"Has layer 3: {collider.gameObject.name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[KSPEvent(guiActive = true, guiActiveEditor = true, guiName = "switch layers")]
|
||||
public void Switch() {
|
||||
Debug.Log(Part.layerMask.value);
|
||||
|
||||
var cube = part.FindModelTransform("test");
|
||||
layer = (layer + 1) % 32;
|
||||
cube.gameObject.layer = layer;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,216 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals.Util {
|
||||
public static class ParseUtil {
|
||||
private static readonly Dictionary<string, Color> NamedColors = new Dictionary<string, Color>();
|
||||
private static readonly char[] Separator = {',', ' ', '\t'};
|
||||
|
||||
public delegate bool TryParseDelegate<T>(string valueString, out T value);
|
||||
|
||||
static ParseUtil() {
|
||||
// setup named colors
|
||||
foreach (var propertyInfo in typeof(Color).GetProperties(BindingFlags.Static | BindingFlags.Public)) {
|
||||
if (!propertyInfo.CanRead) continue;
|
||||
if (propertyInfo.PropertyType != typeof(Color)) continue;
|
||||
|
||||
NamedColors.Add(propertyInfo.Name, (Color) propertyInfo.GetValue(null, null));
|
||||
}
|
||||
|
||||
foreach (var propertyInfo in typeof(XKCDColors).GetProperties(BindingFlags.Static | BindingFlags.Public)) {
|
||||
if (!propertyInfo.CanRead) continue;
|
||||
if (propertyInfo.PropertyType != typeof(Color)) continue;
|
||||
|
||||
if (NamedColors.ContainsKey(propertyInfo.Name)) throw new Exception("duplicate key " + propertyInfo.Name);
|
||||
|
||||
NamedColors.Add(propertyInfo.Name, (Color) propertyInfo.GetValue(null, null));
|
||||
}
|
||||
}
|
||||
|
||||
public static string ParseString(ConfigNode node, string valueName, bool isOptional = false, string defaultValue = "") {
|
||||
if (!node.HasValue(valueName)) throw new FormatException($"Missing value for {valueName}");
|
||||
|
||||
return node.GetValue(valueName);
|
||||
}
|
||||
|
||||
public static bool ParseStringIndirect(ref string value, ConfigNode node, string valueName) {
|
||||
if (node.HasValue(valueName)) {
|
||||
value = node.GetValue(valueName);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool ParseBool(ConfigNode node, string valueName, bool isOptional = false, bool defaultValue = false) {
|
||||
return ParseValue(node, valueName, bool.TryParse, isOptional, defaultValue);
|
||||
}
|
||||
|
||||
public static bool ParseBoolIndirect(ref bool value, ConfigNode node, string valueName) {
|
||||
return ParseValueIndirect(ref value, node, valueName, bool.TryParse);
|
||||
}
|
||||
|
||||
public static float ParseFloat(ConfigNode node, string valueName, bool isOptional = false, float defaultValue = 0.0f) {
|
||||
return ParseValue(node, valueName, float.TryParse, isOptional, defaultValue);
|
||||
}
|
||||
|
||||
public static bool ParseFloatIndirect(ref float value, ConfigNode node, string valueName) {
|
||||
return ParseValueIndirect(ref value, node, valueName, float.TryParse);
|
||||
}
|
||||
|
||||
public static int ParseInt(ConfigNode node, string valueName, bool isOptional = false, int defaultValue = 0) {
|
||||
return ParseValue(node, valueName, int.TryParse, isOptional, defaultValue);
|
||||
}
|
||||
|
||||
public static bool ParseIntIndirect(ref int value, ConfigNode node, string valueName) {
|
||||
return ParseValueIndirect(ref value, node, valueName, int.TryParse);
|
||||
}
|
||||
|
||||
public static Color32 ParseColor32(ConfigNode node, string valueName, bool isOptional = false, Color32 defaultValue = default) {
|
||||
return ParseValue(node, valueName, TryParseColor32, isOptional, defaultValue);
|
||||
}
|
||||
|
||||
public static bool ParseColor32Indirect(ref Color32 value, ConfigNode node, string valueName) {
|
||||
return ParseValueIndirect(ref value, node, valueName, TryParseColor32);
|
||||
}
|
||||
|
||||
public static Rect ParseRect(ConfigNode node, string valueName, bool isOptional = false, Rect defaultValue = default) {
|
||||
return ParseValue(node, valueName, ParseExtensions.TryParseRect, isOptional, defaultValue);
|
||||
}
|
||||
|
||||
public static bool ParseRectIndirect(ref Rect value, ConfigNode node, string valueName) {
|
||||
return ParseValueIndirect(ref value, node, valueName, ParseExtensions.TryParseRect);
|
||||
}
|
||||
|
||||
public static Vector2 ParseVector2(ConfigNode node, string valueName, bool isOptional = false, Vector2 defaultValue = default) {
|
||||
return ParseValue(node, valueName, ParseExtensions.TryParseVector2, isOptional, defaultValue);
|
||||
}
|
||||
|
||||
public static bool ParseVector2Indirect(ref Vector2 value, ConfigNode node, string valueName) {
|
||||
return ParseValueIndirect(ref value, node, valueName, ParseExtensions.TryParseVector2);
|
||||
}
|
||||
|
||||
public static Vector3 ParseVector3(ConfigNode node, string valueName, bool isOptional = false, Vector3 defaultValue = default) {
|
||||
return ParseValue(node, valueName, ParseExtensions.TryParseVector3, isOptional, defaultValue);
|
||||
}
|
||||
|
||||
public static bool ParseVector3Indirect(ref Vector3 value, ConfigNode node, string valueName) {
|
||||
return ParseValueIndirect(ref value, node, valueName, ParseExtensions.TryParseVector3);
|
||||
}
|
||||
|
||||
public static T ParseValue<T>(ConfigNode node, string valueName, TryParseDelegate<T> tryParse, bool isOptional = false, T defaultValue = default) {
|
||||
string valueString = node.GetValue(valueName);
|
||||
|
||||
if (isOptional) {
|
||||
if (string.IsNullOrEmpty(valueString)) return defaultValue;
|
||||
}
|
||||
else {
|
||||
if (valueString == null)
|
||||
throw new FormatException($"Missing {typeof(T)} value for {valueName}");
|
||||
|
||||
if (valueString == string.Empty)
|
||||
throw new FormatException($"Empty {typeof(T)} value for {valueName}");
|
||||
}
|
||||
|
||||
if (tryParse(valueString, out var value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (isOptional) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
else {
|
||||
throw new FormatException($"Improperly formatted {typeof(T)} value for {valueName} : '{valueString}");
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ParseValueIndirect<T>(ref T value, ConfigNode node, string valueName, TryParseDelegate<T> tryParse) {
|
||||
if (!node.HasValue(valueName)) return false;
|
||||
|
||||
var valueString = node.GetValue(valueName);
|
||||
if (tryParse(valueString, out var newValue)) {
|
||||
value = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new FormatException($"Improperly formatted {typeof(T)} value for {valueName} : '{valueString}");
|
||||
}
|
||||
|
||||
public static bool TryParseColor32(string valueString, out Color32 value) {
|
||||
value = new Color32(0, 0, 0, byte.MaxValue);
|
||||
|
||||
// HTML-style hex color
|
||||
if (valueString[0] == '#') {
|
||||
var hexColorString = valueString.Substring(1);
|
||||
|
||||
if (!int.TryParse(hexColorString, System.Globalization.NumberStyles.HexNumber, null, out var hexColor)) return false;
|
||||
|
||||
switch (hexColorString.Length) {
|
||||
case 8: // RRGGBBAA
|
||||
value.a = (byte) (hexColor & 0xFF);
|
||||
hexColor >>= 8;
|
||||
goto case 6;
|
||||
|
||||
case 6: // RRGGBB
|
||||
value.b = (byte) (hexColor & 0xFF);
|
||||
hexColor >>= 8;
|
||||
value.g = (byte) (hexColor & 0xFF);
|
||||
hexColor >>= 8;
|
||||
value.r = (byte) (hexColor & 0xFF);
|
||||
return true;
|
||||
|
||||
case 4: // RGBA
|
||||
value.a = (byte) ((hexColor & 0xF) << 4);
|
||||
hexColor >>= 4;
|
||||
goto case 3;
|
||||
|
||||
case 3: // RGB
|
||||
value.b = (byte) (hexColor & 0xF << 4);
|
||||
hexColor >>= 4;
|
||||
value.g = (byte) (hexColor & 0xF << 4);
|
||||
hexColor >>= 4;
|
||||
value.r = (byte) (hexColor & 0xF << 4);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// named color
|
||||
if (NamedColors.TryGetValue(valueString, out var namedColor)) {
|
||||
value = namedColor;
|
||||
return true;
|
||||
}
|
||||
|
||||
// float color
|
||||
var split = valueString.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
|
||||
for (int i = 0; i < split.Length; i++) {
|
||||
split[i] = split[i].Trim();
|
||||
}
|
||||
|
||||
switch (split.Length) {
|
||||
case 4:
|
||||
if (!float.TryParse(split[4], out var alpha)) return false;
|
||||
value.a = (byte) (alpha * 0xFF);
|
||||
goto case 3;
|
||||
|
||||
case 3:
|
||||
if (!float.TryParse(split[0], out var red)) return false;
|
||||
if (!float.TryParse(split[1], out var green)) return false;
|
||||
if (!float.TryParse(split[2], out var blue)) return false;
|
||||
|
||||
value.r = (byte) (red * 0xFF);
|
||||
value.g = (byte) (green * 0xFF);
|
||||
value.b = (byte) (blue * 0xFF);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue