mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Add shader blacklist
Add a configurable blacklist of shaders that can be projected onto
This commit is contained in:
parent
7e520f97ca
commit
53538a7b09
20
Distribution/GameData/ConformalDecals/ConformalDecals.cfg
Normal file
20
Distribution/GameData/ConformalDecals/ConformalDecals.cfg
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
CONFORMALDECALS {
|
||||||
|
SHADERBLACKLIST {
|
||||||
|
shader = DepthMask
|
||||||
|
shader = KSP/Alpha/Cutoff
|
||||||
|
shader = KSP/Alpha/Cutoff Bumped
|
||||||
|
shader = KSP/Alpha/Translucent
|
||||||
|
shader = KSP/Alpha/Translucent Additive
|
||||||
|
shader = KSP/Alpha/Translucent Specular
|
||||||
|
shader = KSP/Alpha/Unlit Transparent
|
||||||
|
shader = KSP/Bumped Specular (Transparent)
|
||||||
|
shader = KSP/FX/ScrollingUnlit
|
||||||
|
shader = KSP/Particles/Additive
|
||||||
|
shader = KSP/Particles/Additive (Soft)
|
||||||
|
shader = KSP/Particles/Alpha Blended
|
||||||
|
shader = KSP/Particles/Alpha Blended Emissive Cutout
|
||||||
|
shader = KSP/Specular (Cutoff)
|
||||||
|
shader = KSP/Specular (Transparent)
|
||||||
|
shader = Solid Color (Alpha)
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
38
Source/ConformalDecals/ConformalDecalConfig.cs
Normal file
38
Source/ConformalDecals/ConformalDecalConfig.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace ConformalDecals {
|
||||||
|
[KSPAddon(KSPAddon.Startup.Instantly, true)]
|
||||||
|
public class ConformalDecalConfig : MonoBehaviour {
|
||||||
|
private static List<string> _shaderBlacklist;
|
||||||
|
|
||||||
|
public static bool IsBlacklisted(Shader shader) {
|
||||||
|
return IsBlacklisted(shader.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsBlacklisted(string shaderName) {
|
||||||
|
return _shaderBlacklist.Contains(shaderName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ParseConfig(ConfigNode node) {
|
||||||
|
foreach (var blacklist in node.GetNodes("SHADERBLACKLIST")) {
|
||||||
|
foreach (var shaderName in blacklist.GetValuesList("shader")) {
|
||||||
|
_shaderBlacklist.Add(shaderName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Start() {
|
||||||
|
_shaderBlacklist = new List<string>();
|
||||||
|
|
||||||
|
var configs = GameDatabase.Instance.GetConfigs("CONFORMALDECALS");
|
||||||
|
|
||||||
|
if (configs.Length > 0) {
|
||||||
|
Debug.Log("DecalConfig loading config");
|
||||||
|
foreach (var config in configs) {
|
||||||
|
ParseConfig(config.config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -49,6 +49,7 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="ConformalDecalConfig.cs" />
|
||||||
<Compile Include="MaterialModifiers\MaterialColorProperty.cs" />
|
<Compile Include="MaterialModifiers\MaterialColorProperty.cs" />
|
||||||
<Compile Include="MaterialModifiers\MaterialFloatProperty.cs" />
|
<Compile Include="MaterialModifiers\MaterialFloatProperty.cs" />
|
||||||
<Compile Include="MaterialModifiers\MaterialProperty.cs" />
|
<Compile Include="MaterialModifiers\MaterialProperty.cs" />
|
||||||
|
@ -330,6 +330,12 @@ namespace ConformalDecals {
|
|||||||
foreach (var renderer in renderers) {
|
foreach (var renderer in renderers) {
|
||||||
// skip disabled renderers
|
// skip disabled renderers
|
||||||
if (renderer.gameObject.activeInHierarchy == false) continue;
|
if (renderer.gameObject.activeInHierarchy == false) continue;
|
||||||
|
|
||||||
|
// skip blacklisted shaders
|
||||||
|
if (ConformalDecalConfig.IsBlacklisted(renderer.material.shader)) {
|
||||||
|
this.Log($"Skipping blacklisted shader '{renderer.material.shader.name}' in '{renderer.gameObject.name}'");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var meshFilter = renderer.GetComponent<MeshFilter>();
|
var meshFilter = renderer.GetComponent<MeshFilter>();
|
||||||
if (meshFilter == null) continue; // object has a meshRenderer with no filter, invalid
|
if (meshFilter == null) continue; // object has a meshRenderer with no filter, invalid
|
||||||
|
Loading…
Reference in New Issue
Block a user