2 Commits

Author SHA1 Message Date
0281759d5f SDF experiments 2020-06-22 01:43:47 -07:00
545f0d538b Merge branch 'master' into develop 2020-06-20 11:46:51 -07:00
14 changed files with 100 additions and 33 deletions

View File

@ -22,7 +22,7 @@ Shader "ConformalDecals/Feature/Bumped"
}
SubShader
{
Tags { "Queue" = "Geometry+100" "IgnoreProjector" = "true"}
Tags { "Queue" = "Geometry+100" }
Cull [_Cull]
Ztest LEqual

View File

@ -25,7 +25,7 @@ Shader "ConformalDecals/Paint/Diffuse"
}
SubShader
{
Tags { "Queue" = "Geometry+100" "IgnoreProjector" = "true"}
Tags { "Queue" = "Geometry+100" }
Cull [_Cull]
Ztest LEqual

View File

@ -27,7 +27,7 @@ Shader "ConformalDecals/Paint/DiffuseSDF"
}
SubShader
{
Tags { "Queue" = "Geometry+100" "IgnoreProjector" = "true"}
Tags { "Queue" = "Geometry+100" }
Cull [_Cull]
Ztest LEqual

View File

@ -30,7 +30,7 @@ Shader "ConformalDecals/Paint/Specular"
}
SubShader
{
Tags { "Queue" = "Geometry+100" "IgnoreProjector" = "true"}
Tags { "Queue" = "Geometry+100" }
Cull [_Cull]
Ztest LEqual

View File

@ -32,7 +32,7 @@ Shader "ConformalDecals/Paint/SpecularSDF"
}
SubShader
{
Tags { "Queue" = "Geometry+100" "IgnoreProjector" = "true"}
Tags { "Queue" = "Geometry+100" }
Cull [_Cull]
Ztest LEqual

View File

@ -0,0 +1,76 @@
Shader "ConformalDecals/SDF4test"
{
Properties
{
_MainTex("_MainTex (RGB spec(A))", 2D) = "white" {}
_Color1("Color 1", Color) = (0,0,0,0)
_Color2("Color 2", Color) = (0,0,0,0)
_Color3("Color 3", Color) = (0,0,0,0)
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
_Smoothness ("SDF smoothness", Range(0,1)) = 0.15
}
SubShader
{
Tags { "Queue" = "Transparent" }
Cull Back
ZWrite On
Pass
{
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
sampler2D _MainTex;
float4 _Color1;
float4 _Color2;
float4 _Color3;
float _Smoothness;
float _Cutoff;
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "AutoLight.cginc"
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
float3 worldPosition : TEXCOORD1;
half3 worldNormal : TEXCOORD2;
};
v2f vert(float4 vertex : POSITION, float2 uv : TEXCOORD0) {
v2f o;
o.pos = UnityObjectToClipPos(vertex);
o.uv = uv;
o.worldPosition = mul(unity_ObjectToWorld, vertex).xyz;
return o;
}
fixed4 frag (v2f i) : SV_Target {
fixed4 c = 0;
float4 s = tex2D(_MainTex,(i.uv));
s.rgb = s.rbg;
c = lerp(c, _Color1, smoothstep(_Cutoff, saturate(_Smoothness+ _Cutoff), s.r + s.g + s.b));
c = lerp(c, _Color2, smoothstep(_Cutoff, saturate(_Smoothness+ _Cutoff), s.g + s.b ));
c = lerp(c, _Color3, smoothstep(_Cutoff, saturate(_Smoothness+ _Cutoff), s.b ));
// if (s.r + s.g + s.b > 0.5) {
// if (s.r > s.g && s.r > s.b) c = _Color1;
// if (s.g > s.r && s.g > s.b) c = _Color2;
// if (s.b > s.g && s.b > s.r) c = _Color3;
// }
return c;
}
ENDCG
}
}
}

View File

