diff --git a/Distribution/GameData/ConformalDecals/Localization/en-us.cfg b/Distribution/GameData/ConformalDecals/Localization/en-us.cfg
index ed70d52..599411c 100644
--- a/Distribution/GameData/ConformalDecals/Localization/en-us.cfg
+++ b/Distribution/GameData/ConformalDecals/Localization/en-us.cfg
@@ -14,6 +14,7 @@ Localization
#LOC_ConformalDecals_gui-depth = Depth
#LOC_ConformalDecals_gui-opacity = Opacity
#LOC_ConformalDecals_gui-cutoff = Cutoff
+ #LOC_ConformalDecals_gui-wear = Edge Wear
#LOC_ConformalDecals_gui-aspectratio = Aspect Ratio
#LOC_ConformalDecals_gui-select-flag = Select Flag
#LOC_ConformalDecals_gui-reset-flag = Reset Flag
diff --git a/Distribution/GameData/ConformalDecals/Parts/Generic/decal-generic.cfg b/Distribution/GameData/ConformalDecals/Parts/Generic/decal-generic.cfg
index 04a3d1a..56c62b5 100644
--- a/Distribution/GameData/ConformalDecals/Parts/Generic/decal-generic.cfg
+++ b/Distribution/GameData/ConformalDecals/Parts/Generic/decal-generic.cfg
@@ -68,7 +68,7 @@ PART
cutoff = 0.5
cutoffAdjustable = false
- scaleRange = 0.05, 1
+ scaleRange = 0.1, 4
shader = ConformalDecals/Paint/Specular
@@ -511,7 +511,7 @@ PART
SUBTYPE {
name = numeral-0
- title = #LOC_ConformalDecals_generic-variant-numeral-10
+ title = #LOC_ConformalDecals_generic-variant-numeral-0
primaryColor = Black
secondaryColor = White
diff --git a/Distribution/GameData/ConformalDecals/Parts/decal-flag.cfg b/Distribution/GameData/ConformalDecals/Parts/decal-flag.cfg
index 5b8d1c5..be12f72 100644
--- a/Distribution/GameData/ConformalDecals/Parts/decal-flag.cfg
+++ b/Distribution/GameData/ConformalDecals/Parts/decal-flag.cfg
@@ -59,5 +59,6 @@ PART
useBaseNormal = true
defaultDepth = 0.2
+ defaultCutoff = 0
}
}
diff --git a/Distribution/GameData/ConformalDecals/Plugins/ConformalDecals.dll b/Distribution/GameData/ConformalDecals/Plugins/ConformalDecals.dll
index a9601b2..6deba2e 100644
Binary files a/Distribution/GameData/ConformalDecals/Plugins/ConformalDecals.dll and b/Distribution/GameData/ConformalDecals/Plugins/ConformalDecals.dll differ
diff --git a/Source/ConformalDecals/DecalPropertyIDs.cs b/Source/ConformalDecals/DecalPropertyIDs.cs
index 0be88d1..6c9e13c 100644
--- a/Source/ConformalDecals/DecalPropertyIDs.cs
+++ b/Source/ConformalDecals/DecalPropertyIDs.cs
@@ -10,6 +10,7 @@ namespace ConformalDecals {
public static readonly int _DecalNormal = Shader.PropertyToID("_DecalNormal");
public static readonly int _DecalOpacity = Shader.PropertyToID("_DecalOpacity");
public static readonly int _DecalTangent = Shader.PropertyToID("_DecalTangent");
+ public static readonly int _EdgeWearStrength = Shader.PropertyToID("_EdgeWearStrength");
public static readonly int _ProjectionMatrix = Shader.PropertyToID("_ProjectionMatrix");
}
}
\ No newline at end of file
diff --git a/Source/ConformalDecals/MaterialModifiers/MaterialPropertyCollection.cs b/Source/ConformalDecals/MaterialModifiers/MaterialPropertyCollection.cs
index c4de994..8698f88 100644
--- a/Source/ConformalDecals/MaterialModifiers/MaterialPropertyCollection.cs
+++ b/Source/ConformalDecals/MaterialModifiers/MaterialPropertyCollection.cs
@@ -238,6 +238,10 @@ namespace ConformalDecals.MaterialModifiers {
PreviewMaterial.SetFloat(DecalPropertyIDs._Cutoff, cutoff);
}
+ public void SetWear(float wear) {
+ DecalMaterial.SetFloat(DecalPropertyIDs._EdgeWearStrength, wear);
+ }
+
public void UpdateMaterials() {
UpdateMaterial(DecalMaterial);
UpdateMaterial(PreviewMaterial);
diff --git a/Source/ConformalDecals/ModuleConformalDecal.cs b/Source/ConformalDecals/ModuleConformalDecal.cs
index a213b01..810eeae 100644
--- a/Source/ConformalDecals/ModuleConformalDecal.cs
+++ b/Source/ConformalDecals/ModuleConformalDecal.cs
@@ -54,9 +54,13 @@ namespace ConformalDecals {
[KSPField] public Vector2 opacityRange = new Vector2(0, 1);
[KSPField] public bool cutoffAdjustable = true;
- [KSPField] public float defaultCutoff;
+ [KSPField] public float defaultCutoff = 0.5f;
[KSPField] public Vector2 cutoffRange = new Vector2(0, 1);
+ [KSPField] public bool useBaseNormal = true;
+ [KSPField] public float defaultWear = 100;
+ [KSPField] public Vector2 wearRange = new Vector2(0, 100);
+
[KSPField] public Rect tileRect = new Rect(-1, -1, 0, 0);
[KSPField] public Vector2 tileSize;
[KSPField] public int tileIndex = -1;
@@ -66,10 +70,6 @@ namespace ConformalDecals {
///
[KSPField] public bool updateBackScale = true;
- ///
- /// Should the shader use the normal map of the part its projecting onto? Use only with "paint" shaders.
- ///
- [KSPField] public bool useBaseNormal = true;
// INTERNAL VALUES
@@ -101,6 +101,13 @@ namespace ConformalDecals {
UI_FloatRange(stepIncrement = 0.05f)]
public float cutoff = 0.5f;
+ ///
+ /// Edge wear value for the decal shader. Only relevent when useBaseNormal is true and the shader is a paint shader
+ ///
+ [KSPField(guiName = "#LOC_ConformalDecals_gui-wear", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F0"),
+ UI_FloatRange()]
+ public float wear = 100;
+
[KSPField] public MaterialPropertyCollection materialProperties;
[KSPField] public Transform decalFrontTransform;
@@ -313,7 +320,7 @@ namespace ConformalDecals {
// scale or depth values have been changed, so update scale
// and update projection matrices if attached
UpdateScale();
-
+
foreach (var counterpart in part.symmetryCounterparts) {
var decal = counterpart.GetComponent();
decal.UpdateScale();
@@ -323,11 +330,17 @@ namespace ConformalDecals {
protected void OnMaterialTweakEvent(BaseField field, object obj) {
materialProperties.SetOpacity(opacity);
materialProperties.SetCutoff(cutoff);
-
+ if (useBaseNormal) {
+ materialProperties.SetWear(wear);
+ }
+
foreach (var counterpart in part.symmetryCounterparts) {
var decal = counterpart.GetComponent();
decal.materialProperties.SetOpacity(opacity);
decal.materialProperties.SetCutoff(cutoff);
+ if (useBaseNormal) {
+ decal.materialProperties.SetWear(wear);
+ }
}
}
@@ -427,6 +440,9 @@ namespace ConformalDecals {
materialProperties.UpdateMaterials();
materialProperties.SetOpacity(opacity);
materialProperties.SetCutoff(cutoff);
+ if (useBaseNormal) {
+ materialProperties.SetWear(wear);
+ }
_decalMaterial = materialProperties.DecalMaterial;
_previewMaterial = materialProperties.PreviewMaterial;
@@ -470,11 +486,13 @@ namespace ConformalDecals {
var depthField = Fields[nameof(depth)];
var opacityField = Fields[nameof(opacity)];
var cutoffField = Fields[nameof(cutoff)];
+ var wearField = Fields[nameof(wear)];
scaleField.guiActiveEditor = scaleAdjustable;
depthField.guiActiveEditor = depthAdjustable;
opacityField.guiActiveEditor = opacityAdjustable;
cutoffField.guiActiveEditor = cutoffAdjustable;
+ wearField.guiActiveEditor = useBaseNormal;
var steps = 20;
@@ -523,6 +541,17 @@ namespace ConformalDecals {
cutoffEditor.stepIncrement = (maxValue - minValue) / steps;
cutoffEditor.onFieldChanged = OnMaterialTweakEvent;
}
+
+ if (useBaseNormal) {
+ var minValue = Mathf.Max(0, wearRange.x);
+ var maxValue = Mathf.Max(minValue, wearRange.y);
+
+ var wearEditor = (UI_FloatRange) wearField.uiControlEditor;
+ wearEditor.minValue = minValue;
+ wearEditor.maxValue = maxValue;
+ wearEditor.stepIncrement = (maxValue - minValue) / steps;
+ wearEditor.onFieldChanged = OnMaterialTweakEvent;
+ }
}
protected void Render(Camera camera) {