Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
f545e4c5ab | |||
cb98e78a3f | |||
946975249d | |||
ce55f07150 | |||
7286202be9 | |||
14640c1dca | |||
321b2a49a4 | |||
f1115ef188 | |||
92818edfaa | |||
dd40e54ef3 | |||
c19a0c2889 | |||
ded36f457d | |||
1be7a98835 | |||
a3a9ad9674 | |||
89a1f0d872 | |||
6db2d6b82a | |||
37715a46ab | |||
60cc0d76bb | |||
e7307f95e9 | |||
88da55123b |
6
.github/workflows/ksp-publish.yml
vendored
@ -124,7 +124,7 @@ jobs:
|
||||
curl -c ./cookies -b ./cookies \
|
||||
-F "version=$VERSION_TITLE" \
|
||||
-F "changelog=$(yaclog show -mb)" \
|
||||
-F "game-version=1.12.3" \
|
||||
-F "game-version=1.12.5" \
|
||||
-F "notify-followers=yes" \
|
||||
-F "zipball=@bundled/ConformalDecals-$VERSION_TITLE.zip" \
|
||||
"https://spacedock.info/api/mod/2451/update"
|
||||
@ -134,8 +134,8 @@ jobs:
|
||||
set -u
|
||||
gh release create ${{ github.ref_name }} \
|
||||
--notes "$(yaclog show -mb)" \
|
||||
--title "Version $VERSION_TITLE" \
|
||||
bundled/ConformalDecals-*.zip
|
||||
--title "Conformal Decals $VERSION_TITLE" \
|
||||
bundled/ConformalDecals-*.zip \
|
||||
ConformalDecals/GameData/ConformalDecals/Versioning/ConformalDecals.version
|
||||
|
||||
env:
|
||||
|
12
.gitignore
vendored
@ -1,10 +1,8 @@
|
||||
# Unity Project Directories
|
||||
Assets/*
|
||||
!Assets/Shaders/
|
||||
!Assets/Textures/
|
||||
!Assets/Scripts/
|
||||
!Assets/UI/
|
||||
!Assets/ConformalDecals/
|
||||
!Assets/ConformalDecals
|
||||
Assets/ConformalDecals/Fonts
|
||||
Assets/ConformalDecals/Parts
|
||||
KSP/
|
||||
Library/
|
||||
Logs/
|
||||
@ -12,6 +10,9 @@ Packages/
|
||||
ProjectSettings/
|
||||
Temp/
|
||||
|
||||
# Autogenerated shaders
|
||||
Assets/ConformalDecals/Shaders/Decal/*.shader
|
||||
|
||||
# Unity Assetbundle Manifest Files
|
||||
GameData/ConformalDecals/Resources/Resources
|
||||
GameData/ConformalDecals/Resources/*.manifest
|
||||
@ -55,3 +56,4 @@ Source/ConformalDecals/bin
|
||||
obj
|
||||
*.swp
|
||||
@thumbs
|
||||
|
||||
|
156
Assets/ConformalDecals/Shaders/Decal/DecalBase.shader.template
Normal file
@ -0,0 +1,156 @@
|
||||
Shader "ConformalDecals/Decal/{% block shader_name %}UNKNOWN{% endblock %}"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
|
||||
// Shader-specific properties
|
||||
{% block properties %}
|
||||
{% endblock %}
|
||||
|
||||
// Common decal properties
|
||||
_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
|
||||
#pragma fragment frag_forward
|
||||
|
||||
#pragma multi_compile_fwdbase
|
||||
#pragma skip_variants LIGHTMAP_ON DIRLIGHTMAP_COMBINED DYNAMICLIGHTMAP_ON LIGHTMAP_SHADOW_MIXING
|
||||
#pragma multi_compile_local __ DECAL_PREVIEW
|
||||
|
||||
{% block body %}
|
||||
#error No body provided
|
||||
{% endblock %}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD"
|
||||
Tags
|
||||
{
|
||||
"LightMode" = "ForwardAdd"
|
||||
}
|
||||
ZWrite Off
|
||||
ZTest LEqual
|
||||
Blend SrcAlpha One
|
||||
Offset -1, -1
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag_forward
|
||||
|
||||
#pragma multi_compile DIRECTIONAL SPOT POINT
|
||||
#pragma multi_compile __ LIGHTPROBE_SH
|
||||
#pragma multi_compile_local __ DECAL_PREVIEW
|
||||
|
||||
{{ self.body() }}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DEFERRED_PREPASS"
|
||||
Tags
|
||||
{
|
||||
"LightMode" = "Deferred"
|
||||
}
|
||||
ZWrite Off
|
||||
ZTest LEqual
|
||||
Offset -1, -1
|
||||
Blend 1 Zero OneMinusSrcColor, Zero OneMinusSrcAlpha
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref 1
|
||||
Comp Equal
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag_deferred_prepass
|
||||
#pragma target 3.0
|
||||
|
||||
#pragma multi_compile_local __ DECAL_PREVIEW
|
||||
|
||||
{{ self.body() }}
|
||||
|
||||
{% block pragmas_deferred_prepass %}
|
||||
{% endblock %}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DEFERRED"
|
||||
Tags
|
||||
{
|
||||
"LightMode" = "Deferred"
|
||||
}
|
||||
ZWrite Off
|
||||
ZTest LEqual
|
||||
Offset -1, -1
|
||||
Blend 0 SrcAlpha OneMinusSrcAlpha, Zero One
|
||||
Blend 1 One One
|
||||
Blend 2 SrcAlpha OneMinusSrcAlpha, Zero One
|
||||
Blend 3 SrcAlpha OneMinusSrcAlpha, Zero One
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref 1
|
||||
Comp Equal
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag_deferred
|
||||
#pragma target 3.0
|
||||
|
||||
#pragma multi_compile __ LIGHTPROBE_SH
|
||||
#pragma multi_compile __ UNITY_HDR_ON
|
||||
#pragma multi_compile_local __ DECAL_PREVIEW
|
||||
|
||||
{{ self.body() }}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
422
Assets/ConformalDecals/Shaders/Decal/DecalsCommon.cginc
Normal file
@ -0,0 +1,422 @@
|
||||
#ifndef DECALS_COMMON_INCLUDED
|
||||
#define DECALS_COMMON_INCLUDED
|
||||
|
||||
#include "AutoLight.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "../LightingKSP.cginc"
|
||||
|
||||
#define CLIP_MARGIN 0.05
|
||||
#define EDGE_MARGIN 0.01
|
||||
|
||||
// UNIFORM VARIABLES
|
||||
// Projection matrix, normal, and tangent vectors
|
||||
float4x4 _ProjectionMatrix;
|
||||
float3 _DecalNormal;
|
||||
float3 _DecalTangent;
|
||||
|
||||
// Common Shading Paramaters
|
||||
float _Cutoff;
|
||||
float _DecalOpacity;
|
||||
float4 _Background;
|
||||
|
||||
sampler2D _Decal;
|
||||
float4 _Decal_ST;
|
||||
|
||||
// Variant Shading Parameters
|
||||
#ifdef DECAL_BASE_NORMAL
|
||||
sampler2D _BumpMap;
|
||||
float4 _BumpMap_ST;
|
||||
float _EdgeWearStrength;
|
||||
float _EdgeWearOffset;
|
||||
#endif //DECAL_BASE_NORMAL
|
||||
|
||||
#ifdef DECAL_BUMPMAP
|
||||
sampler2D _BumpMap;
|
||||
float4 _BumpMap_ST;
|
||||
#endif //DECAL_BUMPMAP
|
||||
|
||||
#ifdef DECAL_SPECMAP
|
||||
sampler2D _SpecMap;
|
||||
float4 _SpecMap_ST;
|
||||
// specular color is declared in a unity CGINC for some reason??
|
||||
#endif //DECAL_SPECMAP
|
||||
|
||||
fixed _Shininess;
|
||||
|
||||
|
||||
#ifdef DECAL_EMISSIVE
|
||||
sampler2D _Emissive;
|
||||
float4 _Emissive_ST;
|
||||
fixed4 _Emissive_Color;
|
||||
#endif //DECAL_EMISSIVE
|
||||
|
||||
// KSP EFFECTS
|
||||
// opacity and color
|
||||
float _Opacity;
|
||||
float _RimFalloff;
|
||||
float4 _RimColor;
|
||||
|
||||
// SURFACE INPUT STRUCT
|
||||
struct DecalSurfaceInput
|
||||
{
|
||||
float3 uv;
|
||||
float2 uv_decal;
|
||||
|
||||
#ifdef DECAL_BUMPMAP
|
||||
float2 uv_bumpmap;
|
||||
#endif //DECAL_BUMPMAP
|
||||
|
||||
#ifdef DECAL_SPECMAP
|
||||
float2 uv_specmap;
|
||||
#endif //DECAL_SPECMAP
|
||||
|
||||
#ifdef DECAL_EMISSIVE
|
||||
float2 uv_emissive;
|
||||
#endif //DECAL_EMISSIVE
|
||||
|
||||
#ifdef DECAL_BASE_NORMAL
|
||||
float3 normal;
|
||||
#endif //DECAL_BASE_NORMAL
|
||||
|
||||
float3 vertex_normal;
|
||||
float3 viewDir;
|
||||
float3 worldPosition;
|
||||
};
|
||||
|
||||
struct appdata_decal
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
#if defined(DECAL_BASE_NORMAL) || defined(DECAL_PREVIEW)
|
||||
float4 texcoord : TEXCOORD0;
|
||||
float4 tangent : TANGENT;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
UNITY_POSITION(pos);
|
||||
float3 normal : NORMAL;
|
||||
float4 uv_decal : TEXCOORD0;
|
||||
|
||||
#ifdef DECAL_BASE_NORMAL
|
||||
float2 uv_base : TEXCOORD1;
|
||||
#endif //DECAL_BASE_NORMAL
|
||||
|
||||
float4 tSpace0 : TEXCOORD2;
|
||||
float4 tSpace1 : TEXCOORD3;
|
||||
float4 tSpace2 : TEXCOORD4;
|
||||
|
||||
#ifdef UNITY_PASS_FORWARDBASE
|
||||
fixed3 vlight : TEXCOORD5;
|
||||
UNITY_SHADOW_COORDS(6)
|
||||
#endif //UNITY_PASS_FORWARDBASE
|
||||
|
||||
#ifdef UNITY_PASS_FORWARDADD
|
||||
UNITY_LIGHTING_COORDS(5,6)
|
||||
#endif //UNITY_PASS_FORWARDADD
|
||||
|
||||
#if UNITY_SHOULD_SAMPLE_SH
|
||||
half3 sh : TEXCOORD7; // SH
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
inline void decalClipAlpha(float alpha) {
|
||||
#ifndef DECAL_PREVIEW
|
||||
clip(alpha - 0.001);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline float CalcMipLevel(float2 texture_coord) {
|
||||
float2 dx = ddx(texture_coord);
|
||||
float2 dy = ddy(texture_coord);
|
||||
float delta_max_sqr = max(dot(dx, dx), dot(dy, dy));
|
||||
|
||||
return 0.5 * log2(delta_max_sqr);
|
||||
}
|
||||
|
||||
// Decal bounds distance function
|
||||
// takes in a world position, world normal, and projector normal and outputs a unitless signed distance from the
|
||||
inline float BoundsDist(float3 p, float3 normal, float3 projNormal) {
|
||||
float3 q = abs(p - 0.5) - 0.5; // 1x1 square/cube centered at (0.5,0.5)
|
||||
//float dist = length(max(q,0)) + min(max(q.x,max(q.y,q.z)),0.0); // true SDF
|
||||
#ifdef DECAL_PREVIEW
|
||||
return 10 * max(q.x, q.y); // 2D pseudo SDF
|
||||
#else
|
||||
float dist = max(max(q.x, q.y), q.z); // pseudo SDF
|
||||
float ndist = EDGE_MARGIN - dot(normal, projNormal); // SDF to normal
|
||||
return 10 * max(dist, ndist); // return intersection
|
||||
#endif //DECAL_PREVIEW
|
||||
}
|
||||
|
||||
// declare surf function,
|
||||
// this must be defined in any shader using this cginc
|
||||
void surf (DecalSurfaceInput IN, inout SurfaceOutput o);
|
||||
|
||||
v2f vert(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;
|
||||
}
|
||||
|
||||
|
||||
SurfaceOutput frag_common(v2f IN, out float3 worldPos, out float3 worldViewDir, out float3 viewDir) {
|
||||
SurfaceOutput o;
|
||||
|
||||
// setup world-space TBN vectors
|
||||
UNITY_EXTRACT_TBN(IN);
|
||||
|
||||
worldPos = float3(IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w);
|
||||
worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos));
|
||||
viewDir = _unity_tbn_0 * worldViewDir.x + _unity_tbn_1 * worldViewDir.y + _unity_tbn_2 * worldViewDir.z;
|
||||
|
||||
#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;
|
||||
|
||||
// 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 = worldPos;
|
||||
|
||||
// initialize surface output
|
||||
o.Albedo = 0.0;
|
||||
o.Emission = 0.0;
|
||||
o.Specular = 0.4;
|
||||
o.Alpha = _DecalOpacity;
|
||||
o.Gloss = 0.0;
|
||||
o.Normal = fixed3(0,0,1);
|
||||
|
||||
// call surface function
|
||||
surf(i, o);
|
||||
|
||||
// apply KSP fog. In the deferred pass this is a no-op
|
||||
o.Albedo = UnderwaterFog(i.worldPosition, o.Albedo).rgb;
|
||||
|
||||
// apply KSP rim lighting
|
||||
half rim = 1.0 - saturate(dot(normalize(i.viewDir), o.Normal));
|
||||
o.Emission += o.Emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
|
||||
|
||||
// compute world normal
|
||||
float3 worldN;
|
||||
worldN.x = dot(_unity_tbn_0, o.Normal);
|
||||
worldN.y = dot(_unity_tbn_1, o.Normal);
|
||||
worldN.z = dot(_unity_tbn_2, o.Normal);
|
||||
worldN = normalize(worldN);
|
||||
o.Normal = worldN;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag_forward(v2f IN) : SV_Target
|
||||
{
|
||||
fixed4 c = 0;
|
||||
|
||||
float3 worldPos;
|
||||
float3 worldViewDir;
|
||||
float3 viewDir;
|
||||
SurfaceOutput o = frag_common(IN, worldPos, worldViewDir, viewDir);
|
||||
|
||||
// compute lighting & shadowing factor
|
||||
UNITY_LIGHT_ATTENUATION(atten, IN, worldPos)
|
||||
|
||||
#ifndef USING_DIRECTIONAL_LIGHT
|
||||
fixed3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos));
|
||||
#else
|
||||
fixed3 lightDir = _WorldSpaceLightPos0.xyz;
|
||||
#endif
|
||||
|
||||
// Setup lighting environment
|
||||
UnityGI gi;
|
||||
UNITY_INITIALIZE_OUTPUT(UnityGI, gi);
|
||||
gi.indirect.diffuse = 0;
|
||||
gi.indirect.specular = 0;
|
||||
gi.light.color = _LightColor0.rgb;
|
||||
gi.light.dir = lightDir;
|
||||
|
||||
#ifdef UNITY_PASS_FORWARDBASE
|
||||
// Call GI (lightmaps/SH/reflections) lighting function
|
||||
UnityGIInput giInput;
|
||||
UNITY_INITIALIZE_OUTPUT(UnityGIInput, giInput);
|
||||
giInput.light = gi.light;
|
||||
giInput.worldPos = worldPos;
|
||||
giInput.worldViewDir = worldViewDir;
|
||||
giInput.atten = atten;
|
||||
|
||||
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
||||
giInput.ambient = IN.sh;
|
||||
#else
|
||||
giInput.ambient.rgb = 0.0;
|
||||
#endif
|
||||
|
||||
LightingBlinnPhongKSP_GI(o, giInput, gi);
|
||||
#endif
|
||||
|
||||
#ifdef UNITY_PASS_FORWARDADD
|
||||
gi.light.color *= atten;
|
||||
#endif
|
||||
|
||||
//call modified KSP lighting function
|
||||
c += LightingBlinnPhongKSP(o, viewDir, gi);
|
||||
c.rgb += o.Emission;
|
||||
return c;
|
||||
}
|
||||
|
||||
void frag_deferred (v2f IN,
|
||||
out half4 outGBuffer0 : SV_Target0,
|
||||
out half4 outGBuffer1 : SV_Target1,
|
||||
#if defined(DECAL_BUMPMAP) || defined(DECAL_PREVIEW)
|
||||
out half4 outGBuffer2 : SV_Target2,
|
||||
#endif
|
||||
out half4 outEmission : SV_Target3)
|
||||
{
|
||||
#if !(defined(DECAL_BUMPMAP) || defined(DECAL_PREVIEW))
|
||||
half4 outGBuffer2 = 0; // define dummy normal buffer when we're not writing to it
|
||||
#endif
|
||||
|
||||
float3 worldPos;
|
||||
float3 worldViewDir;
|
||||
float3 viewDir;
|
||||
SurfaceOutput o = frag_common(IN, worldPos, worldViewDir, viewDir);
|
||||
|
||||
// Setup lighting environment
|
||||
UnityGI gi;
|
||||
UNITY_INITIALIZE_OUTPUT(UnityGI, gi);
|
||||
gi.indirect.diffuse = 0;
|
||||
gi.indirect.specular = 0;
|
||||
gi.light.color = 0;
|
||||
gi.light.dir = half3(0,1,0);
|
||||
|
||||
UnityGIInput giInput;
|
||||
UNITY_INITIALIZE_OUTPUT(UnityGIInput, giInput);
|
||||
giInput.light = gi.light;
|
||||
giInput.worldPos = worldPos;
|
||||
giInput.worldViewDir = worldViewDir;
|
||||
giInput.atten = 1;
|
||||
giInput.lightmapUV = 0.0;
|
||||
|
||||
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
||||
giInput.ambient = 0.0 * IN.sh;
|
||||
#else
|
||||
giInput.ambient.rgb = 0.0;
|
||||
#endif
|
||||
|
||||
giInput.probeHDR[0] = unity_SpecCube0_HDR;
|
||||
giInput.probeHDR[1] = unity_SpecCube1_HDR;
|
||||
|
||||
LightingBlinnPhongKSP_GI(o, giInput, gi);
|
||||
|
||||
outEmission = LightingBlinnPhongKSP_Deferred(o, worldViewDir, gi, outGBuffer0, outGBuffer1, outGBuffer2);
|
||||
|
||||
// outGBuffer0 = outEmission;
|
||||
|
||||
#ifndef UNITY_HDR_ON
|
||||
outEmission.rgb = exp2(-outEmission.rgb);
|
||||
#endif
|
||||
|
||||
outGBuffer0.a = o.Alpha;
|
||||
outGBuffer1 *= o.Alpha;
|
||||
outGBuffer2.a = o.Alpha;
|
||||
outEmission.a = o.Alpha;
|
||||
|
||||
}
|
||||
|
||||
void frag_deferred_prepass(v2f IN, out half4 outGBuffer1: SV_Target1) {
|
||||
float3 worldPos;
|
||||
float3 worldViewDir;
|
||||
float3 viewDir;
|
||||
SurfaceOutput o = frag_common(IN, worldPos, worldViewDir, viewDir);
|
||||
|
||||
outGBuffer1 = o.Alpha;
|
||||
}
|
||||
|
||||
#endif
|
@ -1,28 +1,27 @@
|
||||
#include "DecalsCommon.cginc"
|
||||
#include "../SDF.cginc"
|
||||
|
||||
void surf(DecalSurfaceInput IN, inout SurfaceOutput o) {
|
||||
float4 color = tex2D(_Decal, IN.uv_decal);
|
||||
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
||||
o.Alpha = _DecalOpacity;
|
||||
o.Albedo = color.rgb;
|
||||
o.Specular = 0.4;
|
||||
o.Gloss = _Shininess;
|
||||
|
||||
#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);
|
||||
o.Normal = UnpackNormalDXT5nm(tex2D(_BumpMap, IN.uv_bumpmap));
|
||||
#endif
|
||||
|
||||
#ifdef DECAL_SPECMAP
|
||||
float4 specular = tex2D(_SpecMap, IN.uv_specmap);
|
||||
o.Gloss = specular.r;
|
||||
o.Specular = _Shininess;
|
||||
o.Specular = specular;
|
||||
#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
|
||||
@ -34,5 +33,5 @@ void surf(DecalSurfaceInput IN, inout SurfaceOutput o) {
|
||||
#else
|
||||
o.Alpha *= SDFAA(dist);
|
||||
o.Alpha *= color.a;
|
||||
#endif
|
||||
#endif
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
{% extends "DecalBase.shader.template" %}
|
||||
{% block shader_name %}Standard{% endblock %}
|
||||
|
||||
{% block 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)
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
#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 "StandardDecal.cginc"
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block pragmas_deferred_prepass %}
|
||||
#pragma skip_variants DECAL_SPECMAP DECAL_EMISSIVE DECAL_BUMPMAP
|
||||
{% endblock %}
|
@ -1,3 +1,6 @@
|
||||
#include "DecalsCommon.cginc"
|
||||
#include "../SDF.cginc"
|
||||
|
||||
float4 _DecalColor;
|
||||
|
||||
float4 _OutlineColor;
|
||||
@ -5,8 +8,11 @@ float _OutlineWidth;
|
||||
|
||||
void surf(DecalSurfaceInput IN, inout SurfaceOutput o) {
|
||||
float4 color = _DecalColor;
|
||||
o.Specular = 0.4;
|
||||
o.Gloss = _Shininess;
|
||||
|
||||
float dist = _Cutoff - tex2D(_Decal, IN.uv_decal).r; // text distance
|
||||
|
||||
|
||||
#ifdef DECAL_OUTLINE
|
||||
// Outline
|
||||
float outlineOffset = _OutlineWidth * 0.25;
|
||||
@ -28,8 +34,8 @@ void surf(DecalSurfaceInput IN, inout SurfaceOutput o) {
|
||||
|
||||
dist = max(dist, BoundsDist(IN.uv, IN.vertex_normal, _DecalNormal));
|
||||
float ddist = SDFdDist(dist); // distance gradient magnitude
|
||||
o.Alpha = _DecalOpacity * SDFAA(dist, ddist);
|
||||
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
||||
o.Albedo = color.rgb;
|
||||
o.Alpha *= SDFAA(dist, ddist);
|
||||
|
||||
#ifdef DECAL_BASE_NORMAL
|
||||
float3 normal = IN.normal;
|
||||
@ -40,10 +46,6 @@ void surf(DecalSurfaceInput IN, inout SurfaceOutput o) {
|
||||
|
||||
#ifdef DECAL_SPECMAP
|
||||
float4 specular = tex2D(_SpecMap, IN.uv_specmap);
|
||||
o.Gloss = specular.r;
|
||||
o.Specular = _Shininess;
|
||||
o.Specular = specular;
|
||||
#endif
|
||||
|
||||
half rim = 1.0 - saturate(dot(normalize(IN.viewDir), o.Normal));
|
||||
o.Emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
{% extends "DecalBase.shader.template" %}
|
||||
{% block shader_name %}Text{% endblock %}
|
||||
|
||||
{% block properties %}
|
||||
[Header(Decal)]
|
||||
[Toggle(DECAL_FILL)] _Fill ("Fill", int) = 0
|
||||
_Decal("Decal Texture", 2D) = "gray" {}
|
||||
_DecalColor("Decal Color", Color) = (1,1,1,1)
|
||||
|
||||
_Weight("Text Weight", Range(0,1)) = 0
|
||||
|
||||
[Header(Outline)]
|
||||
[Toggle(DECAL_OUTLINE)] _Outline ("Outline", int) = 0
|
||||
_OutlineColor("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineWidth("Outline Width", Range(0,1)) = 0.1
|
||||
|
||||
[Header(Normal)]
|
||||
[Toggle(DECAL_BASE_NORMAL)] _BaseNormal ("Use Base Normal", 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
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
#pragma multi_compile_local __ DECAL_BASE_NORMAL
|
||||
#pragma multi_compile_local __ DECAL_SPECMAP
|
||||
#pragma multi_compile_local __ DECAL_OUTLINE
|
||||
#pragma multi_compile_local __ DECAL_FILL
|
||||
|
||||
#include "TextDecal.cginc"
|
||||
{% endblock %}
|
||||
|
||||
{% block pragmas_deferred_prepass %}
|
||||
#pragma skip_variants DECAL_SPECMAP
|
||||
{% endblock %}
|
@ -29,7 +29,7 @@ Shader "ConformalDecals/Decal Back"
|
||||
CGPROGRAM
|
||||
|
||||
#include "LightingKSP.cginc"
|
||||
#pragma surface surf BlinnPhongSmooth vertex:vert
|
||||
#pragma surface surf BlinnPhongKSP vertex:vert
|
||||
#pragma target 3.0
|
||||
|
||||
sampler2D _MainTex;
|
||||
@ -63,12 +63,12 @@ Shader "ConformalDecals/Decal Back"
|
||||
// 45° rotation
|
||||
uv_MainTex.x = IN.uv_MainTex.x - IN.uv_MainTex.y;
|
||||
uv_MainTex.y = IN.uv_MainTex.x + IN.uv_MainTex.y;
|
||||
|
||||
|
||||
// stagger every other row
|
||||
uv_MainTex.y *= 2;
|
||||
int row = floor(uv_MainTex.y);
|
||||
uv_MainTex.x += row * _RowOffset;
|
||||
uv_MainTex.y *= 2;
|
||||
|
||||
|
||||
float4 color = _Color * tex2D(_MainTex,(uv_MainTex));
|
||||
float3 normal = UnpackNormal(tex2D(_BumpMap, uv_BumpMap));
|
||||
|
161
Assets/ConformalDecals/Shaders/LightingKSP.cginc
Normal file
@ -0,0 +1,161 @@
|
||||
// WHAT IS THIS FILE?
|
||||
// this file provides a replacement for the LightingKSP.cginc file that ships with part tools for writing custom shaders.
|
||||
// This version enables support for the Deferred mod
|
||||
//
|
||||
// HOW DO I USE IT?
|
||||
// Step 1)
|
||||
// replace LightingKSP.cginc in your shader folder with this file, if present. If you aren't using LightingKSP.cginc
|
||||
// in your shader, add the following below `CGPROGRAM`:
|
||||
// `#include "../LightingKSP.cginc"`
|
||||
//
|
||||
// Step 2)
|
||||
// add the following above `CGPROGRAM`:
|
||||
// ```
|
||||
// Stencil
|
||||
// {
|
||||
// Ref 1
|
||||
// Comp Always
|
||||
// Pass Replace
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// Step 3)
|
||||
// there should be a line in your shader that looks like this:
|
||||
// `#pragma surface surf BlinnPhongSmooth keepalpha`
|
||||
// Remove the `keepalpha` if it's there. the part after `surf` is the name of the lighting function your shader uses now.
|
||||
// If the lighting function is `BlinnPhong` or `BlinnPhongSmooth`, change it to `BlinnPhongKSP`
|
||||
// If the lighting function is `Standard`, change it to `StandardKSP`
|
||||
// If the lighting function is `StandardSpecular`, change it to `StandardSpecularKSP`
|
||||
|
||||
#ifndef LIGHTING_KSP_INCLUDED
|
||||
#define LIGHTING_KSP_INCLUDED
|
||||
|
||||
#include "UnityPBSLighting.cginc"
|
||||
|
||||
#define blinnPhongShininessPower 0.215
|
||||
|
||||
// An exact conversion from blinn-phong to PBR is impossible, but the look can be approximated perceptually
|
||||
// and by observing how blinn-phong looks and feels at various settings, although it can never be perfect
|
||||
// 1) The specularColor can be used as is in the PBR specular flow, just needs to be divided by PI so it sums up to 1 over the hemisphere
|
||||
// 2) Blinn-phong shininess doesn't stop feeling shiny unless at very low values, like below 0.04
|
||||
// while the PBR smoothness feels more linear -> map shininess to smoothness accordingly using a function
|
||||
// that increases very quickly at first then slows down, I went with something like x^(1/4) or x^(1/6) then made the power configurable
|
||||
// I tried various mappings from the literature but nothing really worked as well as this
|
||||
// 3) Finally I noticed that some parts still looked very shiny like the AV-R8 winglet while in stock they looked rough thanks a low
|
||||
// specularColor but high shininess and specularMap, so I multiplied the smoothness by the sqrt of the specularColor and that caps
|
||||
// the smoothness when specularColor is low
|
||||
void GetStandardSpecularPropertiesFromLegacy(float legacyShininess, float specularMap, out float3 specular,
|
||||
out float smoothness)
|
||||
{
|
||||
float3 legacySpecularColor = saturate(_SpecColor);
|
||||
|
||||
smoothness = pow(legacyShininess, blinnPhongShininessPower) * specularMap;
|
||||
smoothness *= sqrt(length(legacySpecularColor));
|
||||
|
||||
specular = legacySpecularColor * UNITY_INV_PI;
|
||||
}
|
||||
|
||||
float4 _Color;
|
||||
|
||||
// LEGACY BLINN-PHONG LIGHTING FUNCTION FOR KSP WITH PBR CONVERSION FOR DEFERRED
|
||||
|
||||
inline float4 LightingBlinnPhongKSP(SurfaceOutput s, half3 viewDir, UnityGI gi)
|
||||
{
|
||||
return LightingBlinnPhong(s,viewDir, gi);
|
||||
}
|
||||
|
||||
inline float4 LightingBlinnPhongKSP_Deferred(SurfaceOutput s, float3 worldViewDir, UnityGI gi,
|
||||
out float4 outDiffuseOcclusion, out float4 outSpecSmoothness,
|
||||
out float4 outNormal)
|
||||
{
|
||||
SurfaceOutputStandardSpecular ss;
|
||||
ss.Albedo = s.Albedo;
|
||||
ss.Normal = s.Normal;
|
||||
ss.Emission = s.Emission;
|
||||
ss.Occlusion = 1;
|
||||
ss.Alpha = saturate(s.Alpha);
|
||||
GetStandardSpecularPropertiesFromLegacy(s.Specular, s.Gloss, ss.Specular, ss.Smoothness);
|
||||
|
||||
return LightingStandardSpecular_Deferred(ss, worldViewDir, gi, outDiffuseOcclusion, outSpecSmoothness, outNormal);
|
||||
}
|
||||
|
||||
inline void LightingBlinnPhongKSP_GI(inout SurfaceOutput s, UnityGIInput gi_input, inout UnityGI gi)
|
||||
{
|
||||
#ifndef UNITY_PASS_DEFERRED
|
||||
gi = UnityGlobalIllumination(gi_input, 1.0, s.Normal);
|
||||
#endif
|
||||
}
|
||||
|
||||
// STANDARD UNITY LIGHTING FUNCTION FOR KSP
|
||||
|
||||
inline float4 LightingStandardKSP(SurfaceOutputStandard s, float3 worldViewDir, UnityGI gi)
|
||||
{
|
||||
return LightingStandard(s, worldViewDir, gi); // no change
|
||||
}
|
||||
|
||||
inline float4 LightingStandardKSP_Deferred(SurfaceOutputStandard s, float3 worldViewDir, UnityGI gi,
|
||||
out float4 outDiffuseOcclusion,
|
||||
out float4 outSpecSmoothness, out float4 outNormal)
|
||||
{
|
||||
return LightingStandard_Deferred(s, worldViewDir, gi, outDiffuseOcclusion, outSpecSmoothness, outNormal);
|
||||
}
|
||||
|
||||
inline void LightingStandardKSP_GI(inout SurfaceOutputStandard s, UnityGIInput gi_input, inout UnityGI gi)
|
||||
{
|
||||
#ifndef UNITY_PASS_DEFERRED
|
||||
LightingStandard_GI(s, gi_input, gi);
|
||||
#endif
|
||||
}
|
||||
|
||||
// STANDARD SPECULAR UNITY LIGHTING FUNCTION FOR KSP
|
||||
|
||||
inline float4 LightingStandardSpecularKSP(SurfaceOutputStandardSpecular s, float3 worldViewDir, UnityGI gi)
|
||||
{
|
||||
return LightingStandardSpecular(s, worldViewDir, gi); // no change
|
||||
}
|
||||
|
||||
inline float4 LightingStandardSpecularKSP_Deferred(SurfaceOutputStandardSpecular s, float3 worldViewDir, UnityGI gi,
|
||||
out float4 outDiffuseOcclusion,
|
||||
out float4 outSpecSmoothness, out float4 outNormal)
|
||||
{
|
||||
return LightingStandardSpecular_Deferred(s, worldViewDir, gi, outDiffuseOcclusion, outSpecSmoothness, outNormal);
|
||||
}
|
||||
|
||||
inline void LightingStandardSpecularKSP_GI(inout SurfaceOutputStandardSpecular s, UnityGIInput gi_input,
|
||||
inout UnityGI gi)
|
||||
{
|
||||
#ifndef UNITY_PASS_DEFERRED
|
||||
LightingStandardSpecular_GI(s, gi_input, gi);
|
||||
#endif
|
||||
}
|
||||
|
||||
float4 _LocalCameraPos;
|
||||
float4 _LocalCameraDir;
|
||||
float4 _UnderwaterFogColor;
|
||||
float _UnderwaterMinAlphaFogDistance;
|
||||
float _UnderwaterMaxAlbedoFog;
|
||||
float _UnderwaterMaxAlphaFog;
|
||||
float _UnderwaterAlbedoDistanceScalar;
|
||||
float _UnderwaterAlphaDistanceScalar;
|
||||
float _UnderwaterFogFactor;
|
||||
|
||||
float4 UnderwaterFog(float3 worldPos, float3 color)
|
||||
{
|
||||
// skip fog in deferred mode
|
||||
#ifdef UNITY_PASS_DEFERRED
|
||||
return float4(color, 1);
|
||||
#endif
|
||||
|
||||
float3 toPixel = worldPos - _LocalCameraPos.xyz;
|
||||
float toPixelLength = length(toPixel); ///< Comment out the math--looks better without it.
|
||||
|
||||
float underwaterDetection = _UnderwaterFogFactor * _LocalCameraDir.w; ///< sign(1 - sign(_LocalCameraPos.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
|
@ -4,11 +4,11 @@ Shader "ConformalDecals/UI/Color Slider"
|
||||
{
|
||||
_Color("Color", Color) = (0,0,0,0)
|
||||
_Radius("Radius", Float) = 4
|
||||
|
||||
|
||||
_OutlineGradient("Outline Gradient Step", Range (0, 1)) = 0.6
|
||||
_OutlineOpacity("Outline Opacity", Range (0, 0.5)) = 0.1
|
||||
_OutlineWidth("Outline Width", Float) = 3
|
||||
|
||||
|
||||
_StencilComp ("Stencil Comparison", Float) = 8
|
||||
_Stencil ("Stencil ID", Float) = 0
|
||||
_StencilOp ("Stencil Operation", Float) = 0
|
||||
@ -18,13 +18,11 @@ Shader "ConformalDecals/UI/Color Slider"
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||
|
||||
|
||||
[Toggle(HUE)] _Hue ("Hue", int) = 0
|
||||
[Toggle(RED)] _Red ("Red", int) = 0
|
||||
[Toggle(GREEN)] _Green ("Green", int) = 0
|
||||
[Toggle(BLUE)] _Blue ("Blue", int) = 0
|
||||
|
||||
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
@ -44,14 +42,14 @@ Shader "ConformalDecals/UI/Color Slider"
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest [unity_GUIZTestMode]
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
@ -63,7 +61,7 @@ Shader "ConformalDecals/UI/Color Slider"
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
#include "HSL.cginc"
|
||||
#include "SDF.cginc"
|
||||
#include "../SDF.cginc"
|
||||
|
||||
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile_local _ UNITY_UI_ALPHACLIP
|
@ -8,7 +8,7 @@ Shader "ConformalDecals/UI/HSV Square"
|
||||
_OutlineGradient("Outline Gradient Step", Range (0, 1)) = 0.6
|
||||
_OutlineOpacity("Outline Opacity", Range (0, 0.5)) = 0.1
|
||||
_OutlineWidth("Outline Width", Float) = 3
|
||||
|
||||
|
||||
_StencilComp ("Stencil Comparison", Float) = 8
|
||||
_Stencil ("Stencil ID", Float) = 0
|
||||
_StencilOp ("Stencil Operation", Float) = 0
|
||||
@ -37,14 +37,14 @@ Shader "ConformalDecals/UI/HSV Square"
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest [unity_GUIZTestMode]
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
@ -56,7 +56,7 @@ Shader "ConformalDecals/UI/HSV Square"
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
#include "HSL.cginc"
|
||||
#include "SDF.cginc"
|
||||
#include "../SDF.cginc"
|
||||
|
||||
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile_local _ UNITY_UI_ALPHACLIP
|
@ -4,11 +4,11 @@ Shader "ConformalDecals/UI/Color Swatch"
|
||||
{
|
||||
_Color("Color", Color) = (0,0,0,0)
|
||||
_Radius("Radius", Float) = 4
|
||||
|
||||
|
||||
_OutlineGradient("Outline Gradient Step", Range (0, 1)) = 0.6
|
||||
_OutlineOpacity("Outline Opacity", Range (0, 0.5)) = 0.1
|
||||
_OutlineWidth("Outline Width", Float) = 3
|
||||
|
||||
|
||||
_StencilComp ("Stencil Comparison", Float) = 8
|
||||
_Stencil ("Stencil ID", Float) = 0
|
||||
_StencilOp ("Stencil Operation", Float) = 0
|
||||
@ -37,14 +37,14 @@ Shader "ConformalDecals/UI/Color Swatch"
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest [unity_GUIZTestMode]
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
@ -56,7 +56,7 @@ Shader "ConformalDecals/UI/Color Swatch"
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
#include "HSL.cginc"
|
||||
#include "SDF.cginc"
|
||||
#include "../SDF.cginc"
|
||||
|
||||
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile_local _ UNITY_UI_ALPHACLIP
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
BIN
Assets/ConformalDecals/Textures/Decal-Blank.afdesign
Normal file
BIN
Assets/ConformalDecals/Textures/Decal-Blank.afdesign~lock~
Normal file
BIN
Assets/ConformalDecals/Textures/Decal-Spec.tif
Normal file
BIN
Assets/ConformalDecals/Textures/Icons Generic.afdesign
Normal file
Before Width: | Height: | Size: 470 KiB After Width: | Height: | Size: 470 KiB |
BIN
Assets/ConformalDecals/Textures/Munar.afdesign
Normal file
BIN
Assets/ConformalDecals/Textures/Paper-Wrinkle-n.png
Normal file
After Width: | Height: | Size: 1.4 MiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
BIN
Assets/ConformalDecals/Textures/Semiotic.afdesign
Normal file
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 260 B After Width: | Height: | Size: 260 B |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 169 B After Width: | Height: | Size: 169 B |
BIN
Assets/ConformalDecals/Textures/paper-spec.png
Normal file
After Width: | Height: | Size: 74 KiB |
BIN
Assets/ConformalDecals/Textures/paper.png
Normal file
After Width: | Height: | Size: 48 KiB |
@ -1,46 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class DecalProjectorTest : MonoBehaviour
|
||||
{
|
||||
public GameObject target = null;
|
||||
public Material targetMaterial = null;
|
||||
public MeshRenderer targetRenderer;
|
||||
|
||||
|
||||
public float aspectRatio = 1.0f;
|
||||
public float size = 1.0f;
|
||||
public float factor = 1.0f;
|
||||
|
||||
private Matrix4x4 _projectionMatrix;
|
||||
private Matrix4x4 _OrthoMatrix;
|
||||
|
||||
private int _matrixID;
|
||||
private int _normalID;
|
||||
public int _tangentID;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
_projectionMatrix = Matrix4x4.identity;
|
||||
targetRenderer = target.GetComponent<MeshRenderer>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
Vector3 pos =new Vector3( 0.5f ,0.5f, 0);
|
||||
Vector3 scale = new Vector3(1 / size, 1 / (aspectRatio * size), 1);
|
||||
_OrthoMatrix.SetTRS(pos, Quaternion.identity, scale);
|
||||
//Debug.Log(_OrthoMatrix);
|
||||
var targetToProjector = transform.worldToLocalMatrix * targetRenderer.localToWorldMatrix;
|
||||
var projectorToTarget = targetRenderer.worldToLocalMatrix * transform.localToWorldMatrix;
|
||||
_projectionMatrix = _OrthoMatrix * targetToProjector;
|
||||
|
||||
targetMaterial.SetMatrix("_ProjectionMatrix", _projectionMatrix);
|
||||
targetMaterial.SetVector("_DecalNormal", projectorToTarget.MultiplyVector(Vector3.back).normalized);
|
||||
targetMaterial.SetVector("_DecalTangent", projectorToTarget.MultiplyVector(Vector3.right).normalized);
|
||||
}
|
||||
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
public class TextRenderTest : MonoBehaviour {
|
||||
//[InspectorButton("go")] public bool button;
|
||||
|
||||
public Camera _camera;
|
||||
|
||||
public GameObject _cameraObject;
|
||||
|
||||
public TextMeshPro _tmp;
|
||||
|
||||
public Material _blitMaterial;
|
||||
|
||||
public Material _targetMaterial;
|
||||
|
||||
public RenderTexture renderTex;
|
||||
private float pixelDensity = 8;
|
||||
private int MaxTextureSize = 4096;
|
||||
private static readonly int Decal = Shader.PropertyToID("_Decal");
|
||||
|
||||
public const TextureFormat TextTextureFormat = TextureFormat.RG16;
|
||||
public const RenderTextureFormat TextRenderTextureFormat = RenderTextureFormat.R8;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start() {
|
||||
Debug.Log("starting...");
|
||||
|
||||
StartCoroutine(OnRender());
|
||||
var thing = new GameObject();
|
||||
thing.AddComponent<TextMeshPro>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update() { }
|
||||
|
||||
private IEnumerator OnRender() {
|
||||
Debug.Log("starting...2");
|
||||
|
||||
// calculate camera and texture size
|
||||
_tmp.ForceMeshUpdate();
|
||||
var mesh = _tmp.mesh;
|
||||
mesh.RecalculateBounds();
|
||||
var bounds = mesh.bounds;
|
||||
Debug.Log(bounds.size);
|
||||
|
||||
var width = bounds.size.x * pixelDensity;
|
||||
var height = bounds.size.y * pixelDensity;
|
||||
|
||||
var widthPoT = Mathf.NextPowerOfTwo((int) width);
|
||||
var heightPoT = Mathf.NextPowerOfTwo((int) height);
|
||||
|
||||
if (widthPoT > MaxTextureSize) {
|
||||
widthPoT /= widthPoT / MaxTextureSize;
|
||||
heightPoT /= widthPoT / MaxTextureSize;
|
||||
}
|
||||
|
||||
if (heightPoT > MaxTextureSize) {
|
||||
widthPoT /= heightPoT / MaxTextureSize;
|
||||
heightPoT /= heightPoT / MaxTextureSize;
|
||||
}
|
||||
|
||||
widthPoT = Mathf.Min(widthPoT, MaxTextureSize);
|
||||
heightPoT = Mathf.Min(heightPoT, MaxTextureSize);
|
||||
|
||||
var widthRatio = widthPoT / width;
|
||||
var heightRatio = heightPoT / height;
|
||||
|
||||
var sizeRatio = Mathf.Min(widthRatio, heightRatio);
|
||||
|
||||
Debug.Log(sizeRatio);
|
||||
|
||||
int scaledHeight = (int) (sizeRatio * height);
|
||||
int scaledWidth = (int) (sizeRatio * width);
|
||||
|
||||
Debug.Log($"width = {scaledWidth}");
|
||||
Debug.Log($"height = {scaledHeight}");
|
||||
|
||||
_camera.orthographicSize = scaledHeight / pixelDensity / 2;
|
||||
_camera.aspect = (float) widthPoT / heightPoT;
|
||||
|
||||
_cameraObject.transform.localPosition = new Vector3(bounds.center.x, bounds.center.y, -1);
|
||||
|
||||
var halfHeight = heightPoT / pixelDensity / 2 / sizeRatio;
|
||||
var halfWidth = widthPoT / pixelDensity / 2 / sizeRatio;
|
||||
var matrix = Matrix4x4.Ortho(bounds.center.x - halfWidth, bounds.center.x + halfWidth,
|
||||
bounds.center.y - halfHeight, bounds.center.y + halfHeight, -1, 1);
|
||||
|
||||
// setup texture
|
||||
var texture = new Texture2D(widthPoT, heightPoT, TextTextureFormat, true);
|
||||
_targetMaterial.SetTexture(Decal, texture);
|
||||
|
||||
|
||||
// setup render texture
|
||||
renderTex = RenderTexture.GetTemporary(widthPoT, heightPoT, 0, TextRenderTextureFormat, RenderTextureReadWrite.Linear, 1);
|
||||
renderTex.autoGenerateMips = false;
|
||||
|
||||
RenderTexture.active = renderTex;
|
||||
GL.PushMatrix();
|
||||
GL.LoadProjectionMatrix(matrix);
|
||||
_blitMaterial.SetPass(0);
|
||||
Graphics.DrawMeshNow(mesh, Matrix4x4.identity);
|
||||
GL.PopMatrix();
|
||||
|
||||
// setup material
|
||||
_blitMaterial.mainTexture = _tmp.font.atlas;
|
||||
|
||||
yield return null;
|
||||
|
||||
RenderTexture.active = renderTex;
|
||||
texture.ReadPixels(new Rect(0, 0, widthPoT, heightPoT), 0, 0, true);
|
||||
texture.Apply(false, true);
|
||||
|
||||
RenderTexture.ReleaseTemporary(renderTex);
|
||||
}
|
||||
}
|
@ -1,156 +0,0 @@
|
||||
#ifndef DECALS_COMMON_INCLUDED
|
||||
#define DECALS_COMMON_INCLUDED
|
||||
|
||||
#include "AutoLight.cginc"
|
||||
#include "Lighting.cginc"
|
||||
|
||||
#define CLIP_MARGIN 0.05
|
||||
#define EDGE_MARGIN 0.01
|
||||
|
||||
// UNIFORM VARIABLES
|
||||
// Projection matrix, normal, and tangent vectors
|
||||
float4x4 _ProjectionMatrix;
|
||||
float3 _DecalNormal;
|
||||
float3 _DecalTangent;
|
||||
|
||||
// Common Shading Paramaters
|
||||
float _Cutoff;
|
||||
float _DecalOpacity;
|
||||
float4 _Background;
|
||||
|
||||
sampler2D _Decal;
|
||||
float4 _Decal_ST;
|
||||
|
||||
// Variant Shading Parameters
|
||||
#ifdef DECAL_BASE_NORMAL
|
||||
sampler2D _BumpMap;
|
||||
float4 _BumpMap_ST;
|
||||
float _EdgeWearStrength;
|
||||
float _EdgeWearOffset;
|
||||
#endif //DECAL_BASE_NORMAL
|
||||
|
||||
#ifdef DECAL_BUMPMAP
|
||||
sampler2D _BumpMap;
|
||||
float4 _BumpMap_ST;
|
||||
#endif //DECAL_BUMPMAP
|
||||
|
||||
#ifdef DECAL_SPECMAP
|
||||
sampler2D _SpecMap;
|
||||
float4 _SpecMap_ST;
|
||||
// specular color is declared in a unity CGINC for some reason??
|
||||
fixed _Shininess;
|
||||
#endif //DECAL_SPECMAP
|
||||
|
||||
#ifdef DECAL_EMISSIVE
|
||||
sampler2D _Emissive;
|
||||
float4 _Emissive_ST;
|
||||
fixed4 _Emissive_Color;
|
||||
#endif //DECAL_EMISSIVE
|
||||
|
||||
// KSP EFFECTS
|
||||
// opacity and color
|
||||
float _Opacity;
|
||||
float4 _Color;
|
||||
float _RimFalloff;
|
||||
float4 _RimColor;
|
||||
|
||||
// fog
|
||||
float4 _LocalCameraPos;
|
||||
float4 _LocalCameraDir;
|
||||
float4 _UnderwaterFogColor;
|
||||
float _UnderwaterMinAlphaFogDistance;
|
||||
float _UnderwaterMaxAlbedoFog;
|
||||
float _UnderwaterMaxAlphaFog;
|
||||
float _UnderwaterAlbedoDistanceScalar;
|
||||
float _UnderwaterAlphaDistanceScalar;
|
||||
float _UnderwaterFogFactor;
|
||||
|
||||
// SURFACE INPUT STRUCT
|
||||
struct DecalSurfaceInput
|
||||
{
|
||||
float3 uv;
|
||||
float2 uv_decal;
|
||||
|
||||
#ifdef DECAL_BUMPMAP
|
||||
float2 uv_bumpmap;
|
||||
#endif //DECAL_BUMPMAP
|
||||
|
||||
#ifdef DECAL_SPECMAP
|
||||
float2 uv_specmap;
|
||||
#endif //DECAL_SPECMAP
|
||||
|
||||
#ifdef DECAL_EMISSIVE
|
||||
float2 uv_emissive;
|
||||
#endif //DECAL_EMISSIVE
|
||||
|
||||
#ifdef DECAL_BASE_NORMAL
|
||||
float3 normal;
|
||||
#endif //DECAL_BASE_NORMAL
|
||||
|
||||
float3 vertex_normal;
|
||||
float3 viewDir;
|
||||
float3 worldPosition;
|
||||
};
|
||||
|
||||
struct appdata_decal
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
#if defined(DECAL_BASE_NORMAL) || defined(DECAL_PREVIEW)
|
||||
float4 texcoord : TEXCOORD0;
|
||||
float4 tangent : TANGENT;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
UNITY_POSITION(pos);
|
||||
float3 normal : NORMAL;
|
||||
float4 uv_decal : TEXCOORD0;
|
||||
|
||||
#ifdef DECAL_BASE_NORMAL
|
||||
float2 uv_base : TEXCOORD1;
|
||||
#endif //DECAL_BASE_NORMAL
|
||||
|
||||
float4 tSpace0 : TEXCOORD2;
|
||||
float4 tSpace1 : TEXCOORD3;
|
||||
float4 tSpace2 : TEXCOORD4;
|
||||
|
||||
#ifdef UNITY_PASS_FORWARDBASE
|
||||
fixed3 vlight : TEXCOORD5;
|
||||
UNITY_SHADOW_COORDS(6)
|
||||
#endif //UNITY_PASS_FORWARDBASE
|
||||
|
||||
#ifdef UNITY_PASS_FORWARDADD
|
||||
UNITY_LIGHTING_COORDS(5,6)
|
||||
#endif //UNITY_PASS_FORWARDADD
|
||||
};
|
||||
|
||||
|
||||
inline void decalClipAlpha(float alpha) {
|
||||
#ifndef DECAL_PREVIEW
|
||||
clip(alpha - 0.001);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline float CalcMipLevel(float2 texture_coord) {
|
||||
float2 dx = ddx(texture_coord);
|
||||
float2 dy = ddy(texture_coord);
|
||||
float delta_max_sqr = max(dot(dx, dx), dot(dy, dy));
|
||||
|
||||
return 0.5 * log2(delta_max_sqr);
|
||||
}
|
||||
|
||||
inline float BoundsDist(float3 p, float3 normal, float3 projNormal) {
|
||||
float3 q = abs(p - 0.5) - 0.5; // 1x1 square/cube centered at (0.5,0.5)
|
||||
//float dist = length(max(q,0)) + min(max(q.x,max(q.y,q.z)),0.0); // true SDF
|
||||
#ifdef DECAL_PREVIEW
|
||||
return 10 * max(q.x, q.y); // 2D pseudo SDF
|
||||
#else
|
||||
float dist = max(max(q.x, q.y), q.z); // pseudo SDF
|
||||
float ndist = EDGE_MARGIN - dot(normal, projNormal); // SDF to normal
|
||||
return 10 * max(dist, ndist); // return intersection
|
||||
#endif //DECAL_PREVIEW
|
||||
}
|
||||
|
||||
#endif
|
@ -1,33 +0,0 @@
|
||||
#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
|
@ -1,183 +0,0 @@
|
||||
#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
|
@ -1,102 +0,0 @@
|
||||
#ifndef LIGHTING_KSP_INCLUDED
|
||||
#define LIGHTING_KSP_INCLUDED
|
||||
|
||||
inline fixed4 LightingBlinnPhongSmooth(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;
|
||||
c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * _SpecColor.rgb * spec) * (atten);
|
||||
c.a = s.Alpha + _LightColor0.a * _SpecColor.a * spec * atten;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline half4 LightingUnlit(SurfaceOutput s, half3 lightDir, half atten)
|
||||
{
|
||||
// half diff = max (0, dot (s.Normal, lightDir));
|
||||
|
||||
half4 c;
|
||||
c.rgb = s.Albedo;
|
||||
c.a = s.Alpha;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline half4 LightingUnlit_PrePass(SurfaceOutput s, half4 light)
|
||||
{
|
||||
half4 c;
|
||||
c.rgb = s.Albedo;
|
||||
c.a = s.Alpha;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
fixed4 LightingNoLighting(SurfaceOutput s, fixed3 lightDir, fixed atten) { return fixed4(0, 0, 0, 0); }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
float4 _Color;
|
||||
half _LightBoost;
|
||||
half4 LightingLightWrapped(SurfaceOutput s, half3 lightDir, half3 viewDir, half atten) {
|
||||
float3 w = _Color.rgb*0.5;
|
||||
half3 NdotL = dot(s.Normal, lightDir);
|
||||
|
||||
//Specular term
|
||||
half3 h = normalize(lightDir + viewDir);
|
||||
s.Normal = normalize(s.Normal);
|
||||
float NdotH = dot(s.Normal, h);
|
||||
float spec = pow(max(NdotH, 0), s.Specular * 128.0) * s.Gloss;
|
||||
fixed3 specColor = _SpecColor.rgb * _LightColor0.rgb;
|
||||
|
||||
half3 diff = NdotL * (1 - w) + w;
|
||||
half4 c;
|
||||
c.rgb = ((s.Albedo * _LightColor0.rgb * diff) + (specColor * spec)) * (atten * _LightBoost);
|
||||
c.a = s.Alpha + (_LightColor0.a * _SpecColor.a * spec * atten);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
float4 _LocalCameraPos;
|
||||
float4 _LocalCameraDir;
|
||||
float4 _UnderwaterFogColor;
|
||||
float _UnderwaterMinAlphaFogDistance;
|
||||
float _UnderwaterMaxAlbedoFog;
|
||||
float _UnderwaterMaxAlphaFog;
|
||||
float _UnderwaterAlbedoDistanceScalar;
|
||||
float _UnderwaterAlphaDistanceScalar;
|
||||
float _UnderwaterFogFactor;
|
||||
|
||||
float4 UnderwaterFog(float3 worldPos, float3 color)
|
||||
{
|
||||
float3 toPixel = worldPos - _LocalCameraPos.xyz;
|
||||
float toPixelLength = length(toPixel); ///< Comment out the math--looks better without it.
|
||||
//float angleDot = dot(_LocalCameraDir.xyz, toPixel / toPixelLength);
|
||||
//angleDot = lerp(0.00000001, angleDot, saturate(sign(angleDot)));
|
||||
//float waterDist = -_LocalCameraPos.w / angleDot;
|
||||
//float dist = min(toPixelLength, waterDist);
|
||||
|
||||
|
||||
float underwaterDetection = _UnderwaterFogFactor * _LocalCameraDir.w; ///< sign(1 - sign(_LocalCameraPos.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
|
@ -1,111 +0,0 @@
|
||||
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 "SDF.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 "SDF.cginc"
|
||||
#include "StandardDecal.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// shadow casting support
|
||||
UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"
|
||||
}
|
||||
}
|
@ -1,112 +0,0 @@
|
||||
Shader "ConformalDecals/Decal/Text"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[Header(Decal)]
|
||||
[Toggle(DECAL_FILL)] _Fill ("Fill", int) = 0
|
||||
_Decal("Decal Texture", 2D) = "gray" {}
|
||||
_DecalColor("Decal Color", Color) = (1,1,1,1)
|
||||
|
||||
_Weight("Text Weight", Range(0,1)) = 0
|
||||
|
||||
[Header(Outline)]
|
||||
[Toggle(DECAL_OUTLINE)] _Outline ("Outline", int) = 0
|
||||
_OutlineColor("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineWidth("Outline Width", Range(0,1)) = 0.1
|
||||
|
||||
[Header(Normal)]
|
||||
[Toggle(DECAL_BASE_NORMAL)] _BaseNormal ("Use Base Normal", 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
|
||||
|
||||
_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
|
||||
_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
|
||||
#pragma multi_compile_local __ DECAL_SPECMAP
|
||||
#pragma multi_compile_local __ DECAL_OUTLINE
|
||||
#pragma multi_compile_local __ DECAL_FILL
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "DecalsCommon.cginc"
|
||||
#include "DecalsSurface.cginc"
|
||||
#include "SDF.cginc"
|
||||
#include "TextDecal.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
|
||||
#pragma multi_compile_local __ DECAL_SPECMAP
|
||||
#pragma multi_compile_local __ DECAL_OUTLINE
|
||||
#pragma multi_compile_local __ DECAL_FILL
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "DecalsCommon.cginc"
|
||||
#include "DecalsSurface.cginc"
|
||||
#include "SDF.cginc"
|
||||
#include "TextDecal.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// shadow casting support
|
||||
UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"
|
||||
}
|
||||
}
|
@ -8,6 +8,13 @@ All notable changes to this project will be documented in this file
|
||||
| website | https://forum.kerbalspaceprogram.com/index.php?/topic/194802-18-111-conformal-decals |
|
||||
| author | Andrew Cassidy |
|
||||
|
||||
## 0.2.14 - 2024-06-25
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed parts showing as all black with the Deferred Rendering mod
|
||||
|
||||
|
||||
## 0.2.13 - 2024-05-17
|
||||
|
||||
### Fixed
|
||||
|
BIN
GameData/ConformalDecals/Assets/paper.dds
Normal file
@ -8,6 +8,11 @@
|
||||
<AssemblyVersion>9.9.9</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DefineConstants>DEBUG;TRACE;ENABLE_PROFILER</DefineConstants>
|
||||
<DebugType>portable</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls\Assembly-CSharp.dll</HintPath>
|
||||
@ -49,6 +54,7 @@
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="/bin/cp -v '$(OutDir)ConformalDecals.dll' '$(SolutionDir)../GameData/ConformalDecals/Plugins/ConformalDecals.dll'" IgnoreExitCode="true"/>
|
||||
<Exec Command="/bin/cp -v '$(OutDir)ConformalDecals.pdb' '$(SolutionDir)../GameData/ConformalDecals/Plugins/ConformalDecals.pdb'" IgnoreExitCode="true"/>
|
||||
<!--Fuck you MSBuild stop trying to run CMD.exe on macOS-->
|
||||
</Target>
|
||||
|
||||
|
@ -45,6 +45,7 @@ namespace ConformalDecals.MaterialProperties {
|
||||
_decalMaterial.SetInt(DecalPropertyIDs._Cull, (int) CullMode.Off);
|
||||
_decalMaterial.SetInt(DecalPropertyIDs._ZWrite, 0);
|
||||
_decalMaterial.renderQueue = RenderQueue;
|
||||
_decalMaterial.SetShaderPassEnabled("SHADOWCASTER", false);
|
||||
}
|
||||
|
||||
return _decalMaterial;
|
||||
@ -59,6 +60,7 @@ namespace ConformalDecals.MaterialProperties {
|
||||
_previewMaterial.EnableKeyword("DECAL_PREVIEW");
|
||||
_previewMaterial.SetInt(DecalPropertyIDs._Cull, (int) CullMode.Back);
|
||||
_previewMaterial.SetInt(DecalPropertyIDs._ZWrite, 1);
|
||||
_previewMaterial.SetShaderPassEnabled("DEFERRED_PREPASS", false);
|
||||
}
|
||||
|
||||
return _previewMaterial;
|
||||
|