@ -12,7 +12,7 @@ Shader "ConformalDecals/SelectionGlow"
}
SubShader
{
Tags { "Queue" = "Transparent" "IgnoreProjector" = "true" }
Tags { "Queue" = "Transparent" }
Cull Back
ZWrite Off

View File

@ -6,7 +6,7 @@
{
"MAJOR":0,
"MINOR":1,
"PATCH":4,
"PATCH":3,
"BUILD":0
},
"KSP_VERSION":
@ -22,7 +22,7 @@
},
"KSP_VERSION_MAX":{
"MAJOR":1,
"MINOR":10,
"MINOR":9,
"PATCH":99
}
}

View File

@ -1,4 +1,4 @@
# Conformal Decals v0.1.4
# Conformal Decals v0.1.3
[![Build Status](https://travis-ci.org/drewcassidy/KSP-Conformal-Decals.svg?branch=release)](https://travis-ci.org/drewcassidy/KSP-Conformal-Decals) [![Art: CC BY-SA 4.0](https://img.shields.io/badge/Art%20License-CC%20BY--SA%204.0-orange.svg)](https://creativecommons.org/licenses/by-sa/4.0/) [![Code: GPL v3](https://img.shields.io/badge/Code%20License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
![Screenshot](http://pileof.rocks/KSP/images/ConformalDecalsHeader.png)
@ -8,7 +8,7 @@ Conformal Decals adds a set of decal stickers to KSP, as well as providing a fra
## Dependencies
Required:
- KSP (1.8.x to 1.10.x)
- KSP (1.8.x to 1.9.x)
- B9 Part Switch (2.16.0). Bundled with release.
- ModuleManager (4.1.3). Bundled with release.
- Shabby (0.1.2). Bundled with release.

View File

@ -237,23 +237,14 @@ namespace ConformalDecals {
public override void OnStart(StartState state) {
this.Log("Starting module");
materialProperties.RenderQueue = DecalQueue;
_boundsRenderer = decalProjectorTransform.GetComponent<MeshRenderer>();
UpdateMaterials();
// handle tweakables
if (HighLogic.LoadedSceneIsEditor) {
GameEvents.onEditorPartEvent.Add(OnEditorEvent);
GameEvents.onVariantApplied.Add(OnVariantApplied);
UpdateTweakables();
}
}
public override void OnStartFinished(StartState state) {
// handle game events
if (HighLogic.LoadedSceneIsGame) {
// set initial attachment state
if (part.parent == null) {
@ -263,20 +254,27 @@ namespace ConformalDecals {
OnAttach();
}
}
// handle tweakables
if (HighLogic.LoadedSceneIsEditor) {
GameEvents.onEditorPartEvent.Add(OnEditorEvent);
GameEvents.onVariantApplied.Add(OnVariantApplied);
UpdateTweakables();
}
// handle flight events
if (HighLogic.LoadedSceneIsFlight) {
GameEvents.onPartWillDie.Add(OnPartWillDie);
if (part.parent == null) part.explode();
Part.layerMask |= 1 << DecalConfig.DecalLayer;
decalColliderTransform.gameObject.layer = DecalConfig.DecalLayer;
if (!selectableInFlight || !DecalConfig.SelectableInFlight) {
decalColliderTransform.GetComponent<Collider>().enabled = false;
_boundsRenderer.enabled = false;
}
if (part.parent == null) part.explode();
}
}

View File

@ -1,12 +1,3 @@
v0.1.4
------
- Supported KSP versions: 1.8.x to 1.10.x
- Fixes:
- Fixed decals rendering onto disabled B9PS part variants
- Decals will still not update whan their parent part's B9PS variant is changed, both in flight and in the editor. This is known and awaiting a change to B9PS to be fixed.
- Fixed decal bounds rendering as dark cubes when shadowed by EVE clouds.
- Fixed decals being shadowed by EVE clouds, causing the part underneath to appear overly dark.
v0.1.3
------
Fixes:
@ -19,6 +10,8 @@ Changes:
- Small refactor of node parsing code
- Colors can now be specified in hex (#RGB, #RGBA, #RRGGBB, or #RRGGBBAA) or using the colors specified in the XKCDColors class
v0.1.2
------
Fixes: