Compare commits
234 Commits
Author | SHA1 | Date | |
---|---|---|---|
f545e4c5ab | |||
cb98e78a3f | |||
946975249d | |||
ce55f07150 | |||
7286202be9 | |||
14640c1dca | |||
321b2a49a4 | |||
f1115ef188 | |||
92818edfaa | |||
dd40e54ef3 | |||
c19a0c2889 | |||
ded36f457d | |||
1be7a98835 | |||
a3a9ad9674 | |||
89a1f0d872 | |||
6db2d6b82a | |||
37715a46ab | |||
60cc0d76bb | |||
e7307f95e9 | |||
88da55123b | |||
eda04235c3 | |||
65031be081 | |||
0c7f6dd628 | |||
883c027a1a | |||
d51b240c6c | |||
91b5e584a6 | |||
44a5aec21e | |||
8e0a26f17c | |||
b48db63a27 | |||
c0d20f847d | |||
36732ed4d4 | |||
d3388a4dad | |||
ece9d959fd | |||
dfdf280564 | |||
2cca6c37bb | |||
c653c9efc8 | |||
374fc8b753 | |||
88b2b4841a | |||
b2da56b1ca | |||
14bc694588 | |||
7e1b993d20 | |||
f8d692352d | |||
fa4b799788 | |||
970a69be11 | |||
dddb7f09f3 | |||
3cd229bc23 | |||
4948818065 | |||
036b084d34 | |||
1e3addeb4d | |||
47c70d3071 | |||
9955b9ce30 | |||
32ddc54019 | |||
ff262d55c8 | |||
d1f3d1fa55 | |||
2965633235 | |||
a82369e595 | |||
16c4fa2b96 | |||
591ec0aa74 | |||
210d326469 | |||
dd405a21db | |||
c40f700235 | |||
36cc896b2a | |||
4c02e91dfd | |||
41b15477fb | |||
b61f71bc00 | |||
74fe42a7ff | |||
7fa8969d5b | |||
21f8332d66 | |||
cb219a52c0 | |||
f2f2100334 | |||
9bdb95527a | |||
ad504ce4cc | |||
18ebbd7b4c | |||
ba189f18c4 | |||
322aaa613e | |||
5443377bfe | |||
1ed6dc0f68 | |||
90dec1b42a | |||
80da98d95a | |||
76016fbbf1 | |||
53657b8fad | |||
9d7502091c | |||
f788c25837 | |||
017110738b | |||
fd7134ece9 | |||
68ceacfef4 | |||
a452844cd1 | |||
4b8d11e1de | |||
8f888ee552 | |||
95b99d1d42 | |||
ba6676b625 | |||
495441be06 | |||
8025a0a418 | |||
760609fae2 | |||
ecc60751f7 | |||
e10b7e4b51 | |||
a91a83a280 | |||
316f92df2c | |||
938babb41b | |||
3173dd914a | |||
5f6712f476 | |||
6b7996fdd7 | |||
5feb16dcfb | |||
bf8e98caf0 | |||
b634eb1e8e | |||
dadf38acd5 | |||
f42e0d78d6 | |||
1e7c6d81c9 | |||
dda988db17 | |||
900061f7f6 | |||
e56278c6cb | |||
2793f5fcb1 | |||
833ec43a52 | |||
e6856124e7 | |||
8ed7a130ab | |||
d8d3d4ed92 | |||
334af786f6 | |||
17ef93bb6e | |||
a6d58690f9 | |||
a6de537e4a | |||
33b0307aa2 | |||
121428414c | |||
98f774b2ae | |||
d31576fb0b | |||
c9853049c5 | |||
f108341068 | |||
40d4e2cc8a | |||
fb0070f92f | |||
6f0c1f8ff5 | |||
4cf6de9693 | |||
06137357c1 | |||
dbbc621181 | |||
c6b9812fe3 | |||
8accabe9e5 | |||
981a167864 | |||
d4978b1b3c | |||
c42e443b4b | |||
a6e2edc475 | |||
e82b02b0e5 | |||
ea8c069d68 | |||
ac1289a46e | |||
16ef53ea65 | |||
7b01848acc | |||
f37c3d57b7 | |||
a937888c0d | |||
5065a8abf3 | |||
1ebed608a8 | |||
98a790630e | |||
ef90f73288 | |||
880f463ee0 | |||
0066cc332e | |||
8f22856064 | |||
5ef33b1d85 | |||
27ecd82193 | |||
ea08bd84f0 | |||
e155526808 | |||
da4c780ce6 | |||
bb0829c0a7 | |||
ddce97ee05 | |||
d1029ca0c1 | |||
bf7d5dd933 | |||
885dfb3397 | |||
1859e51a2e | |||
5a18943db9 | |||
9f32a42e51 | |||
13bf70fd8a | |||
5faa26ae95 | |||
2d299f99f3 | |||
0b15a3125c | |||
4a6d019227 | |||
bb48782eff | |||
3df3e08aae | |||
8b05dc57e8 | |||
54cd5dce20 | |||
7495a6f509 | |||
f3aea02da7 | |||
93c3ff8a49 | |||
ae351c021f | |||
53f8e74836 | |||
7ec4c85e8c | |||
86548a1037 | |||
cdc8794c54 | |||
da3bcf7819 | |||
f367a30dec | |||
7e3f4b84ff | |||
42e6b18845 | |||
1c776c0969 | |||
30870b263a | |||
2994da628b | |||
dbb3281e95 | |||
f3698fc108 | |||
7574614776 | |||
1aebdb4e0e | |||
10da3dd402 | |||
e57bed6ed9 | |||
d5702ee0e7 | |||
b1d6e43512 | |||
365dabc90f | |||
dfef071175 | |||
af05ed43c2 | |||
e87fc48edf | |||
1316dbb553 | |||
b630ddce5e | |||
66dd0a6206 | |||
47727ef0ce | |||
4a3569a7be | |||
a9b05a677e | |||
be641272ad | |||
0aaf0088d8 | |||
3e157faae3 | |||
60764405ba | |||
0b83155c42 | |||
f78093bbb6 | |||
1ab8d0f6bc | |||
70ef88e9d8 | |||
1c055a0285 | |||
1ad6a1fa50 | |||
261da9194b | |||
bf2c2cf940 | |||
48819878dc | |||
14ea974a1d | |||
83acfbf866 | |||
0be2f650f9 | |||
ab254595ab | |||
1a455ea92c | |||
adf6f7171a | |||
545f0d538b | |||
96c625f6f2 | |||
0a77ef57b7 | |||
2c8773ce61 | |||
b3c050be26 | |||
2122b6a0a7 | |||
f9d9c228ae | |||
ecb3eccfe5 |
23
.github/workflows/ff-release.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
name: Fast-Forward Release Branch
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
fast-forward:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
ref: release
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Merge into Release
|
||||
run: git merge ${{github.ref_name}} --ff-only
|
||||
|
||||
- name: Push Changes
|
||||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
branch: release
|
142
.github/workflows/ksp-publish.yml
vendored
Normal file
@ -0,0 +1,142 @@
|
||||
name: Build and Release
|
||||
on: [ push ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
- name: Setup .NET Core SDK
|
||||
uses: actions/setup-dotnet@v4.0.0
|
||||
with:
|
||||
dotnet-version: '6.0.x'
|
||||
|
||||
- name: Install Python Tools
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install yaclog yaclog-ksp
|
||||
|
||||
- name: Generate Version Info
|
||||
run: |
|
||||
yaclog show
|
||||
python Scripts/version.py
|
||||
yaclog-ksp -n "Conformal Decals"
|
||||
|
||||
- name: Validate Version Info
|
||||
uses: DasSkelett/AVC-VersionFileValidator@master
|
||||
|
||||
- name: Download DLL Dependencies
|
||||
working-directory: Source
|
||||
run: |
|
||||
wget --user drewcassidy --password ${{ secrets.PILE_OF_ROCKS_PASS }} https://pileof.rocks/Secret/conformal-decals-dependencies-1.zip
|
||||
unzip conformal-decals-dependencies-*.zip -d ConformalDecals/dlls
|
||||
|
||||
- name: Build DLL
|
||||
working-directory: Source
|
||||
run: |
|
||||
mkdir -p ../GameData/ConformalDecals/Plugins
|
||||
dotnet build --configuration Release ConformalDecals.sln
|
||||
|
||||
- name: Download KSP Dependencies
|
||||
run: |
|
||||
wget https://pileof.rocks/KSP/Shabby_v0.3.0.zip
|
||||
wget https://ksp.sarbian.com/jenkins/job/ModuleManager/161/artifact/ModuleManager.4.2.1.dll
|
||||
wget https://github.com/blowfishpro/B9PartSwitch/releases/download/v2.19.0/B9PartSwitch_v2.19.0.zip
|
||||
wget https://github.com/KSPModdingLibs/HarmonyKSP/releases/download/2.0.4.0/HarmonyKSP_2.0.4.0_for_KSP1.8+.zip
|
||||
unzip -d Shabby Shabby*.zip
|
||||
unzip -d B9PartSwitch B9PartSwitch*.zip
|
||||
unzip -d HarmonyKSP HarmonyKSP*.zip
|
||||
mv Shabby/GameData/Shabby GameData/
|
||||
mv ModuleManager*.dll GameData/
|
||||
mv B9PartSwitch/GameData/B9PartSwitch GameData/
|
||||
mv HarmonyKSP/GameData/000_Harmony GameData/
|
||||
|
||||
- name: Upload Unbundled Build
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ConformalDecals-unbundled
|
||||
path: |
|
||||
GameData/ConformalDecals/
|
||||
README.md
|
||||
CHANGELOG.md
|
||||
LICENSE-ART.md
|
||||
LICENSE-SOURCE.md
|
||||
|
||||
- name: Upload Bundled Build
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ConformalDecals
|
||||
path: |
|
||||
GameData/
|
||||
README.md
|
||||
CHANGELOG.md
|
||||
LICENSE-ART.md
|
||||
LICENSE-SOURCE.md
|
||||
|
||||
|
||||
deploy:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
- name: Install Python Tools
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install yaclog
|
||||
|
||||
- name: Get version name and body
|
||||
run: |
|
||||
echo "VERSION_TITLE=$(yaclog show -n)" >> $GITHUB_ENV
|
||||
yaclog show
|
||||
|
||||
- name: Download Build Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
|
||||
- name: Zip Download Packages
|
||||
run: |
|
||||
set -u
|
||||
mkdir bundled
|
||||
mkdir unbundled
|
||||
zip -r bundled/ConformalDecals-$VERSION_TITLE.zip ConformalDecals/*
|
||||
zip -r unbundled/ConformalDecals-$VERSION_TITLE.zip ConformalDecals-unbundled/*
|
||||
ls
|
||||
|
||||
- name: Publish to Spacedock
|
||||
run: |
|
||||
set -u
|
||||
curl -F "username=drewcassidy" -F "password=${{ secrets.SPACEDOCK_PASS }}" \
|
||||
-c ./cookies "https://spacedock.info/api/login"
|
||||
curl -c ./cookies -b ./cookies \
|
||||
-F "version=$VERSION_TITLE" \
|
||||
-F "changelog=$(yaclog show -mb)" \
|
||||
-F "game-version=1.12.5" \
|
||||
-F "notify-followers=yes" \
|
||||
-F "zipball=@bundled/ConformalDecals-$VERSION_TITLE.zip" \
|
||||
"https://spacedock.info/api/mod/2451/update"
|
||||
|
||||
- name: Publish to Github
|
||||
run: |
|
||||
set -u
|
||||
gh release create ${{ github.ref_name }} \
|
||||
--notes "$(yaclog show -mb)" \
|
||||
--title "Conformal Decals $VERSION_TITLE" \
|
||||
bundled/ConformalDecals-*.zip \
|
||||
ConformalDecals/GameData/ConformalDecals/Versioning/ConformalDecals.version
|
||||
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
19
.gitignore
vendored
@ -1,16 +1,24 @@
|
||||
# Unity Project Directories
|
||||
Assets/*
|
||||
!Assets/Shaders/
|
||||
!Assets/Textures/
|
||||
!Assets/ConformalDecals
|
||||
Assets/ConformalDecals/Fonts
|
||||
Assets/ConformalDecals/Parts
|
||||
KSP/
|
||||
Library/
|
||||
Logs/
|
||||
Packages/
|
||||
ProjectSettings/
|
||||
Temp/
|
||||
|
||||
# Autogenerated shaders
|
||||
Assets/ConformalDecals/Shaders/Decal/*.shader
|
||||
|
||||
# Unity Assetbundle Manifest Files
|
||||
GameData/ConformalDecals/Resources/Resources
|
||||
GameData/ConformalDecals/Resources/Resources.manifest
|
||||
GameData/ConformalDecals/Resources/conformaldecals.shab.manifest
|
||||
GameData/ConformalDecals/Resources/*.manifest
|
||||
|
||||
# DLLs
|
||||
GameData/ConformalDecals/Plugins
|
||||
|
||||
# Unity Project Files
|
||||
PartTools.cfg
|
||||
@ -46,3 +54,6 @@ Source/ConformalDecals/bin
|
||||
*.sublime*
|
||||
.idea
|
||||
obj
|
||||
*.swp
|
||||
@thumbs
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
USE_SSM_CREDENTIALS: false
|
@ -1,30 +0,0 @@
|
||||
# Example annotated build data file
|
||||
mod-name: ConformalDecals
|
||||
package:
|
||||
include-dependencies: true # Include dependencies in the package
|
||||
included-gamedata: # Include these gamedata-level folders in packages:
|
||||
- ConformalDecals
|
||||
included-support: # Include these root-level files in packages
|
||||
- README.md
|
||||
- LICENSE-ART.md
|
||||
- LICENSE-SOURCE.md
|
||||
- changelog.txt
|
||||
dependencies: # Configure dependencies
|
||||
ModuleManager:
|
||||
location: url
|
||||
url: https://ksp.sarbian.com/jenkins/job/ModuleManager/157/artifact/ModuleManager.4.1.3.dll
|
||||
zip: false
|
||||
B9PartSwitch:
|
||||
location: url
|
||||
url: http://pileof.rocks/KSP/B9PartSwitch-v2.16.0.zip
|
||||
zip: true
|
||||
Shabby:
|
||||
location: url
|
||||
url: http://taniwha.org/~bill/Shabby_v0.1.2.zip
|
||||
zip: true
|
||||
deploy:
|
||||
SpaceDock:
|
||||
enabled: true # activate/deactivate this deployment script
|
||||
mod-id: 2451 # The Spacedock mod ID for deployment
|
||||
GitHub:
|
||||
enabled: true # activate/deactivate this deployment script
|
27
.travis.yml
@ -1,27 +0,0 @@
|
||||
language: python
|
||||
python:
|
||||
- 3.6
|
||||
before_install:
|
||||
- echo -e "machine github.com\n login $GITHUB_OAUTH_TOKEN" > ~/.netrc
|
||||
- git lfs pull
|
||||
- git lfs fetch --all
|
||||
install:
|
||||
- pip install awscli boto3 requests
|
||||
branches:
|
||||
only:
|
||||
- release
|
||||
script:
|
||||
- git clone https://github.com/post-kerbin-mining-corporation/build-deploy.git
|
||||
- cd build-deploy
|
||||
- git checkout master
|
||||
- cd ..
|
||||
- pytest -s --testpath "GameData/" build-deploy/src/tests/ # run the deploy tests
|
||||
- python build-deploy/src/package.py --f ".mod_data.yml" # Build package
|
||||
before_deploy:
|
||||
- python build-deploy/src/stage.py --f ".mod_data.yml" # Run the staging script
|
||||
deploy:
|
||||
- provider: script
|
||||
script: python build-deploy/src/deploy.py --f ".mod_data.yml" # Deploy package to spacedock, curse, github
|
||||
skip_cleanup: true
|
||||
on:
|
||||
branch: release
|
36
Assets/ConformalDecals/BoxSlider.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ConformalDecals.UI {
|
||||
[AddComponentMenu("UI/BoxSlider", 35)]
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
public class BoxSlider : Selectable, IDragHandler, IInitializePotentialDragHandler, ICanvasElement {
|
||||
[Serializable]
|
||||
public class BoxSliderEvent : UnityEvent<Vector2> { }
|
||||
|
||||
[SerializeField] private RectTransform _handleRect;
|
||||
[SerializeField] private Vector2 _value = Vector2.zero;
|
||||
|
||||
// Allow for delegate-based subscriptions for faster events than 'eventReceiver', and allowing for multiple receivers.
|
||||
[SerializeField] private BoxSliderEvent _onValueChanged = new BoxSliderEvent();
|
||||
|
||||
public BoxSliderEvent OnValueChanged {
|
||||
get => _onValueChanged;
|
||||
set => _onValueChanged = value;
|
||||
}
|
||||
|
||||
// Private fields
|
||||
public void OnDrag(PointerEventData eventData) { }
|
||||
|
||||
public void OnInitializePotentialDrag(PointerEventData eventData) { }
|
||||
|
||||
public void Rebuild(CanvasUpdate executing) { }
|
||||
|
||||
public void LayoutComplete() { }
|
||||
|
||||
public void GraphicUpdateComplete() { }
|
||||
}
|
||||
}
|
13
Assets/ConformalDecals/ColorBoxSlider.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ConformalDecals.UI {
|
||||
public class ColorBoxSlider : MonoBehaviour{
|
||||
[SerializeField] private Vector2 _value;
|
||||
|
||||
[SerializeField] private BoxSlider _slider;
|
||||
[SerializeField] private Image _image;
|
||||
|
||||
public void OnSliderUpdate(Vector2 value) { }
|
||||
}
|
||||
}
|
18
Assets/ConformalDecals/ColorChannelSlider.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ConformalDecals.UI {
|
||||
public class ColorChannelSlider : MonoBehaviour {
|
||||
[SerializeField] private float _value;
|
||||
[SerializeField] private int _channel;
|
||||
[SerializeField] private bool _hsv;
|
||||
|
||||
[SerializeField] private Selectable _textBox;
|
||||
[SerializeField] private Slider _slider;
|
||||
[SerializeField] private Image _image;
|
||||
|
||||
public void OnTextBoxUpdate(string text) { }
|
||||
|
||||
public void OnSliderUpdate(float value) { }
|
||||
}
|
||||
}
|
17
Assets/ConformalDecals/ColorPickerController.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ConformalDecals.UI {
|
||||
public class ColorPickerController : MonoBehaviour {
|
||||
[SerializeField] private Color _value;
|
||||
[SerializeField] private Image _previewImage;
|
||||
[SerializeField] private Selectable _hexTextBox;
|
||||
|
||||
public void Close() { }
|
||||
|
||||
public void OnHexColorUpdate(string text) { }
|
||||
}
|
||||
}
|
3
Assets/ConformalDecals/ConformalDecals.asmdef
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "ConformalDecals"
|
||||
}
|
10
Assets/ConformalDecals/FontMenuController.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals.UI {
|
||||
public class FontMenuController : MonoBehaviour {
|
||||
[SerializeField] private GameObject _menuItem;
|
||||
[SerializeField] private GameObject _menuList;
|
||||
|
||||
public void Close() { }
|
||||
}
|
||||
}
|
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
|
37
Assets/ConformalDecals/Shaders/Decal/StandardDecal.cginc
Normal file
@ -0,0 +1,37 @@
|
||||
#include "DecalsCommon.cginc"
|
||||
#include "../SDF.cginc"
|
||||
|
||||
void surf(DecalSurfaceInput IN, inout SurfaceOutput o) {
|
||||
float4 color = tex2D(_Decal, IN.uv_decal);
|
||||
o.Albedo = color.rgb;
|
||||
o.Specular = 0.4;
|
||||
o.Gloss = _Shininess;
|
||||
|
||||
#ifdef DECAL_BASE_NORMAL
|
||||
float3 normal = IN.normal;
|
||||
float wearFactor = 1 - normal.z;
|
||||
o.Alpha *= saturate(1 + _EdgeWearOffset - saturate(_EdgeWearStrength * wearFactor));
|
||||
#endif
|
||||
|
||||
#ifdef DECAL_BUMPMAP
|
||||
o.Normal = UnpackNormalDXT5nm(tex2D(_BumpMap, IN.uv_bumpmap));
|
||||
#endif
|
||||
|
||||
#ifdef DECAL_SPECMAP
|
||||
float4 specular = tex2D(_SpecMap, IN.uv_specmap);
|
||||
o.Specular = specular;
|
||||
#endif
|
||||
|
||||
#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,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 %}
|
51
Assets/ConformalDecals/Shaders/Decal/TextDecal.cginc
Normal file
@ -0,0 +1,51 @@
|
||||
#include "DecalsCommon.cginc"
|
||||
#include "../SDF.cginc"
|
||||
|
||||
float4 _DecalColor;
|
||||
|
||||
float4 _OutlineColor;
|
||||
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;
|
||||
float outlineRadius = _OutlineWidth * 0.5;
|
||||
|
||||
#ifdef DECAL_FILL
|
||||
// Outline and Fill
|
||||
float outlineDist = -dist - outlineOffset;
|
||||
float outlineFactor = SDFAA(outlineDist);
|
||||
dist -= outlineOffset;
|
||||
color = lerp(_DecalColor, _OutlineColor, outlineFactor);
|
||||
#else
|
||||
// Outline Only
|
||||
float outlineDist = abs(dist) - outlineOffset;
|
||||
dist = outlineDist;
|
||||
color = _OutlineColor;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
dist = max(dist, BoundsDist(IN.uv, IN.vertex_normal, _DecalNormal));
|
||||
float ddist = SDFdDist(dist); // distance gradient magnitude
|
||||
o.Albedo = color.rgb;
|
||||
o.Alpha *= SDFAA(dist, ddist);
|
||||
|
||||
#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_SPECMAP
|
||||
float4 specular = tex2D(_SpecMap, IN.uv_specmap);
|
||||
o.Specular = specular;
|
||||
#endif
|
||||
}
|
@ -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
|
45
Assets/ConformalDecals/Shaders/SDF.cginc
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef SDF_INCLUDED
|
||||
#define SDF_INCLUDED
|
||||
|
||||
// based on functions by Inigo Quilez
|
||||
// https://iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm
|
||||
|
||||
// SDF of a box
|
||||
float sdBox( in float2 p, in float2 b ) {
|
||||
float2 d = abs(p)-b;
|
||||
return length(max(d,0.0)) + min(max(d.x,d.y),0.0);
|
||||
}
|
||||
|
||||
// SDF of a box with corner radius r
|
||||
float sdRoundedBox( in float2 p, in float2 b, in float r ) {
|
||||
float2 d = abs(p)-b+r;
|
||||
return min(max(d.x,d.y),0.0) + length(max(d,0.0)) - r;
|
||||
}
|
||||
|
||||
// SDF of a box with corner radius r, based on the current UV position
|
||||
// UV must be ∈ (0,1), with (0,0) on one corner
|
||||
float sdRoundedUVBox( float2 uv, float r ) {
|
||||
float dx = ddx(uv.x);
|
||||
float dy = ddy(uv.y);
|
||||
|
||||
float2 dim = abs(float2(1/dx, 1/dy));
|
||||
float2 halfDim = dim / 2;
|
||||
float2 pos = (dim * uv) - halfDim;
|
||||
|
||||
return sdRoundedBox(pos, halfDim, r);
|
||||
}
|
||||
|
||||
inline float SDFdDist(float dist) {
|
||||
return length(float2(ddx(dist), ddy(dist)));
|
||||
}
|
||||
|
||||
inline float SDFAA(float dist, float ddist) {
|
||||
float pixelDist = dist / ddist;
|
||||
return saturate(0.5-pixelDist);
|
||||
}
|
||||
|
||||
inline float SDFAA(float dist) {
|
||||
return SDFAA(dist, SDFdDist(dist));
|
||||
}
|
||||
|
||||
#endif
|
@ -12,7 +12,7 @@ Shader "ConformalDecals/SelectionGlow"
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Transparent" }
|
||||
Tags { "Queue" = "Transparent" "IgnoreProjector" = "true" }
|
||||
Cull Back
|
||||
ZWrite Off
|
||||
|
73
Assets/ConformalDecals/Shaders/TextBlit.shader
Normal file
@ -0,0 +1,73 @@
|
||||
Shader "ConformalDecals/Text Blit"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex("_MainTex (RGB spec(A))", 2D) = "white" {}
|
||||
|
||||
_WeightNormal("Weight Normal", float) = 0
|
||||
_WeightBold("Weight Bold", float) = 0.5
|
||||
|
||||
_ScaleRatioA("Scale RatioA", float) = 1
|
||||
_ScaleRatioB("Scale RatioB", float) = 1
|
||||
_ScaleRatioC("Scale RatioC", float) = 1
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Transparent" }
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
|
||||
Pass
|
||||
{
|
||||
BlendOp Max
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
// font weights to fake bold
|
||||
float _WeightNormal;
|
||||
float _WeightBold;
|
||||
|
||||
// no idea what these do
|
||||
float _ScaleRatioA;
|
||||
float _ScaleRatioB;
|
||||
float _ScaleRatioC;
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
|
||||
struct v2f {
|
||||
float4 pos : SV_POSITION;
|
||||
float4 uv : TEXCOORD0; // u, v, bias, 0
|
||||
};
|
||||
|
||||
v2f vert(float4 vertex : POSITION, float2 uv0 : TEXCOORD0, float2 uv1 : TEXCOORD1) {
|
||||
float bold = step(uv1.y, 0);
|
||||
float weight = lerp(_WeightNormal, _WeightBold, bold) * _ScaleRatioA / 8.0;
|
||||
float bias = 1 - weight;
|
||||
|
||||
v2f o;
|
||||
o.pos = UnityObjectToClipPos(vertex);
|
||||
o.uv = float4(uv0.x, uv0.y, bias, weight);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target {
|
||||
float2 uv = i.uv.xy;
|
||||
float bias = i.uv.z;
|
||||
float weight = i.uv.w;
|
||||
|
||||
fixed4 c = 0;
|
||||
c.r = saturate(tex2D(_MainTex,(uv)).a + weight);
|
||||
return c;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
141
Assets/ConformalDecals/Shaders/UI/ColorSlider.shader
Normal file
@ -0,0 +1,141 @@
|
||||
Shader "ConformalDecals/UI/Color Slider"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_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
|
||||
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||
|
||||
_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
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
"PreviewType"="Plane"
|
||||
"CanUseSpriteAtlas"="True"
|
||||
}
|
||||
Stencil
|
||||
{
|
||||
Ref [_Stencil]
|
||||
Comp [_StencilComp]
|
||||
Pass [_StencilOp]
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest [unity_GUIZTestMode]
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#pragma require integers
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
#include "HSL.cginc"
|
||||
#include "../SDF.cginc"
|
||||
|
||||
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile_local _ UNITY_UI_ALPHACLIP
|
||||
#pragma multi_compile_local HUE RED GREEN BLUE
|
||||
|
||||
float4 _ClipRect;
|
||||
float _Radius;
|
||||
float4 _Color;
|
||||
|
||||
float _OutlineGradient;
|
||||
float _OutlineOpacity;
|
||||
float _OutlineWidth;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 worldPosition : TEXCOORD1;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.worldPosition = v.vertex;
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float4 color = 1;
|
||||
|
||||
#ifdef HUE
|
||||
color.rgb = HSV2RGB(float3(i.uv.y, _Color.y, _Color.z));
|
||||
#endif //HUE
|
||||
|
||||
#ifdef RED
|
||||
color.rgb = float3(i.uv.x, _Color.g, _Color.b);
|
||||
#endif //RED
|
||||
|
||||
#ifdef GREEN
|
||||
color.rgb = float3(_Color.r, i.uv.x, _Color.b);
|
||||
#endif //GREEN
|
||||
|
||||
#ifdef BLUE
|
||||
color.rgb = float3(_Color.r, _Color.g, i.uv.x);
|
||||
#endif //BLUE
|
||||
|
||||
float rrect = sdRoundedUVBox(i.uv, _Radius);
|
||||
float gradient = smoothstep(_OutlineGradient, 1 - _OutlineGradient, i.uv.y);
|
||||
float outlineOpacity = _OutlineOpacity * smoothstep(-1*_OutlineWidth, 0, rrect);
|
||||
|
||||
color.rgb = lerp(color.rgb, gradient, outlineOpacity);
|
||||
|
||||
color.a = saturate(0.5 - rrect);
|
||||
|
||||
#ifdef UNITY_UI_CLIP_RECT
|
||||
color.a *= UnityGet2DClipping(i.worldPosition.xy, _ClipRect);
|
||||
#endif
|
||||
|
||||
#ifdef UNITY_UI_ALPHACLIP
|
||||
clip (color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
122
Assets/ConformalDecals/Shaders/UI/ColorSquare.shader
Normal file
@ -0,0 +1,122 @@
|
||||
Shader "ConformalDecals/UI/HSV Square"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_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
|
||||
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
"PreviewType"="Plane"
|
||||
"CanUseSpriteAtlas"="True"
|
||||
}
|
||||
Stencil
|
||||
{
|
||||
Ref [_Stencil]
|
||||
Comp [_StencilComp]
|
||||
Pass [_StencilOp]
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest [unity_GUIZTestMode]
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#pragma require integers
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
#include "HSL.cginc"
|
||||
#include "../SDF.cginc"
|
||||
|
||||
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile_local _ UNITY_UI_ALPHACLIP
|
||||
|
||||
float4 _ClipRect;
|
||||
float _Radius;
|
||||
float4 _Color;
|
||||
|
||||
float _OutlineGradient;
|
||||
float _OutlineOpacity;
|
||||
float _OutlineWidth;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 worldPosition : TEXCOORD1;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.worldPosition = v.vertex;
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
// sample the texture
|
||||
fixed4 color = 1;
|
||||
|
||||
color.a = saturate(0.5 - sdRoundedUVBox(i.uv, _Radius));
|
||||
|
||||
color.rgb = HSV2RGB(float3(_Color.x, i.uv.x, i.uv.y));
|
||||
|
||||
float rrect = sdRoundedUVBox(i.uv, _Radius);
|
||||
float gradient = smoothstep(_OutlineGradient, 1 - _OutlineGradient, i.uv.y);
|
||||
float outlineOpacity = _OutlineOpacity * smoothstep(-1*_OutlineWidth, 0, rrect);
|
||||
|
||||
color.rgb = lerp(color.rgb, gradient, outlineOpacity);
|
||||
|
||||
#ifdef UNITY_UI_CLIP_RECT
|
||||
color.a *= UnityGet2DClipping(i.worldPosition.xy, _ClipRect);
|
||||
#endif
|
||||
|
||||
#ifdef UNITY_UI_ALPHACLIP
|
||||
clip (color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
120
Assets/ConformalDecals/Shaders/UI/ColorSwatch.shader
Normal file
@ -0,0 +1,120 @@
|
||||
Shader "ConformalDecals/UI/Color Swatch"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_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
|
||||
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
"PreviewType"="Plane"
|
||||
"CanUseSpriteAtlas"="True"
|
||||
}
|
||||
Stencil
|
||||
{
|
||||
Ref [_Stencil]
|
||||
Comp [_StencilComp]
|
||||
Pass [_StencilOp]
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest [unity_GUIZTestMode]
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#pragma require integers
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
#include "HSL.cginc"
|
||||
#include "../SDF.cginc"
|
||||
|
||||
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile_local _ UNITY_UI_ALPHACLIP
|
||||
#pragma multi_compile_local HUE RED GREEN BLUE
|
||||
|
||||
float4 _ClipRect;
|
||||
float _Radius;
|
||||
float4 _Color;
|
||||
|
||||
float _OutlineGradient;
|
||||
float _OutlineOpacity;
|
||||
float _OutlineWidth;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 worldPosition : TEXCOORD1;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.worldPosition = v.vertex;
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
fixed4 color = _Color;
|
||||
|
||||
color.a = saturate(0.5 - sdRoundedUVBox(i.uv, _Radius));
|
||||
|
||||
float rrect = sdRoundedUVBox(i.uv, _Radius);
|
||||
float gradient = smoothstep(_OutlineGradient, 1 - _OutlineGradient, i.uv.y);
|
||||
float outlineOpacity = _OutlineOpacity * smoothstep(-1*_OutlineWidth, 0, rrect);
|
||||
|
||||
color.rgb = lerp(color.rgb, gradient, outlineOpacity);
|
||||
|
||||
#ifdef UNITY_UI_CLIP_RECT
|
||||
color.a *= UnityGet2DClipping(i.worldPosition.xy, _ClipRect);
|
||||
#endif
|
||||
|
||||
#ifdef UNITY_UI_ALPHACLIP
|
||||
clip (color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
17
Assets/ConformalDecals/Shaders/UI/HSL.cginc
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef HSL_INCLUDED
|
||||
#define HSL_INCLUDED
|
||||
|
||||
inline float3 HSL2RGB(float3 hsl) {
|
||||
int3 n = int3(0, 8, 4);
|
||||
float3 k = (n + hsl.x * 12) % 12;
|
||||
float a = hsl.y * min(hsl.z, 1 - hsl.z);
|
||||
return hsl.z - a * max(-1, min(k - 3, min(9 - k, 1)));
|
||||
}
|
||||
|
||||
inline float3 HSV2RGB(float3 hsv) {
|
||||
int3 n = int3(5, 3, 1);
|
||||
float3 k = (n + hsv.x * 6) % 6;
|
||||
return hsv.z - hsv.z * hsv.y * max(0, min(1, min(k, 4 - k)));
|
||||
}
|
||||
|
||||
#endif
|
37
Assets/ConformalDecals/TextEntryController.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ConformalDecals.UI {
|
||||
public class TextEntryController : MonoBehaviour {
|
||||
[SerializeField] private Selectable _textBox;
|
||||
[SerializeField] private Button _fontButton;
|
||||
|
||||
[SerializeField] private Slider _lineSpacingSlider;
|
||||
[SerializeField] private Selectable _lineSpacingTextBox;
|
||||
|
||||
[SerializeField] private Slider _charSpacingSlider;
|
||||
[SerializeField] private Selectable _charSpacingTextBox;
|
||||
|
||||
[SerializeField] private Toggle _boldButton;
|
||||
[SerializeField] private Toggle _italicButton;
|
||||
[SerializeField] private Toggle _underlineButton;
|
||||
[SerializeField] private Toggle _smallCapsButton;
|
||||
[SerializeField] private Toggle _verticalButton;
|
||||
|
||||
public void Close() { }
|
||||
|
||||
public void OnTextUpdate(string text) { }
|
||||
|
||||
public void OnFontMenu() { }
|
||||
|
||||
public void OnLineSpacingUpdate(float value) { }
|
||||
public void OnLineSpacingUpdate(string text) { }
|
||||
public void OnCharSpacingUpdate(float value) { }
|
||||
public void OnCharSpacingUpdate(string text) { }
|
||||
public void OnBoldUpdate(bool state) { }
|
||||
public void OnItalicUpdate(bool state) { }
|
||||
public void OnUnderlineUpdate(bool state) { }
|
||||
public void OnSmallCapsUpdate(bool state) { }
|
||||
public void OnVerticalUpdate(bool state) { }
|
||||
}
|
||||
}
|
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
BIN
Assets/ConformalDecals/Textures/Munar-Atlas.png
Normal file
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
BIN
Assets/ConformalDecals/Textures/UI.png
Normal file
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 |
93
Assets/ConformalDecals/UI/BSlider.mat
Normal file
@ -0,0 +1,93 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: BSlider
|
||||
m_Shader: {fileID: 4800000, guid: a6b2542ba8ea844e7b0526fab69d88ed, type: 3}
|
||||
m_ShaderKeywords: BLUE
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _Blue: 1
|
||||
- _BumpScale: 1
|
||||
- _ColorMask: 15
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _GradientStep: 0.331
|
||||
- _Green: 0
|
||||
- _Hue: 0
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _OutlineGradient: 0.7
|
||||
- _OutlineOpacity: 0.15
|
||||
- _OutlineWidth: 2.5
|
||||
- _Parallax: 0.02
|
||||
- _Radius: 4
|
||||
- _Red: 0
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _UVSec: 0
|
||||
- _UseUIAlphaClip: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
5492
Assets/ConformalDecals/UI/ColorPickerPanel.prefab
Normal file
1048
Assets/ConformalDecals/UI/FontMenuPanel.prefab
Normal file
93
Assets/ConformalDecals/UI/GSlider.mat
Normal file
@ -0,0 +1,93 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: GSlider
|
||||
m_Shader: {fileID: 4800000, guid: a6b2542ba8ea844e7b0526fab69d88ed, type: 3}
|
||||
m_ShaderKeywords: GREEN
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _Blue: 0
|
||||
- _BumpScale: 1
|
||||
- _ColorMask: 15
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _GradientStep: 0.2
|
||||
- _Green: 1
|
||||
- _Hue: 0
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _OutlineGradient: 0.7
|
||||
- _OutlineOpacity: 0.15
|
||||
- _OutlineWidth: 2.5
|
||||
- _Parallax: 0.02
|
||||
- _Radius: 4
|
||||
- _Red: 0
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _UVSec: 0
|
||||
- _UseUIAlphaClip: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
93
Assets/ConformalDecals/UI/HSLSlider.mat
Normal file
@ -0,0 +1,93 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: HSLSlider
|
||||
m_Shader: {fileID: 4800000, guid: a6b2542ba8ea844e7b0526fab69d88ed, type: 3}
|
||||
m_ShaderKeywords: HUE
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _Blue: 0
|
||||
- _BumpScale: 1
|
||||
- _ColorMask: 15
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _GradientStep: 0.2
|
||||
- _Green: 0
|
||||
- _Hue: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _OutlineGradient: 0.55
|
||||
- _OutlineOpacity: 0.15
|
||||
- _OutlineWidth: 2.5
|
||||
- _Parallax: 0.02
|
||||
- _Radius: 4
|
||||
- _Red: 0
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _UVSec: 0
|
||||
- _UseUIAlphaClip: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
89
Assets/ConformalDecals/UI/HSLSquare.mat
Normal file
@ -0,0 +1,89 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: HSLSquare
|
||||
m_Shader: {fileID: 4800000, guid: 41b82117f67243a4851d2ce6bbed0d6a, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _ColorMask: 15
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Hue: 0.566
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _OutlineGradient: 0.55
|
||||
- _OutlineOpacity: 0.15
|
||||
- _OutlineWidth: 2.5
|
||||
- _Parallax: 0.02
|
||||
- _Radius: 4
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _UVSec: 0
|
||||
- _UseUIAlphaClip: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
93
Assets/ConformalDecals/UI/RSlider.mat
Normal file
@ -0,0 +1,93 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: RSlider
|
||||
m_Shader: {fileID: 4800000, guid: a6b2542ba8ea844e7b0526fab69d88ed, type: 3}
|
||||
m_ShaderKeywords: RED
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _Blue: 0
|
||||
- _BumpScale: 1
|
||||
- _ColorMask: 15
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _GradientStep: 0.2
|
||||
- _Green: 0
|
||||
- _Hue: 0
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _OutlineGradient: 0.7
|
||||
- _OutlineOpacity: 0.15
|
||||
- _OutlineWidth: 2.5
|
||||
- _Parallax: 0.02
|
||||
- _Radius: 4
|
||||
- _Red: 1
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _UVSec: 0
|
||||
- _UseUIAlphaClip: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
92
Assets/ConformalDecals/UI/Swatch.mat
Normal file
@ -0,0 +1,92 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Swatch
|
||||
m_Shader: {fileID: 4800000, guid: a6e04e87fe864ed6a3f6a3ce52f57024, type: 3}
|
||||
m_ShaderKeywords: RED
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _Blue: 0
|
||||
- _BumpScale: 1
|
||||
- _ColorMask: 15
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Green: 0
|
||||
- _Hue: 0
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _OutlineGradient: 0.3
|
||||
- _OutlineOpacity: 0.15
|
||||
- _OutlineWidth: 2.5
|
||||
- _Parallax: 0.02
|
||||
- _Radius: 4
|
||||
- _Red: 1
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _UVSec: 0
|
||||
- _UseUIAlphaClip: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0.5176471, g: 0.5019608, b: 0.5019608, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
5193
Assets/ConformalDecals/UI/TextEntryPanel.prefab
Normal file
1
Assets/ConformalDecals/UITag.cs
Symbolic link
@ -0,0 +1 @@
|
||||
/Users/drewcassidy/Projects/KSP-Conformal-Decals/Source/ConformalDecals/UI/UITag.cs
|
@ -1,47 +0,0 @@
|
||||
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;
|
||||
_matrixID = Shader.PropertyToID("_ProjectionMatrix");
|
||||
_normalID = Shader.PropertyToID("_DecalNormal");
|
||||
_tangentID= Shader.PropertyToID("_DecalTangent");
|
||||
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(_matrixID, _projectionMatrix);
|
||||
targetMaterial.SetVector(_normalID, projectorToTarget.MultiplyVector(Vector3.back).normalized);
|
||||
targetMaterial.SetVector(_tangentID, projectorToTarget.MultiplyVector(Vector3.right).normalized);
|
||||
}
|
||||
}
|
@ -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"
|
||||
}
|
||||
}
|
@ -1,287 +0,0 @@
|
||||
#ifndef DECALS_COMMON_INCLUDED
|
||||
#define DECALS_COMMON_INCLUDED
|
||||
|
||||
struct DecalSurfaceInput
|
||||
{
|
||||
float2 uv_decal;
|
||||
|
||||
#ifdef DECAL_NORMAL
|
||||
float2 uv_bump;
|
||||
#endif //DECAL_NORMAL
|
||||
|
||||
#ifdef DECAL_SPECULAR
|
||||
float2 uv_spec;
|
||||
#endif //DECAL_SPECULAR
|
||||
|
||||
#ifdef DECAL_EMISSIVE
|
||||
float2 uv_glow;
|
||||
#endif //DECAL_EMISSIVE
|
||||
|
||||
#ifdef DECAL_BASE_NORMAL
|
||||
float3 normal;
|
||||
#endif
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
// Projection matrix, normal, and tangent vectors
|
||||
float4x4 _ProjectionMatrix;
|
||||
float3 _DecalNormal;
|
||||
float3 _DecalTangent;
|
||||
|
||||
#ifdef DECAL_BASE_NORMAL
|
||||
sampler2D _BumpMap;
|
||||
float4 _BumpMap_ST;
|
||||
#endif //DECAL_BASE_NORMAL
|
||||
|
||||
float _Cutoff;
|
||||
float _DecalOpacity;
|
||||
float _Opacity;
|
||||
float4 _Background;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// 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
|
||||
{
|
||||
// declare data
|
||||
DecalSurfaceInput i;
|
||||
SurfaceOutput o;
|
||||
fixed4 c = 0;
|
||||
|
||||
// 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;
|
||||
|
||||
#ifdef DECAL_PREVIEW
|
||||
fixed4 uv_projected = IN.uv_decal;
|
||||
#else
|
||||
// perform decal projection
|
||||
fixed4 uv_projected = UNITY_PROJ_COORD(IN.uv_decal);
|
||||
|
||||
// clip texture outside of xyz bounds
|
||||
clip(uv_projected.xyz);
|
||||
clip(1-uv_projected.xyz);
|
||||
|
||||
// clip backsides
|
||||
clip(dot(_DecalNormal, IN.normal));
|
||||
#endif //DECAL_PREVIEW
|
||||
|
||||
// initialize surface input
|
||||
UNITY_INITIALIZE_OUTPUT(DecalSurfaceInput, i)
|
||||
i.uv_decal = TRANSFORM_TEX(uv_projected, _Decal);
|
||||
|
||||
#ifdef DECAL_NORMAL
|
||||
i.uv_bump = TRANSFORM_TEX(uv_projected, _DecalBumpMap);
|
||||
#endif //DECAL_NORMAL
|
||||
|
||||
#ifdef DECAL_SPECULAR
|
||||
i.uv_spec = TRANSFORM_TEX(uv_projected, _SpecMap);
|
||||
#endif //DECAL_SPECULAR
|
||||
|
||||
#ifdef DECAL_EMISSIVE
|
||||
i.uv_glow = TRANSFORM_TEX(uv_projected, _GlowMap);
|
||||
#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.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
|
||||
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
|
229
CHANGELOG.md
Normal file
@ -0,0 +1,229 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file
|
||||
|
||||
| modName | Conformal Decals |
|
||||
| ------- |:-------------------------------------------------------------------------------------|
|
||||
| license | CC-By-SA & GPL3 |
|
||||
| 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
|
||||
|
||||
- Fixed flag decals sometimes not respecting image aspect ratio
|
||||
|
||||
|
||||
## 0.2.12 - 2022-10-31
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated bundled Shabby to 0.3.0. Does not affect CKAN users
|
||||
- Made flag aspect ratio overrides configurable with `ASPECTRATIO` nodes in the config. User flags added to Squad/Flags should now be the correct aspect ratio
|
||||
- All decal aspect ratios can now be overriden with the `aspectRatio` field
|
||||
|
||||
### Fixed
|
||||
|
||||
- Reverted some changes from last version that were causing issues on launch
|
||||
|
||||
|
||||
## 0.2.11 - 2022-10-30
|
||||
|
||||
### Fixed
|
||||
|
||||
- PR by LinuxGuruGamer:
|
||||
- Fixed nullref caused when an entry in `_targets` was null
|
||||
- Fixed memory leak caused by the OnDestroy() methods not being called due to them being virtual
|
||||
|
||||
|
||||
## 0.2.10 - 2022-03-14
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed decals not projecting on loading prefabs
|
||||
|
||||
### Changed
|
||||
|
||||
- Re-enabled projecting onto TransparentFX layer
|
||||
|
||||
### Added
|
||||
|
||||
- Allowed for regular expressions to be used when blacklisting shaders
|
||||
- Added all Waterfall shaders to the shader blacklist when Waterfall is present
|
||||
|
||||
|
||||
## 0.2.9 - 2022-03-12
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed text decals breaking when used in symmetry
|
||||
- Fixed decals projecting onto the TransparentFX layer, such as Waterfall plumes
|
||||
|
||||
|
||||
## 0.2.8
|
||||
|
||||
- Update bundled Shabby to support Harmony 2 for compatibility with other mods
|
||||
- Update bundled B9PartSwitch to 2.18.0
|
||||
|
||||
|
||||
## 0.2.7
|
||||
|
||||
- Supported KSP versions: 1.8.x to 1.11.x
|
||||
|
||||
### Notes:
|
||||
|
||||
- Attaching decal parts in flight using engineer kerbals is not supported.
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed certain non-ascii strings not rendering correctly under certain circumstances.
|
||||
- Yet another attempted fix for the planet text glitch.
|
||||
|
||||
|
||||
## 0.2.6
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed stock flags appearing stretched by forcing their aspect ratio to be correct.
|
||||
- Another attempted fix for the planet text glitch.
|
||||
|
||||
|
||||
## 0.2.5
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed line spacing, character spacing, and vertical settings not applying to symmetry counterparts
|
||||
|
||||
|
||||
## 0.2.4
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed red text appearing on planets due to KSP bug by clearing render textures afterwards.
|
||||
- Fixed fonts not saving correctly.
|
||||
|
||||
### Changed:
|
||||
|
||||
- Lowered step size for decal size and depth to 1cm.
|
||||
- Changed default max size to 5m.
|
||||
- Changed default text decal size to 0.2m
|
||||
- Text decals now show as a circle if they contain only whitespace.
|
||||
|
||||
|
||||
## 0.2.3
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed TMP subobjects being deleted, causing fallback fonts to fail in some situations.
|
||||
- Started using URL-style encoding for text decals behind the scenes to prevent issues with certain characters.
|
||||
- Fixed text decals having zero size when they had only whitespace or an empty string.
|
||||
- Fixed decals having drag and causing issues when using FAR.
|
||||
- Fixed broken saving of text decals in certain circumstances.
|
||||
|
||||
|
||||
## 0.2.2
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed corrupted text rendering when a vessel loads during a scene change.
|
||||
|
||||
|
||||
## 0.2.1
|
||||
|
||||
### Changed:
|
||||
|
||||
- Pressing enter in the text entry window now types a newline.
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Renamed font assetbundle. The old extension was causing the game to try to load it twice on Windows due to legacy compatability features.
|
||||
- Fixed text rendering on DirectX resulting in black boxes by using ARGB32 instead of RG16 for the render texture in DirectX.
|
||||
|
||||
|
||||
## 0.2.0
|
||||
|
||||
### New Parts:
|
||||
|
||||
- CDL-3 Surface Base Decal: A set of conformal decals based on the symbols from the movie Moon (2009) designed by Gavin Rothery
|
||||
- CDL-T Custom Text Decal: A customizable text decal with a variety of fonts
|
||||
|
||||
### Changed:
|
||||
|
||||
- New ModuleConformalText module for customizable text
|
||||
- Text, font, and style can all be customized, as well as text fill and outline colors and widths
|
||||
- Same projection and opacity options as other conformal decals
|
||||
- New StandardText decal shader supporting the text module
|
||||
- Unified all decal shaders into a single "StandardDecal" shader with variants supporting any combination of bump, specular and emissive maps, plus SDF alphas.
|
||||
- Old shaders are remapped to Standard shader plus keywords automatically.
|
||||
- New SDF-based antialiasing for when decals extend to their borders, e.g. on opaque flags.
|
||||
- New "KEYWORD" material modifier, allowing for shader features to be enabled and disabled.
|
||||
- Material modifiers can now be removed in variants by setting `remove = true` inside them.
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed WIDTH and HEIGHT scale modes being flipped
|
||||
- Removed some debug log statements
|
||||
- Dependencies:
|
||||
- Updated ModuleManager to version 4.1.4
|
||||
|
||||
|
||||
## 0.1.4
|
||||
|
||||
Supported KSP versions: 1.8.x to 1.10.x
|
||||
|
||||
### Fixed:
|
||||
|
||||
- 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.
|
||||
|
||||
|
||||
## 0.1.3
|
||||
|
||||
### Fixe:
|
||||
|
||||
- Fixed decals being able to be scaled down to 0
|
||||
|
||||
### Changed:
|
||||
|
||||
- Made decal bounds no longer collide in flight, this is done by repurposing layer 31 (which is configurable in the ConformalDecals.cfg file)
|
||||
- Decals will now be unselectable in flight by default. This can be disabled with the `selectableInFlight` value in ConformalDecals.cfg, or in the module config itself.
|
||||
- Decal parts will now destroy themselves automatically when the parent part is destroyed
|
||||
- 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
|
||||
|
||||
|
||||
## 0.1.2
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Disabled writing to the zbuffer in the decal bounds shader. Should fix any issues with Scatterer or EVE.
|
||||
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Fixed flag decal not adjusting to new texture sizes immediately.
|
||||
- Fixed decal bounds being visible on launch.
|
||||
- Fixed decal bounds being visible in the part icon.
|
||||
|
||||
|
||||
## 0.1.0
|
||||
|
||||
Initial release!
|
||||
|
||||
### New Parts:
|
||||
|
||||
- CDL-F Flag Decal: Conformal flag decal, which uses either the mission flag or a flag of your choosing.
|
||||
- CDL-1 Generic Decal: A set of conformal generic decals for planes and rockets
|
||||
- CDL-2 Semiotic Standard Decal: A set of conformal decals based on the Semiotic Standard for All Commercial Trans-Stellar Utility Lifter and Transport Spacecraft designed by Ron Cobb for the movie Alien
|
BIN
GameData/ConformalDecals/Assets/paper.dds
Normal file
@ -18,6 +18,14 @@ Localization
|
||||
#LOC_ConformalDecals_gui-aspectratio = Aspect Ratio
|
||||
#LOC_ConformalDecals_gui-select-flag = Select Flag
|
||||
#LOC_ConformalDecals_gui-reset-flag = Reset Flag
|
||||
#LOC_ConformalDecals_gui-set-text = Set Text
|
||||
#LOC_ConformalDecals_gui-group-fill = Fill
|
||||
#LOC_ConformalDecals_gui-group-outline = Outline
|
||||
#LOC_ConformalDecals_gui-fill = Fill
|
||||
#LOC_ConformalDecals_gui-set-fill-color = Set Fill Color
|
||||
#LOC_ConformalDecals_gui-outline = Outline
|
||||
#LOC_ConformalDecals_gui-outline-width = Outline Width
|
||||
#LOC_ConformalDecals_gui-set-outline-color = Set Outline Color
|
||||
|
||||
// PARTS
|
||||
|
||||
@ -26,6 +34,11 @@ Localization
|
||||
#LOC_ConformalDecals_flag-description = A simple switchable flag. Can either use the mission flag or select a specific flag to use.
|
||||
#LOC_ConformalDecals_flag-tags = conformal decal sticker flag
|
||||
|
||||
// Text
|
||||
#LOC_ConformalDecals_text-title = CDL-T Text Decal
|
||||
#LOC_ConformalDecals_text-description = A decal that can display custom text in a variety of fonts
|
||||
#LOC_ConformalDecals_text-tags = conformal decal sticker text font
|
||||
|
||||
// Generic Decals
|
||||
#LOC_ConformalDecals_generic-title = CDL-1 Generic Decal
|
||||
#LOC_ConformalDecals_generic-description = A set of generic warning decals and signs to add to your vehicles.
|
||||
@ -64,7 +77,7 @@ Localization
|
||||
|
||||
// Semiotic Decals
|
||||
#LOC_ConformalDecals_semiotic-title = CDL-2 Semiotic Standard Decal
|
||||
#LOC_ConformalDecals_semiotic-description = After several unfortunate mishaps with confusing signage on spacecraft, The Peel-N-Stik™ Corporation teamed up with Kerland-Mutani to unveil the Semiotic Standard for Kerbal Vessels, a set of standardized icons for use on ships and stations.
|
||||
#LOC_ConformalDecals_semiotic-description = After several unfortunate mishaps with confusing signage on spacecraft, The Peel-N-Stik™ Corporation teamed up with Kerland-Mutani to unveil the Semiotic Standard for Kerbal Vessels, a set of standardized icons for use on ships and stations. (Based on the work of Ron Cobb)
|
||||
#LOC_ConformalDecals_semiotic-tags = conformal decal sticker semiotic standard for kerbal vessels Ron Cobb Alien
|
||||
#LOC_ConformalDecals_semiotic-variant-00 = Hazard
|
||||
#LOC_ConformalDecals_semiotic-variant-01 = Blank
|
||||
@ -98,5 +111,47 @@ Localization
|
||||
#LOC_ConformalDecals_semiotic-variant-29 = Radiation Hazard
|
||||
#LOC_ConformalDecals_semiotic-variant-30 = Radiation Bunker
|
||||
#LOC_ConformalDecals_semiotic-variant-31 = Exhaust
|
||||
|
||||
// Munar Decals
|
||||
#LOC_ConformalDecals_munar-title = CDL-3 Surface Base Decal
|
||||
#LOC_ConformalDecals_munar-description = 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)
|
||||
#LOC_ConformalDecals_munar-tag = conformal decal sticker Moon munar lunar industries Gavin Rothery Sarang
|
||||
#LOC_ConformalDecals_munar-variant-severe-danger = Severe Danger
|
||||
#LOC_ConformalDecals_munar-variant-danger = Danger
|
||||
#LOC_ConformalDecals_munar-variant-hazard = Hazard
|
||||
#LOC_ConformalDecals_munar-variant-warning = Warning
|
||||
#LOC_ConformalDecals_munar-variant-bulkhead = Bulkhead
|
||||
#LOC_ConformalDecals_munar-variant-hatch = Hatch
|
||||
#LOC_ConformalDecals_munar-variant-pressure-hatch = Hatch (Pressurized)
|
||||
#LOC_ConformalDecals_munar-variant-door = Doorway
|
||||
#LOC_ConformalDecals_munar-variant-door-danger = Do Not Obstruct
|
||||
#LOC_ConformalDecals_munar-variant-airlock-interior = Airlock (Interior)
|
||||
#LOC_ConformalDecals_munar-variant-airlock-exterior = Airlock (Exterior)
|
||||
#LOC_ConformalDecals_munar-variant-check-seals = Check All Seals
|
||||
#LOC_ConformalDecals_munar-variant-pressure-seal = Pressure Seal
|
||||
#LOC_ConformalDecals_munar-variant-vacuum = Danger Vacuum
|
||||
#LOC_ConformalDecals_munar-variant-gas-mask = Breathing Apparatus Required
|
||||
#LOC_ConformalDecals_munar-variant-oxygen-rich = Oxygen Rich Environment
|
||||
#LOC_ConformalDecals_munar-variant-robotic-work = Heavy Robotic Work Ahead
|
||||
#LOC_ConformalDecals_munar-variant-explosion = Explosion Hazard
|
||||
#LOC_ConformalDecals_munar-variant-radiation = Radiation Hazard
|
||||
#LOC_ConformalDecals_munar-variant-antimatter = Annihilation Hazard
|
||||
#LOC_ConformalDecals_munar-variant-high-voltage = High Voltage
|
||||
#LOC_ConformalDecals_munar-variant-extreme-voltage = Extreme Voltage
|
||||
#LOC_ConformalDecals_munar-variant-explosive-bolts = Explosive Bolts
|
||||
#LOC_ConformalDecals_munar-variant-autonomous-device = Autonomous Device
|
||||
#LOC_ConformalDecals_munar-variant-gravity-adjust = Gravity Adjust
|
||||
#LOC_ConformalDecals_munar-variant-electromagnetic = Strong EM Field
|
||||
#LOC_ConformalDecals_munar-variant-mind-step = Mind Step
|
||||
#LOC_ConformalDecals_munar-variant-class-1 = Class 1 Hazard: Flammable Liquid
|
||||
#LOC_ConformalDecals_munar-variant-class-2 = Class 2 Hazard: Flammable Solid
|
||||
#LOC_ConformalDecals_munar-variant-class-3 = Class 3 Hazard: Magnetic Field
|
||||
#LOC_ConformalDecals_munar-variant-class-4 = Class 4 Hazard: Electric Field
|
||||
#LOC_ConformalDecals_munar-variant-class-5 = Class 5 Hazard: Pressurized Fuel
|
||||
#LOC_ConformalDecals_munar-variant-class-6 = Class 6 Hazard: Pressurized Coolant
|
||||
#LOC_ConformalDecals_munar-variant-class-7 = Class 7 Hazard: Cryogenic Liquid
|
||||
#LOC_ConformalDecals_munar-variant-class-8 = Class 8 Hazard: Radioactive
|
||||
#LOC_ConformalDecals_munar-variant-class-9 = Class 9 Hazard: Ionized Gas
|
||||
#LOC_ConformalDecals_munar-variant-class-10 = Class 10 Hazard: Antimatter
|
||||
}
|
||||
}
|
@ -65,7 +65,12 @@ PART
|
||||
scaleRange = 0.1, 4
|
||||
scaleMode = AVERAGE
|
||||
|
||||
shader = ConformalDecals/Paint/Specular
|
||||
shader = ConformalDecals/Decal/Standard
|
||||
|
||||
KEYWORD {
|
||||
name = DECAL_SDF_ALPHA
|
||||
value = false
|
||||
}
|
||||
|
||||
TEXTURE {
|
||||
name = _Decal
|
||||
@ -108,7 +113,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 128, 2, 128, 112
|
||||
}
|
||||
}
|
||||
@ -123,7 +128,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 256, 2, 128, 112
|
||||
}
|
||||
}
|
||||
@ -138,7 +143,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 384, 2, 128, 112
|
||||
}
|
||||
}
|
||||
@ -153,7 +158,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 690, 4, 330, 118
|
||||
}
|
||||
}
|
||||
@ -168,7 +173,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 898, 4, 122, 118
|
||||
}
|
||||
}
|
||||
@ -183,7 +188,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 6, 126, 196, 132
|
||||
}
|
||||
}
|
||||
@ -198,7 +203,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 210, 122, 94, 94
|
||||
}
|
||||
}
|
||||
@ -213,7 +218,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 8, 262, 192, 70
|
||||
}
|
||||
}
|
||||
@ -242,7 +247,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 508, 332, 262, 112
|
||||
}
|
||||
}
|
||||
@ -257,7 +262,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 202, 218, 164, 114
|
||||
}
|
||||
}
|
||||
@ -272,7 +277,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 366, 218, 164, 114
|
||||
}
|
||||
}
|
||||
@ -347,7 +352,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 326, 426, 164, 20
|
||||
}
|
||||
}
|
||||
@ -363,7 +368,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 776, 388, 48, 48
|
||||
}
|
||||
}
|
||||
@ -378,7 +383,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 328, 456, 48, 48
|
||||
}
|
||||
}
|
||||
@ -393,7 +398,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 376, 456, 48, 48
|
||||
}
|
||||
}
|
||||
@ -408,7 +413,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 424, 456, 48, 48
|
||||
}
|
||||
}
|
||||
@ -423,7 +428,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 472, 456, 48, 48
|
||||
}
|
||||
}
|
||||
@ -438,7 +443,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 520, 456, 48, 48
|
||||
}
|
||||
}
|
||||
@ -453,7 +458,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 568, 456, 48, 48
|
||||
}
|
||||
}
|
||||
@ -468,7 +473,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 614, 456, 48, 48
|
||||
}
|
||||
}
|
||||
@ -483,7 +488,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 662, 456, 48, 48
|
||||
}
|
||||
}
|
||||
@ -498,7 +503,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 710, 456, 48, 48
|
||||
}
|
||||
}
|
||||
@ -513,7 +518,7 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/SpecularSDF
|
||||
KEYWORD { name = DECAL_SDF_ALPHA }
|
||||
tile = 758, 456, 48, 48
|
||||
}
|
||||
}
|
||||
@ -528,7 +533,10 @@ PART
|
||||
MODULE {
|
||||
IDENTIFIER { name = ModuleConformalDecal }
|
||||
DATA {
|
||||
shader = ConformalDecals/Paint/Diffuse
|
||||
TEXTURE {
|
||||
name = _SpecMap
|
||||
remove = true
|
||||
}
|
||||
|
||||
tile = 826, 360, 196, 150
|
||||
opacity = 1
|
||||
|
BIN
GameData/ConformalDecals/Parts/Munar/Munar-Atlas.dds
Normal file
537
GameData/ConformalDecals/Parts/Munar/decal-munar.cfg
Normal file
@ -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 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -21,13 +21,13 @@ PART
|
||||
cost = 75
|
||||
category = Structural
|
||||
|
||||
// CDL-1 Semiotic Standard Decal
|
||||
// CDL-2 Semiotic Standard Decal
|
||||
title = #LOC_ConformalDecals_semiotic-title
|
||||
|
||||
// Peel-N-Stik Adhesive Decals
|
||||
manufacturer = #LOC_ConformalDecals_agent-peel-n-stick_title
|
||||
|
||||
// After several unfortunate mishaps with confusing signage on spacecraft, The Peel-N-Stik™ Corporation teamed up with Kerland-Mutani to unveil the Semiotic Standard for Kerbal Vessels, a set of standardized icons for use on ships and stations.
|
||||
// After several unfortunate mishaps with confusing signage on spacecraft, The Peel-N-Stik™ Corporation teamed up with Kerland-Mutani to unveil the Semiotic Standard for Kerbal Vessels, a set of standardized icons for use on ships and stations. (Based on the work of Ron Cobb)
|
||||
description = #LOC_ConformalDecals_semiotic-description
|
||||
|
||||
// conformal decal sticker semiotic standard for kerbal vessels Ron Cobb Alien
|
||||
@ -62,7 +62,7 @@ PART
|
||||
scaleRange = 0.05, 0.5
|
||||
cutoffAdjustable = false
|
||||
|
||||
shader = ConformalDecals/Paint/Specular
|
||||
shader = ConformalDecals/Decal/Standard
|
||||
|
||||
TEXTURE {
|
||||
name = _Decal
|
||||
|
@ -53,5 +53,13 @@ PART
|
||||
|
||||
defaultDepth = 0.2
|
||||
defaultCutoff = 0
|
||||
|
||||
shader = ConformalDecals/Decal/Standard
|
||||
|
||||
TEXTURE {
|
||||
name = _SpecMap
|
||||
textureUrl = ConformalDecals/Assets/Decal-Spec
|
||||
autoScale = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
69
GameData/ConformalDecals/Parts/decal-text.cfg
Normal file
@ -0,0 +1,69 @@
|
||||
PART
|
||||
{
|
||||
name = conformaldecals-text
|
||||
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.1, 0.0, 0.0, -1.0
|
||||
|
||||
// Tech
|
||||
TechRequired = start
|
||||
|
||||
// Info
|
||||
cost = 75
|
||||
category = Structural
|
||||
|
||||
// CDL-T Text Decal
|
||||
title = #LOC_ConformalDecals_text-title
|
||||
|
||||
|
||||
// Peel-N-Stik Adhesive Decals
|
||||
manufacturer = #LOC_ConformalDecals_agent-peel-n-stick_title
|
||||
|
||||
// A decal that can display custom text in a variety of fonts
|
||||
description = #LOC_ConformalDecals_text-description
|
||||
|
||||
|
||||
// conformal decal sticker text font
|
||||
tags = #LOC_ConformalDecals_text-tags
|
||||
|
||||
bulkheadProfiles = srf
|
||||
|
||||
// Parameters
|
||||
mass = 0.0005
|
||||
dragModel = NONE
|
||||
angularDrag = 0.0
|
||||
crashTolerance = 10
|
||||
maxTemp = 2000
|
||||
breakingForce = 350
|
||||
breakingTorque = 150
|
||||
physicalSignificance = NONE
|
||||
|
||||
MODULE
|
||||
{
|
||||
name = ModuleConformalText
|
||||
|
||||
text = Text
|
||||
fontName = Calibri SDF
|
||||
fillColor = #000000FF
|
||||
outlineColor = #FFFFFFFF
|
||||
fillEnabled = true
|
||||
outlineEnabled = false
|
||||
|
||||
shader = ConformalDecals/Decal/Text
|
||||
useBaseNormal = true
|
||||
scaleMode = MINIMUM
|
||||
|
||||
defaultScale = 0.2
|
||||
defaultDepth = 0.2
|
||||
defaultCutoff = 0.5
|
||||
}
|
||||
}
|
17
GameData/ConformalDecals/Patches/FAR.cfg
Normal file
@ -0,0 +1,17 @@
|
||||
// Decals are just paint, so they shouldnt affect a vessel's aerodynamics at all
|
||||
|
||||
@PART[*]:HAS[@MODULE[ModuleConformalDecal]]:After[FerramAerospaceResearch]
|
||||
{
|
||||
!MODULE[GeometryPartModule] {}
|
||||
}
|
||||
|
||||
@PART[*]:HAS[@MODULE[ModuleConformalFlag]]:After[FerramAerospaceResearch]
|
||||
{
|
||||
!MODULE[GeometryPartModule] {}
|
||||
}
|
||||
|
||||
@PART[*]:HAS[@MODULE[ModuleConformalText]]:After[FerramAerospaceResearch]
|
||||
{
|
||||
|
||||
!MODULE[GeometryPartModule] {}
|
||||
}
|
7
GameData/ConformalDecals/Patches/Waterfall.cfg
Normal file
@ -0,0 +1,7 @@
|
||||
// Prevent projection onto Waterfall plumes
|
||||
|
||||
CONFORMALDECALS:NEEDS[Waterfall] {
|
||||
SHADERBLACKLIST {
|
||||
shaderRegex = Waterfall/.*
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
// Custom category, requires WildBlueTools to work
|
||||
MODCAT
|
||||
{
|
||||
name = conformaldecals
|
||||
title = #LOC_ConformalDecals_category-decals_title // Decals
|
||||
|
||||
folderName = ConformalDecals
|
||||
|
@ -4,20 +4,354 @@ 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)
|
||||
shaderRegex = KSP/Alpha/.*
|
||||
shaderRegex = KSP/Particles/.*
|
||||
}
|
||||
|
||||
FONT {
|
||||
name = LiberationSans SDF
|
||||
title = Liberation Sans
|
||||
}
|
||||
|
||||
FONT {
|
||||
name = Calibri SDF
|
||||
title = Calibri
|
||||
}
|
||||
|
||||
FONT {
|
||||
name = NotoSans-Regular SDF
|
||||
title = Noto Sans
|
||||
}
|
||||
|
||||
FONT {
|
||||
name = Waukegan LDO Extended SDF
|
||||
title = Waukegan Extended
|
||||
}
|
||||
|
||||
FONT {
|
||||
name = Nasalization SDF
|
||||
title = Nasalization
|
||||
}
|
||||
|
||||
FONT {
|
||||
name = Helvetica SDF
|
||||
title = Helvetica
|
||||
}
|
||||
|
||||
FONT {
|
||||
name = amarurgt SDF
|
||||
title = Amarillo USAF
|
||||
style = 32
|
||||
styleMask = 4
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/09
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/Sentinel_Flag
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/blorbs
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/bullseye
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/capsule
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/circles
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/default
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/hexagon
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/hexagonCircles
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/kerbal1
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/kerbal2
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/kerbin
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/kerbinmunflag
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/line
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/minimalistic
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/orbit
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/orbs
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/retro
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/rings
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/rocketScience
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/satellite
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/spheres
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/squadLogo
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/squadLogo2
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/stripes
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/trees
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Flags/trippy
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/FlagsAgency/NASA
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/FlagsAgency/esa_dark_blue
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/FlagsAgency/uk_space_agency
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/FlagsOrganization/B612_Foundation_flag
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/FlagsOrganization/ESA_Arianespace
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/FlagsOrganization/electron
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/FlagsOrganization/rocketlab
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/C7AerospaceDivision
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/DinkelsteinKermansConstructionEmporium
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/ExperimentalEngineering
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/FlooydResearchLab
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/GoliathNationalProducts
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/IntegratedIntegrals
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/IonicSymphonicProtonicElectronics
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/JebsJunkyard
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/KerbalMotion
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/KerbinWorldFirstRecordKeepingSociety
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/Kerbodyne
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/Kerlington
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/MaxoConstructionToys
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/MovingPartsExpertsGroup
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/OMBDemolition
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/PeriapsisCo
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/Probodobodyne
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/R&D
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/ReactionSystemsLtd
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/Rockomax
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/Rokea
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/SeansCannery
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/SteadlerEngineeringCorps
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/StrutCo
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/Vac-Co
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/WinterOwl
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
|
||||
ASPECTRATIO {
|
||||
path = Squad/Agencies/ZaltonicElectronics
|
||||
aspectRatio = 0.625
|
||||
}
|
||||
}
|
BIN
GameData/ConformalDecals/Resources/conformaldecals.decalfont
Normal file
BIN
GameData/ConformalDecals/Resources/ui.conformaldecals
Normal file
@ -1,28 +1,24 @@
|
||||
{
|
||||
"NAME":"ConformalDecals",
|
||||
"URL":"https://raw.githubusercontent.com/drewcassidy/KSP-Conformal-Decals/release/GameData/ConformalDecals/Versioning/ConformalDecals.version",
|
||||
"DOWNLOAD":"https://github.com/drewcassidy/KSP-Conformal-Decals/releases",
|
||||
"VERSION":
|
||||
{
|
||||
"MAJOR":0,
|
||||
"MINOR":1,
|
||||
"PATCH":3,
|
||||
"BUILD":0
|
||||
"NAME": "ConformalDecals",
|
||||
"URL": "https://github.com/drewcassidy/KSP-Conformal-Decals/releases/latest/download/ConformalDecals.version",
|
||||
"DOWNLOAD": "https://github.com/drewcassidy/KSP-Conformal-Decals/releases/latest",
|
||||
"CHANGE_LOG_URL": "https://raw.githubusercontent.com/drewcassidy/KSP-Conformal-Decals/release/CHANGELOG.md",
|
||||
"VERSION": {
|
||||
"MAJOR": 9,
|
||||
"MINOR": 9,
|
||||
"PATCH": 9,
|
||||
"BUILD": 100000
|
||||
},
|
||||
"KSP_VERSION":
|
||||
{
|
||||
"MAJOR":1,
|
||||
"MINOR":9,
|
||||
"PATCH":1
|
||||
"KSP_VERSION": {
|
||||
"MAJOR": 1,
|
||||
"MINOR": 12
|
||||
},
|
||||
"KSP_VERSION_MIN":{
|
||||
"MAJOR":1,
|
||||
"MINOR":8,
|
||||
"PATCH":0
|
||||
"KSP_VERSION_MIN": {
|
||||
"MAJOR": 1,
|
||||
"MINOR": 8
|
||||
},
|
||||
"KSP_VERSION_MAX":{
|
||||
"MAJOR":1,
|
||||
"MINOR":9,
|
||||
"PATCH":99
|
||||
"KSP_VERSION_MAX": {
|
||||
"MAJOR": 1,
|
||||
"MINOR": 12
|
||||
}
|
||||
}
|
15
README.md
@ -1,5 +1,5 @@
|
||||
# Conformal Decals v0.1.3
|
||||
[](https://travis-ci.org/drewcassidy/KSP-Conformal-Decals) [](https://creativecommons.org/licenses/by-sa/4.0/) [](https://www.gnu.org/licenses/gpl-3.0)
|
||||
# Conformal Decals
|
||||
[](https://creativecommons.org/licenses/by-sa/4.0/) [](https://www.gnu.org/licenses/gpl-3.0) [](https://github.com/KSP-CKAN/CKAN)
|
||||
|
||||

|
||||
|
||||
@ -8,10 +8,11 @@ Conformal Decals adds a set of decal stickers to KSP, as well as providing a fra
|
||||
## Dependencies
|
||||
|
||||
Required:
|
||||
- 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.
|
||||
- KSP (1.8.x to 1.12.x)
|
||||
- B9 Part Switch (2.18.0). Bundled with release.
|
||||
- ModuleManager (4.1.4). Bundled with release.
|
||||
- Shabby (0.2.0 unofficial build). Bundled with release.
|
||||
- HarmonyKSP (2.0.4.0). Bundled with release.
|
||||
|
||||
Optional:
|
||||
- Wild Blue Tools. For custom decals category in the VAB and SPH.
|
||||
@ -20,6 +21,8 @@ Optional:
|
||||
|
||||
- Art and Plugin code: Andrew Cassidy (Cineboxandrew)
|
||||
- Semiotic decal pack based on the work of Ron Cobb
|
||||
- Munar decal pack based on the work of Gavin Rothery
|
||||
- Header image by Zorg, featuring parts from Bluedog Design Bureau
|
||||
|
||||
## Installation
|
||||
|
||||
|
61
Scripts/version.py
Normal file
@ -0,0 +1,61 @@
|
||||
import yaclog
|
||||
import yaclog.version
|
||||
import git as gp
|
||||
import os
|
||||
import xml.dom.minidom as minidom
|
||||
import json
|
||||
|
||||
|
||||
def run():
|
||||
repo = gp.Repo(os.curdir)
|
||||
cl = yaclog.Changelog('CHANGELOG.md')
|
||||
version = str(cl.current_version(released=True).version)
|
||||
release = False
|
||||
|
||||
for tag in repo.tags:
|
||||
if tag.commit == repo.head.commit:
|
||||
release = True
|
||||
build = 100000
|
||||
break
|
||||
|
||||
if not release:
|
||||
build = int.from_bytes(repo.head.commit.binsha[0:2], byteorder='big')
|
||||
version = yaclog.version.increment_version(version, 2)
|
||||
|
||||
print(f'Setting up version {version} build {build}')
|
||||
|
||||
version_path = 'GameData/ConformalDecals/Versioning/ConformalDecals.version'
|
||||
with open(version_path, 'r+') as version_file:
|
||||
print('Updating version file')
|
||||
segments = version.split('.')
|
||||
# print(version_file.read())
|
||||
decoded = json.load(version_file)
|
||||
decoded['VERSION']['MAJOR'] = int(segments[0])
|
||||
decoded['VERSION']['MINOR'] = int(segments[1])
|
||||
decoded['VERSION']['PATCH'] = int(segments[2])
|
||||
decoded['VERSION']['BUILD'] = build
|
||||
|
||||
version_file.seek(0)
|
||||
json.dump(decoded, version_file, indent=4)
|
||||
version_file.truncate()
|
||||
|
||||
project_path = 'Source/ConformalDecals/ConformalDecals.csproj'
|
||||
with open(project_path, 'r+') as project_file:
|
||||
print('Updating csproj file')
|
||||
segments = version.split('.')
|
||||
decoded = minidom.parse(project_file)
|
||||
version_node = decoded.getElementsByTagName('AssemblyVersion')[0]
|
||||
if release:
|
||||
version_node.firstChild.nodeValue = f'{version}'
|
||||
else:
|
||||
version_node.firstChild.nodeValue = f'{version}.{build}'
|
||||
# version_node.value = f'{version}.{build}'
|
||||
project_file.seek(0)
|
||||
decoded.writexml(project_file)
|
||||
project_file.truncate()
|
||||
|
||||
print('Done!')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run()
|
@ -1,6 +1,6 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConformalDecals", "ConformalDecals/ConformalDecals.csproj", "{1ea983f9-42e5-494e-9683-fdac9c9121f4}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConformalDecals", "ConformalDecals/ConformalDecals.csproj", "{1EA983F9-42E5-494E-9683-FDAC9C9121F4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -8,9 +8,9 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1ea983f9-42e5-494e-9683-fdac9c9121f4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1ea983f9-42e5-494e-9683-fdac9c9121f4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1ea983f9-42e5-494e-9683-fdac9c9121f4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1ea983f9-42e5-494e-9683-fdac9c9121f4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1EA983F9-42E5-494E-9683-FDAC9C9121F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1EA983F9-42E5-494E-9683-FDAC9C9121F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1EA983F9-42E5-494E-9683-FDAC9C9121F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1EA983F9-42E5-494E-9683-FDAC9C9121F4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
@ -1,75 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<?xml version="1.0" ?><Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{1ea983f9-42e5-494e-9683-fdac9c9121f4}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
<LangVersion>8</LangVersion>
|
||||
<RootNamespace>ConformalDecals</RootNamespace>
|
||||
<IsPackable>false</IsPackable>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<NoWarn>1701;1702;CS0649;CS1591</NoWarn>
|
||||
<AssemblyVersion>9.9.9</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Release\ConformalDecals.xml</DocumentationFile>
|
||||
<NoWarn>CS1591</NoWarn>
|
||||
<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>
|
||||
<HintPath>dlls\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Shabby, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls/Shabby.dll</HintPath>
|
||||
<HintPath>dlls\Shabby.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls\UnityEngine.dll</HintPath>
|
||||
<HintPath>dlls\UnityEngine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.AssetBundleModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls\UnityEngine.AssetBundleModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls\UnityEngine.CoreModule.dll</HintPath>
|
||||
<HintPath>dlls\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls\UnityEngine.PhysicsModule.dll</HintPath>
|
||||
<HintPath>dlls\UnityEngine.PhysicsModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls\UnityEngine.UI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UIModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>dlls\UnityEngine.UIModule.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="DecalConfig.cs" />
|
||||
<Compile Include="DecalIconFixer.cs" />
|
||||
<Compile Include="DecalPropertyIDs.cs" />
|
||||
<Compile Include="MaterialProperties\MaterialColorProperty.cs" />
|
||||
<Compile Include="MaterialProperties\MaterialFloatProperty.cs" />
|
||||
<Compile Include="MaterialProperties\MaterialProperty.cs" />
|
||||
<Compile Include="MaterialProperties\MaterialPropertyCollection.cs" />
|
||||
<Compile Include="MaterialProperties\MaterialTextureProperty.cs" />
|
||||
<Compile Include="ModuleConformalFlag.cs" />
|
||||
<Compile Include="ProjectionTarget.cs" />
|
||||
<Compile Include="ModuleConformalDecal.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Test\TestLayers.cs" />
|
||||
<Compile Include="Util\Logging.cs" />
|
||||
<Compile Include="Util\OrientedBounds.cs" />
|
||||
<Compile Include="Util\ParseUtil.cs" />
|
||||
<Compile Remove="dlls\**"/>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>sh -e -c "cp -v '$(TargetPath)' '$(SolutionDir)/../GameData/ConformalDecals/Plugins'"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Remove="dlls\**"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="dlls\**"/>
|
||||
</ItemGroup>
|
||||
|
||||
<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>
|
||||
|
||||
</Project>
|
@ -1,13 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using ConformalDecals.Text;
|
||||
using ConformalDecals.Util;
|
||||
using TMPro;
|
||||
using UniLinq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals {
|
||||
public static class DecalConfig {
|
||||
private static Texture2D _blankNormal;
|
||||
private static List<string> _shaderBlacklist;
|
||||
private static int _decalLayer = 31;
|
||||
private static bool _selectableInFlight = false;
|
||||
private static Texture2D _blankNormal;
|
||||
private static List<string> _shaderBlacklist;
|
||||
private static List<Regex> _shaderRegexBlacklist;
|
||||
private static Dictionary<string, DecalFont> _fontList;
|
||||
private static int _decalLayer = 31;
|
||||
private static bool _selectableInFlight;
|
||||
private static Dictionary<string, float> _aspectRatios;
|
||||
|
||||
private struct LegacyShaderEntry {
|
||||
public string name;
|
||||
public string[] keywords;
|
||||
}
|
||||
|
||||
private static readonly Dictionary<string, LegacyShaderEntry> LegacyShaderPairs = new Dictionary<string, LegacyShaderEntry>() {
|
||||
["ConformalDecals/Feature/Bumped"] = new LegacyShaderEntry() {
|
||||
name = "ConformalDecals/Decal/Standard",
|
||||
keywords = new[] {"DECAL_BUMPMAP"}
|
||||
},
|
||||
["ConformalDecals/Paint/Diffuse"] = new LegacyShaderEntry() {
|
||||
name = "ConformalDecals/Decal/Standard",
|
||||
keywords = new string[] { }
|
||||
},
|
||||
["ConformalDecals/Paint/Specular"] = new LegacyShaderEntry() {
|
||||
name = "ConformalDecals/Decal/Standard",
|
||||
keywords = new[] {"DECAL_SPECMAP"}
|
||||
},
|
||||
["ConformalDecals/Paint/DiffuseSDF"] = new LegacyShaderEntry() {
|
||||
name = "ConformalDecals/Decal/Standard",
|
||||
keywords = new[] {"DECAL_SDF_ALPHA"}
|
||||
},
|
||||
["ConformalDecals/Paint/SpecularSDF"] = new LegacyShaderEntry() {
|
||||
name = "ConformalDecals/Decal/Standard",
|
||||
keywords = new[] {"DECAL_SDF_ALPHA", "DECAL_SPECMAP"}
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
public static Texture2D BlankNormal => _blankNormal;
|
||||
|
||||
@ -15,27 +52,87 @@ namespace ConformalDecals {
|
||||
|
||||
public static bool SelectableInFlight => _selectableInFlight;
|
||||
|
||||
public static IEnumerable<DecalFont> Fonts => _fontList.Values;
|
||||
|
||||
public static Dictionary<string, float> AspectRatios => _aspectRatios;
|
||||
|
||||
public static bool IsBlacklisted(Shader shader) {
|
||||
return IsBlacklisted(shader.name);
|
||||
}
|
||||
|
||||
public static bool IsBlacklisted(string shaderName) {
|
||||
return _shaderBlacklist.Contains(shaderName);
|
||||
if (_shaderBlacklist.Contains(shaderName)) return true;
|
||||
|
||||
foreach (var regex in _shaderRegexBlacklist) {
|
||||
if (regex.IsMatch(shaderName)) {
|
||||
_shaderBlacklist.Add(shaderName);
|
||||
Logging.Log($"Caching blacklisted shader name '{shaderName}' which matches '{regex}'");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsLegacy(string shaderName, out string newShader, out string[] keywords) {
|
||||
if (LegacyShaderPairs.TryGetValue(shaderName, out var entry)) {
|
||||
newShader = entry.name;
|
||||
keywords = entry.keywords;
|
||||
return true;
|
||||
}
|
||||
|
||||
newShader = null;
|
||||
keywords = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static DecalFont GetFont(string name) {
|
||||
if (_fontList.TryGetValue(name, out var font)) {
|
||||
return font;
|
||||
} else {
|
||||
throw new KeyNotFoundException($"Font {name} not found");
|
||||
}
|
||||
}
|
||||
|
||||
private static void ParseConfig(ConfigNode node) {
|
||||
|
||||
ParseUtil.ParseIntIndirect(ref _decalLayer, node, "decalLayer");
|
||||
ParseUtil.ParseBoolIndirect(ref _selectableInFlight, node, "selectableInFlight");
|
||||
|
||||
foreach (var blacklist in node.GetNodes("SHADERBLACKLIST")) {
|
||||
foreach (var shaderName in blacklist.GetValuesList("shader")) {
|
||||
_shaderBlacklist.Add(shaderName);
|
||||
}
|
||||
|
||||
ParseUtil.ParseIntIndirect(ref _decalLayer, node, "decalLayer");
|
||||
ParseUtil.ParseBoolIndirect(ref _selectableInFlight, node, "selectableInFlight");
|
||||
foreach (var shaderRegex in blacklist.GetValuesList("shaderRegex")) {
|
||||
_shaderRegexBlacklist.Add(new Regex(shaderRegex));
|
||||
}
|
||||
}
|
||||
|
||||
var allFonts = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
|
||||
|
||||
foreach (var fontNode in node.GetNodes("FONT")) {
|
||||
try {
|
||||
var font = new DecalFont(fontNode, allFonts);
|
||||
_fontList.Add(font.Name, font);
|
||||
} catch (Exception e) {
|
||||
Debug.LogException(e);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var ratioNode in node.GetNodes("ASPECTRATIO")) {
|
||||
try {
|
||||
var path = ParseUtil.ParseString(ratioNode, "path");
|
||||
var ratio = ParseUtil.ParseFloat(ratioNode, "aspectRatio");
|
||||
_aspectRatios[path] = ratio;
|
||||
} catch (Exception e) {
|
||||
Debug.LogException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Texture2D MakeBlankNormal() {
|
||||
Debug.Log("ConformalDecals: Generating neutral normal map texture");
|
||||
Logging.Log("Generating neutral normal map texture");
|
||||
var width = 2;
|
||||
var height = 2;
|
||||
var color = new Color32(255, 128, 128, 128);
|
||||
@ -56,12 +153,15 @@ namespace ConformalDecals {
|
||||
// ReSharper disable once UnusedMember.Global
|
||||
public static void ModuleManagerPostLoad() {
|
||||
_shaderBlacklist = new List<string>();
|
||||
_shaderRegexBlacklist = new List<Regex>();
|
||||
_fontList = new Dictionary<string, DecalFont>();
|
||||
_aspectRatios = new Dictionary<string, float>();
|
||||
|
||||
var configs = GameDatabase.Instance.GetConfigs("CONFORMALDECALS");
|
||||
|
||||
if (configs.Length > 0) {
|
||||
Debug.Log("ConformalDecals: loading config");
|
||||
foreach (var config in configs) {
|
||||
Logging.Log($"loading config node '{config.url}'");
|
||||
ParseConfig(config.config);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using ConformalDecals.Util;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ConformalDecals {
|
||||
@ -12,11 +13,11 @@ namespace ConformalDecals {
|
||||
|
||||
public void Start() {
|
||||
foreach (var partName in PartNames) {
|
||||
Debug.Log($"Unf*&king decal preview on {partName}");
|
||||
Logging.Log($"Unf*&king decal preview on '{partName}'");
|
||||
var partInfo = PartLoader.getPartInfoByName(partName);
|
||||
|
||||
if (partInfo == null) {
|
||||
Debug.Log($"Part {partName} not found!");
|
||||
Logging.LogError($"Part {partName} not found!");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -28,12 +29,12 @@ namespace ConformalDecals {
|
||||
var backTransform = Part.FindHeirarchyTransform(icon.transform, decalModule.decalBack);
|
||||
|
||||
if (frontTransform == null) {
|
||||
Debug.Log($"Part {partName} has no frontTransform");
|
||||
Logging.Log($"Part '{partName}' has no frontTransform");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (backTransform == null) {
|
||||
Debug.Log($"Part {partName} has no backTransform");
|
||||
Logging.Log($"Part '{partName}' has no backTransform");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace ConformalDecals {
|
||||
@ -12,5 +13,6 @@ namespace ConformalDecals {
|
||||
public static readonly int _DecalTangent = Shader.PropertyToID("_DecalTangent");
|
||||
public static readonly int _EdgeWearStrength = Shader.PropertyToID("_EdgeWearStrength");
|
||||
public static readonly int _ProjectionMatrix = Shader.PropertyToID("_ProjectionMatrix");
|
||||
public static readonly int _ZWrite = Shader.PropertyToID("_ZWrite");
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -14,13 +14,14 @@ namespace ConformalDecals.MaterialProperties {
|
||||
[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");
|
||||
Debug.Log($"Parsing material property {_propertyName}");
|
||||
}
|
||||
|
||||
public abstract void Modify(Material material);
|
||||
public virtual void Remove(Material material) { }
|
||||
}
|
||||
}
|
@ -30,13 +30,22 @@ namespace ConformalDecals.MaterialProperties {
|
||||
|
||||
public Shader DecalShader => _shader;
|
||||
|
||||
public IEnumerable<Material> Materials {
|
||||
get {
|
||||
yield return PreviewMaterial;
|
||||
yield return DecalMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
public Material DecalMaterial {
|
||||
get {
|
||||
if (_decalMaterial == null) {
|
||||
_decalMaterial = new Material(_shader);
|
||||
|
||||
_decalMaterial.SetInt(DecalPropertyIDs._Cull, (int) CullMode.Off);
|
||||
_decalMaterial.SetInt(DecalPropertyIDs._ZWrite, 0);
|
||||
_decalMaterial.renderQueue = RenderQueue;
|
||||
_decalMaterial.SetShaderPassEnabled("SHADOWCASTER", false);
|
||||
}
|
||||
|
||||
return _decalMaterial;
|
||||
@ -50,6 +59,8 @@ 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;
|
||||
@ -66,10 +77,14 @@ namespace ConformalDecals.MaterialProperties {
|
||||
}
|
||||
}
|
||||
|
||||
public float AspectRatio => MainTexture == null ? 1 : MainTexture.AspectRatio;
|
||||
public float AspectRatio {
|
||||
get => MainTexture == null ? 1 : MainTexture.AspectRatio;
|
||||
set {
|
||||
if (MainTexture != null) MainTexture.AspectRatio = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnBeforeSerialize() {
|
||||
Debug.Log($"Serializing MaterialPropertyCollection {this.GetInstanceID()}");
|
||||
if (_materialProperties == null) throw new SerializationException("Tried to serialize an uninitialized MaterialPropertyCollection");
|
||||
|
||||
_serializedNames = _materialProperties.Keys.ToArray();
|
||||
@ -77,7 +92,6 @@ namespace ConformalDecals.MaterialProperties {
|
||||
}
|
||||
|
||||
public void OnAfterDeserialize() {
|
||||
Debug.Log($"Deserializing MaterialPropertyCollection {this.GetInstanceID()}");
|
||||
if (_serializedNames == null) throw new SerializationException("ID array is null");
|
||||
if (_serializedProperties == null) throw new SerializationException("Property array is null");
|
||||
if (_serializedProperties.Length != _serializedNames.Length) throw new SerializationException("Material property arrays are different lengths.");
|
||||
@ -95,7 +109,6 @@ namespace ConformalDecals.MaterialProperties {
|
||||
}
|
||||
|
||||
public void Awake() {
|
||||
Debug.Log($"MaterialPropertyCollection {this.GetInstanceID()} onAwake");
|
||||
_materialProperties ??= new Dictionary<string, MaterialProperty>();
|
||||
}
|
||||
|
||||
@ -130,8 +143,7 @@ namespace ConformalDecals.MaterialProperties {
|
||||
public T GetProperty<T>(string propertyName) where T : MaterialProperty {
|
||||
if (_materialProperties.ContainsKey(propertyName) && _materialProperties[propertyName] is T property) {
|
||||
return property;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -139,12 +151,26 @@ namespace ConformalDecals.MaterialProperties {
|
||||
public T AddOrGetProperty<T>(string propertyName) where T : MaterialProperty {
|
||||
if (_materialProperties.ContainsKey(propertyName) && _materialProperties[propertyName] is T property) {
|
||||
return property;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return AddProperty<T>(propertyName);
|
||||
}
|
||||
}
|
||||
|
||||
public bool RemoveProperty(string propertyName) {
|
||||
if (_materialProperties.TryGetValue(propertyName, out var property)) {
|
||||
foreach (var material in Materials) {
|
||||
property.Remove(material);
|
||||
}
|
||||
|
||||
_materialProperties.Remove(propertyName);
|
||||
Destroy(property);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public MaterialTextureProperty AddTextureProperty(string propertyName, bool isMain = false) {
|
||||
var newProperty = AddProperty<MaterialTextureProperty>(propertyName);
|
||||
if (isMain) _mainTexture = newProperty;
|
||||
@ -167,6 +193,8 @@ namespace ConformalDecals.MaterialProperties {
|
||||
string propertyName = "";
|
||||
if (!ParseUtil.ParseStringIndirect(ref propertyName, node, "name")) throw new ArgumentException("node has no name");
|
||||
|
||||
if (ParseUtil.ParseBool(node, "remove", true)) RemoveProperty(propertyName);
|
||||
|
||||
var newProperty = AddOrGetProperty<T>(propertyName);
|
||||
newProperty.ParseNode(node);
|
||||
|
||||
@ -180,14 +208,22 @@ namespace ConformalDecals.MaterialProperties {
|
||||
public void SetShader(string shaderName) {
|
||||
if (string.IsNullOrEmpty(shaderName)) {
|
||||
if (_shader == null) {
|
||||
Debug.Log("Using default decal shader");
|
||||
shaderName = "ConformalDecals/Paint/Diffuse";
|
||||
}
|
||||
else {
|
||||
Logging.Log("Using default decal shader");
|
||||
shaderName = "ConformalDecals/Decal/Standard";
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (DecalConfig.IsLegacy(shaderName, out var newShader, out var keywords)) {
|
||||
Logging.LogWarning($"Part is using shader {shaderName}, which has been replaced by {newShader}.");
|
||||
shaderName = newShader;
|
||||
foreach (var keyword in keywords) {
|
||||
var newProperty = AddOrGetProperty<MaterialKeywordProperty>(keyword);
|
||||
newProperty.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
var shader = Shabby.Shabby.FindShader(shaderName);
|
||||
|
||||
if (shader == null) throw new FormatException($"Unable to find specified shader '{shaderName}'");
|
||||
@ -209,8 +245,6 @@ namespace ConformalDecals.MaterialProperties {
|
||||
if (_mainTexture == null) throw new InvalidOperationException("UpdateTile called but no main texture is specified!");
|
||||
var mainTexSize = _mainTexture.Dimensions;
|
||||
|
||||
Debug.Log($"Main texture is {_mainTexture.PropertyName} and its size is {mainTexSize}");
|
||||
|
||||
foreach (var entry in _materialProperties) {
|
||||
if (entry.Value is MaterialTextureProperty textureProperty && textureProperty.autoTile) {
|
||||
textureProperty.SetTile(tile, mainTexSize);
|
||||
@ -244,8 +278,9 @@ namespace ConformalDecals.MaterialProperties {
|
||||
}
|
||||
|
||||
public void UpdateMaterials() {
|
||||
UpdateMaterial(DecalMaterial);
|
||||
UpdateMaterial(PreviewMaterial);
|
||||
foreach (var material in Materials) {
|
||||
UpdateMaterial(material);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateMaterial(Material material) {
|
||||
|
@ -10,7 +10,7 @@ namespace ConformalDecals.MaterialProperties {
|
||||
[SerializeField] public bool autoTile;
|
||||
|
||||
[SerializeField] private string _textureUrl;
|
||||
[SerializeField] private Texture2D _texture = Texture2D.whiteTexture;
|
||||
[SerializeField] private Texture2D _texture;
|
||||
|
||||
[SerializeField] private bool _hasTile;
|
||||
[SerializeField] private Rect _tileRect;
|
||||
@ -19,7 +19,12 @@ namespace ConformalDecals.MaterialProperties {
|
||||
[SerializeField] private Vector2 _textureOffset;
|
||||
[SerializeField] private Vector2 _textureScale = Vector2.one;
|
||||
|
||||
public Texture2D Texture => _texture;
|
||||
[SerializeField] private float _aspectRatioOverride = -1.0f;
|
||||
|
||||
public Texture2D Texture {
|
||||
get => _texture;
|
||||
set => _texture = value;
|
||||
}
|
||||
|
||||
public string TextureUrl {
|
||||
get => _textureUrl;
|
||||
@ -38,7 +43,15 @@ namespace ConformalDecals.MaterialProperties {
|
||||
public Vector2 Dimensions => new Vector2(_texture.width, _texture.height);
|
||||
public Vector2 MaskedDimensions => _hasTile ? _tileRect.size : Dimensions;
|
||||
|
||||
public float AspectRatio => MaskedHeight / (float) MaskedWidth;
|
||||
public float AspectRatio {
|
||||
get {
|
||||
if (_aspectRatioOverride > 0) return _aspectRatioOverride;
|
||||
if (_texture == null) return 1;
|
||||
return MaskedHeight / (float) MaskedWidth;
|
||||
}
|
||||
|
||||
set => _aspectRatioOverride = value;
|
||||
}
|
||||
|
||||
public override void ParseNode(ConfigNode node) {
|
||||
base.ParseNode(node);
|
||||
@ -55,18 +68,29 @@ namespace ConformalDecals.MaterialProperties {
|
||||
if (ParseUtil.ParseStringIndirect(ref _textureUrl, node, "textureUrl")) {
|
||||
_texture = LoadTexture(_textureUrl, isNormal);
|
||||
}
|
||||
|
||||
if (_texture == null) {
|
||||
_texture = isNormal ? DecalConfig.BlankNormal : Texture2D.whiteTexture;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Modify(Material material) {
|
||||
if (material == null) throw new ArgumentNullException(nameof(material));
|
||||
if (_texture == null) {
|
||||
_texture = Texture2D.whiteTexture;
|
||||
throw new NullReferenceException("texture is null, but should not be");
|
||||
_texture = isNormal ? DecalConfig.BlankNormal : Texture2D.whiteTexture;
|
||||
}
|
||||
|
||||
material.SetTexture(_propertyID, _texture);
|
||||
material.SetTextureOffset(_propertyID, _textureOffset);
|
||||
material.SetTextureScale(_propertyID, _textureScale * _scale);
|
||||
if (_propertyName != "_Decal") material.EnableKeyword("DECAL" + _propertyName.ToUpper());
|
||||
}
|
||||
|
||||
public override void Remove(Material material) {
|
||||
if (material == null) throw new ArgumentNullException(nameof(material));
|
||||
base.Remove(material);
|
||||
|
||||
if (_propertyName != "_Decal") material.DisableKeyword("DECAL" + _propertyName.ToUpper());
|
||||
}
|
||||
|
||||
public void SetScale(Vector2 scale) {
|
||||
@ -94,7 +118,7 @@ namespace ConformalDecals.MaterialProperties {
|
||||
}
|
||||
|
||||
private static Texture2D LoadTexture(string textureUrl, bool isNormal) {
|
||||
Debug.Log($"loading texture '{textureUrl}', isNormalMap = {isNormal}");
|
||||
//Logging.Log($"loading texture '{textureUrl}', isNormalMap = {isNormal}");
|
||||
if ((string.IsNullOrEmpty(textureUrl) && isNormal) || textureUrl == "Bump") {
|
||||
return Texture2D.normalTexture;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace ConformalDecals {
|
||||
|
||||
// CONFIGURABLE VALUES
|
||||
|
||||
[KSPField] public string shader = "ConformalDecals/Paint/Diffuse";
|
||||
[KSPField] public string shader = "ConformalDecals/Decal/Standard";
|
||||
|
||||
[KSPField] public string decalFront = "Decal-Front";
|
||||
[KSPField] public string decalBack = "Decal-Back";
|
||||
@ -31,10 +31,12 @@ namespace ConformalDecals {
|
||||
|
||||
[KSPField] public bool scaleAdjustable = true;
|
||||
[KSPField] public float defaultScale = 1;
|
||||
[KSPField] public Vector2 scaleRange = new Vector2(0, 4);
|
||||
[KSPField] public Vector2 scaleRange = new Vector2(0, 5);
|
||||
|
||||
[KSPField] public DecalScaleMode scaleMode = DecalScaleMode.HEIGHT;
|
||||
|
||||
[KSPField] public float aspectRatio = -1.0f; // < 0 = use texture
|
||||
|
||||
[KSPField] public bool depthAdjustable = true;
|
||||
[KSPField] public float defaultDepth = 0.1f;
|
||||
[KSPField] public Vector2 depthRange = new Vector2(0, 2);
|
||||
@ -60,19 +62,19 @@ namespace ConformalDecals {
|
||||
|
||||
// INTERNAL VALUES
|
||||
[KSPField(guiName = "#LOC_ConformalDecals_gui-scale", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F2", guiUnits = "m"),
|
||||
UI_FloatRange(stepIncrement = 0.05f)]
|
||||
UI_FloatRange()]
|
||||
public float scale = 1.0f;
|
||||
|
||||
[KSPField(guiName = "#LOC_ConformalDecals_gui-depth", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F2", guiUnits = "m"),
|
||||
UI_FloatRange(stepIncrement = 0.02f)]
|
||||
UI_FloatRange()]
|
||||
public float depth = 0.2f;
|
||||
|
||||
[KSPField(guiName = "#LOC_ConformalDecals_gui-opacity", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "P0"),
|
||||
UI_FloatRange(stepIncrement = 0.05f)]
|
||||
UI_FloatRange()]
|
||||
public float opacity = 1.0f;
|
||||
|
||||
[KSPField(guiName = "#LOC_ConformalDecals_gui-cutoff", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "P0"),
|
||||
UI_FloatRange(stepIncrement = 0.05f)]
|
||||
UI_FloatRange()]
|
||||
public float cutoff = 0.5f;
|
||||
|
||||
[KSPField(guiName = "#LOC_ConformalDecals_gui-wear", guiActive = false, guiActiveEditor = true, isPersistant = true, guiFormat = "F0"),
|
||||
@ -122,15 +124,13 @@ namespace ConformalDecals {
|
||||
|
||||
if (materialProperties == null) {
|
||||
materialProperties = ScriptableObject.CreateInstance<MaterialPropertyCollection>();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
materialProperties = ScriptableObject.Instantiate(materialProperties);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLoad(ConfigNode node) {
|
||||
this.Log("Loading module");
|
||||
try {
|
||||
// SETUP TRANSFORMS
|
||||
decalFrontTransform = part.FindModelTransform(decalFront);
|
||||
@ -150,19 +150,16 @@ namespace ConformalDecals {
|
||||
|
||||
// SETUP BACK MATERIAL
|
||||
if (updateBackScale) {
|
||||
this.Log("Getting material and base scale for back material");
|
||||
var backRenderer = decalBackTransform.GetComponent<MeshRenderer>();
|
||||
if (backRenderer == null) {
|
||||
this.LogError($"Specified decalBack transform {decalBack} has no renderer attached! Setting updateBackScale to false.");
|
||||
updateBackScale = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
backMaterial = backRenderer.material;
|
||||
if (backMaterial == null) {
|
||||
this.LogError($"Specified decalBack transform {decalBack} has a renderer but no material! Setting updateBackScale to false.");
|
||||
updateBackScale = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (backTextureBaseScale == default) backTextureBaseScale = backMaterial.GetTextureScale(PropertyIDs._MainTex);
|
||||
}
|
||||
}
|
||||
@ -172,6 +169,12 @@ namespace ConformalDecals {
|
||||
|
||||
// set shader
|
||||
materialProperties.SetShader(shader);
|
||||
materialProperties.AddOrGetProperty<MaterialKeywordProperty>("DECAL_BASE_NORMAL").value = useBaseNormal;
|
||||
|
||||
// add keyword nodes
|
||||
foreach (var keywordNode in node.GetNodes("KEYWORD")) {
|
||||
materialProperties.ParseProperty<MaterialKeywordProperty>(keywordNode);
|
||||
}
|
||||
|
||||
// add texture nodes
|
||||
foreach (var textureNode in node.GetNodes("TEXTURE")) {
|
||||
@ -190,7 +193,6 @@ namespace ConformalDecals {
|
||||
|
||||
// handle texture tiling parameters
|
||||
var tileString = node.GetValue("tile");
|
||||
this.Log(tileString);
|
||||
if (!string.IsNullOrEmpty(tileString)) {
|
||||
var tileValid = ParseExtensions.TryParseRect(tileString, out tileRect);
|
||||
if (!tileValid) throw new FormatException($"Invalid rect value for tile '{tileString}'");
|
||||
@ -198,33 +200,38 @@ namespace ConformalDecals {
|
||||
|
||||
if (tileRect.x >= 0) {
|
||||
materialProperties.UpdateTile(tileRect);
|
||||
}
|
||||
else if (tileIndex >= 0) {
|
||||
} else if (tileIndex >= 0) {
|
||||
materialProperties.UpdateTile(tileIndex, tileSize);
|
||||
}
|
||||
|
||||
// QUEUE PART FOR ICON FIXING IN VAB
|
||||
DecalIconFixer.QueuePart(part.name);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// handle aspect ratio overrides
|
||||
materialProperties.AspectRatio = aspectRatio;
|
||||
|
||||
} catch (Exception e) {
|
||||
this.LogException("Exception parsing partmodule", e);
|
||||
}
|
||||
|
||||
UpdateMaterials();
|
||||
|
||||
foreach (var keyword in _decalMaterial.shaderKeywords) {
|
||||
this.Log($"keyword: {keyword}");
|
||||
}
|
||||
|
||||
if (HighLogic.LoadedSceneIsEditor) {
|
||||
UpdateTweakables();
|
||||
}
|
||||
|
||||
if (HighLogic.LoadedSceneIsGame) {
|
||||
UpdateScale();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
scale = defaultScale;
|
||||
depth = defaultDepth;
|
||||
opacity = defaultOpacity;
|
||||
cutoff = defaultCutoff;
|
||||
wear = defaultWear;
|
||||
|
||||
// QUEUE PART FOR ICON FIXING IN VAB
|
||||
DecalIconFixer.QueuePart(part.name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,46 +242,44 @@ namespace ConformalDecals {
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnStart(StartState state) {
|
||||
this.Log("Starting module");
|
||||
|
||||
|
||||
|
||||
materialProperties.RenderQueue = DecalQueue;
|
||||
|
||||
_boundsRenderer = decalProjectorTransform.GetComponent<MeshRenderer>();
|
||||
|
||||
UpdateMaterials();
|
||||
|
||||
if (HighLogic.LoadedSceneIsGame) {
|
||||
// set initial attachment state
|
||||
if (part.parent == null) {
|
||||
OnDetach();
|
||||
}
|
||||
else {
|
||||
OnAttach();
|
||||
}
|
||||
}
|
||||
|
||||
// handle tweakables
|
||||
if (HighLogic.LoadedSceneIsEditor) {
|
||||
GameEvents.onEditorPartEvent.Add(OnEditorEvent);
|
||||
GameEvents.onVariantApplied.Add(OnVariantApplied);
|
||||
GameEvents.onEditorUndo.Add(OnEditorUndo);
|
||||
|
||||
UpdateTweakables();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void OnStartFinished(StartState state) {
|
||||
// handle game events
|
||||
if (HighLogic.LoadedSceneIsGame) {
|
||||
// set initial attachment state
|
||||
if (part.parent == null) {
|
||||
OnDetach();
|
||||
} else {
|
||||
OnAttach();
|
||||
}
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -283,6 +288,7 @@ namespace ConformalDecals {
|
||||
if (HighLogic.LoadedSceneIsEditor) {
|
||||
GameEvents.onEditorPartEvent.Remove(OnEditorEvent);
|
||||
GameEvents.onVariantApplied.Remove(OnVariantApplied);
|
||||
GameEvents.onEditorUndo.Remove(OnEditorUndo);
|
||||
}
|
||||
|
||||
if (HighLogic.LoadedSceneIsFlight) {
|
||||
@ -346,14 +352,18 @@ namespace ConformalDecals {
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnEditorUndo(ShipConstruct sc) {
|
||||
UpdateTargets();
|
||||
}
|
||||
|
||||
protected void OnPartWillDie(Part willDie) {
|
||||
if (willDie == part.parent) {
|
||||
this.Log("Parent part about to be destroyed! Killing decal part.");
|
||||
part.Die();
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnAttach() {
|
||||
|
||||
protected virtual void OnAttach() {
|
||||
if (part.parent == null) {
|
||||
this.LogError("Attach function called but part has no parent!");
|
||||
_isAttached = false;
|
||||
@ -362,8 +372,6 @@ namespace ConformalDecals {
|
||||
|
||||
_isAttached = true;
|
||||
|
||||
this.Log($"Decal attached to {part.parent.partName}");
|
||||
|
||||
// hide model
|
||||
decalModelTransform.gameObject.SetActive(false);
|
||||
|
||||
@ -378,7 +386,7 @@ namespace ConformalDecals {
|
||||
UpdateScale();
|
||||
}
|
||||
|
||||
protected void OnDetach() {
|
||||
protected virtual void OnDetach() {
|
||||
_isAttached = false;
|
||||
|
||||
// unhide model
|
||||
@ -397,30 +405,32 @@ namespace ConformalDecals {
|
||||
protected void UpdateScale() {
|
||||
scale = Mathf.Max(0.01f, scale);
|
||||
depth = Mathf.Max(0.01f, depth);
|
||||
var aspectRatio = materialProperties.AspectRatio;
|
||||
|
||||
var sizeRatio = Mathf.Max(0.01f, materialProperties.AspectRatio);
|
||||
|
||||
Vector2 size;
|
||||
|
||||
switch (scaleMode) {
|
||||
default:
|
||||
case DecalScaleMode.HEIGHT:
|
||||
size = new Vector2(scale, scale * aspectRatio);
|
||||
size = new Vector2(scale / sizeRatio, scale);
|
||||
break;
|
||||
case DecalScaleMode.WIDTH:
|
||||
size = new Vector2(scale / aspectRatio, scale);
|
||||
size = new Vector2(scale, scale * sizeRatio);
|
||||
break;
|
||||
case DecalScaleMode.AVERAGE:
|
||||
var width1 = 2 * scale / (1 + aspectRatio);
|
||||
size = new Vector2(width1, width1 * aspectRatio);
|
||||
var width1 = 2 * scale / (1 + sizeRatio);
|
||||
size = new Vector2(width1, width1 * sizeRatio);
|
||||
break;
|
||||
case DecalScaleMode.AREA:
|
||||
var width2 = Mathf.Sqrt(scale / aspectRatio);
|
||||
size = new Vector2(width2, width2 * aspectRatio);
|
||||
var width2 = Mathf.Sqrt(scale / sizeRatio);
|
||||
size = new Vector2(width2, width2 * sizeRatio);
|
||||
break;
|
||||
case DecalScaleMode.MINIMUM:
|
||||
if (aspectRatio > 1) goto case DecalScaleMode.WIDTH;
|
||||
if (sizeRatio > 1) goto case DecalScaleMode.WIDTH;
|
||||
else goto case DecalScaleMode.HEIGHT;
|
||||
case DecalScaleMode.MAXIMUM:
|
||||
if (aspectRatio > 1) goto case DecalScaleMode.HEIGHT;
|
||||
if (sizeRatio > 1) goto case DecalScaleMode.HEIGHT;
|
||||
else goto case DecalScaleMode.WIDTH;
|
||||
}
|
||||
|
||||
@ -437,10 +447,13 @@ namespace ConformalDecals {
|
||||
|
||||
// update projection
|
||||
foreach (var target in _targets) {
|
||||
target.Project(_orthoMatrix, decalProjectorTransform, _boundsRenderer.bounds, useBaseNormal);
|
||||
if (target.target == null) {
|
||||
_targets.Remove(target);
|
||||
} else {
|
||||
target.Project(_orthoMatrix, decalProjectorTransform, _boundsRenderer.bounds, useBaseNormal);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// rescale preview model
|
||||
decalModelTransform.localScale = new Vector3(size.x, size.y, (size.x + size.y) / 2);
|
||||
|
||||
@ -451,7 +464,7 @@ namespace ConformalDecals {
|
||||
}
|
||||
}
|
||||
|
||||
protected void UpdateMaterials() {
|
||||
protected virtual void UpdateMaterials() {
|
||||
materialProperties.UpdateMaterials();
|
||||
materialProperties.SetOpacity(opacity);
|
||||
materialProperties.SetCutoff(cutoff);
|
||||
@ -468,8 +481,7 @@ namespace ConformalDecals {
|
||||
protected void UpdateTargets() {
|
||||
if (_targets == null) {
|
||||
_targets = new List<ProjectionTarget>();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
_targets.Clear();
|
||||
}
|
||||
|
||||
@ -495,7 +507,7 @@ namespace ConformalDecals {
|
||||
}
|
||||
}
|
||||
|
||||
protected void UpdateTweakables() {
|
||||
protected virtual void UpdateTweakables() {
|
||||
// setup tweakable fields
|
||||
var scaleField = Fields[nameof(scale)];
|
||||
var depthField = Fields[nameof(depth)];
|
||||
@ -518,7 +530,7 @@ namespace ConformalDecals {
|
||||
var scaleEditor = (UI_FloatRange) scaleField.uiControlEditor;
|
||||
scaleEditor.minValue = minValue;
|
||||
scaleEditor.maxValue = maxValue;
|
||||
scaleEditor.stepIncrement = (maxValue - minValue) / steps;
|
||||
scaleEditor.stepIncrement = 0.01f; //1cm
|
||||
scaleEditor.onFieldChanged = OnSizeTweakEvent;
|
||||
}
|
||||
|
||||
@ -529,7 +541,7 @@ namespace ConformalDecals {
|
||||
var depthEditor = (UI_FloatRange) depthField.uiControlEditor;
|
||||
depthEditor.minValue = minValue;
|
||||
depthEditor.maxValue = maxValue;
|
||||
depthEditor.stepIncrement = (maxValue - minValue) / steps;
|
||||
depthEditor.stepIncrement = 0.01f; //1cm
|
||||
depthEditor.onFieldChanged = OnSizeTweakEvent;
|
||||
}
|
||||
|
||||
@ -571,10 +583,11 @@ namespace ConformalDecals {
|
||||
|
||||
public void Render(Camera camera) {
|
||||
if (!_isAttached) return;
|
||||
|
||||
|
||||
// render on each target object
|
||||
foreach (var target in _targets) {
|
||||
target.Render(_decalMaterial, part.mpb, camera);
|
||||
if (ReferenceEquals(target.target, null)) _targets.Remove(target);
|
||||
else target.Render(_decalMaterial, part.mpb, camera);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ namespace ConformalDecals {
|
||||
|
||||
[KSPField(isPersistant = true)] public bool useCustomFlag;
|
||||
|
||||
// The URL of the flag for the current mission or agency
|
||||
public string MissionFlagUrl {
|
||||
get {
|
||||
if (HighLogic.LoadedSceneIsEditor) {
|
||||
@ -19,6 +20,7 @@ namespace ConformalDecals {
|
||||
return string.IsNullOrEmpty(part.flagURL) ? HighLogic.CurrentGame.flagURL : part.flagURL;
|
||||
}
|
||||
|
||||
// If we are not in game, use the default flag (for icon rendering)
|
||||
return DefaultFlag;
|
||||
}
|
||||
}
|
||||
@ -26,84 +28,108 @@ namespace ConformalDecals {
|
||||
public override void OnLoad(ConfigNode node) {
|
||||
base.OnLoad(node);
|
||||
|
||||
if (useCustomFlag) {
|
||||
SetFlag(flagUrl);
|
||||
}
|
||||
else {
|
||||
SetFlag(MissionFlagUrl);
|
||||
}
|
||||
// Since OnLoad is called for all modules, we only need to update this module
|
||||
// Updating symmetry counterparts would be redundent
|
||||
UpdateFlag();
|
||||
}
|
||||
|
||||
public override void OnStart(StartState state) {
|
||||
base.OnStart(state);
|
||||
|
||||
if (HighLogic.LoadedSceneIsGame) {
|
||||
GameEvents.onMissionFlagSelect.Add(OnEditorFlagSelected);
|
||||
}
|
||||
|
||||
if (HighLogic.LoadedSceneIsEditor) {
|
||||
// Register flag change event
|
||||
GameEvents.onMissionFlagSelect.Add(OnEditorFlagSelected);
|
||||
|
||||
// Register reset button event
|
||||
Events[nameof(ResetFlag)].guiActiveEditor = useCustomFlag;
|
||||
}
|
||||
|
||||
if (useCustomFlag) {
|
||||
SetFlag(flagUrl);
|
||||
}
|
||||
else {
|
||||
SetFlag(MissionFlagUrl);
|
||||
}
|
||||
// Since OnStart is called for all modules, we only need to update this module
|
||||
// Updating symmetry counterparts would be redundent
|
||||
UpdateFlag();
|
||||
}
|
||||
|
||||
public override void OnDestroy() {
|
||||
GameEvents.onMissionFlagSelect.Remove(SetFlag);
|
||||
if (HighLogic.LoadedSceneIsEditor) {
|
||||
// Unregister flag change event
|
||||
GameEvents.onMissionFlagSelect.Remove(OnEditorFlagSelected);
|
||||
}
|
||||
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
[KSPEvent(guiActive = false, guiActiveEditor = true, guiName = "#LOC_ConformalDecals_gui-select-flag")]
|
||||
public void SelectFlag() {
|
||||
// Button for selecting a flag
|
||||
// This is a bit of a hack to bring up the stock flag selection menu
|
||||
// When its done, it calls OnCustomFlagSelected()
|
||||
|
||||
// ReSharper disable once PossibleNullReferenceException
|
||||
var flagBrowser = (Instantiate((Object) (new FlagBrowserGUIButton(null, null, null, null)).FlagBrowserPrefab) as GameObject).GetComponent<FlagBrowser>();
|
||||
flagBrowser.OnFlagSelected = OnCustomFlagSelected;
|
||||
}
|
||||
|
||||
[KSPEvent(guiActive = false, guiActiveEditor = true, guiName = "#LOC_ConformalDecals_gui-reset-flag")]
|
||||
public void ResetFlag() {
|
||||
SetFlag(MissionFlagUrl);
|
||||
SetFlagSymmetryCounterparts(MissionFlagUrl);
|
||||
|
||||
// we are no longer using a custom flag, so instead use the mission or agency flag
|
||||
useCustomFlag = false;
|
||||
flagUrl = "Mission";
|
||||
UpdateFlag(true);
|
||||
|
||||
// disable the reset button, since it no longer makes sense
|
||||
Events[nameof(ResetFlag)].guiActiveEditor = false;
|
||||
}
|
||||
|
||||
private void OnCustomFlagSelected(FlagBrowser.FlagEntry newFlagEntry) {
|
||||
SetFlag(newFlagEntry.textureInfo.name);
|
||||
SetFlagSymmetryCounterparts(newFlagEntry.textureInfo.name);
|
||||
// Callback for when a flag is selected in the menu spawned by SelectFlag()
|
||||
|
||||
// we are now using a custom flag with the URL of the new flag entry
|
||||
useCustomFlag = true;
|
||||
flagUrl = newFlagEntry.textureInfo.name;
|
||||
UpdateFlag(true);
|
||||
|
||||
// make sure the reset button is now available
|
||||
Events[nameof(ResetFlag)].guiActiveEditor = true;
|
||||
}
|
||||
|
||||
private void OnEditorFlagSelected(string newFlagUrl) {
|
||||
if (!useCustomFlag) {
|
||||
SetFlag(newFlagUrl);
|
||||
SetFlagSymmetryCounterparts(newFlagUrl);
|
||||
flagUrl = newFlagUrl;
|
||||
// Since this callback is called for all modules, we only need to update this module
|
||||
// Updating symmetry counterparts would be redundent
|
||||
UpdateFlag();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetFlag(string newFlagUrl) {
|
||||
this.Log($"Loading flag texture '{newFlagUrl}'.");
|
||||
// Update the displayed flag texture for this decal or optionally any symmetry counterparts
|
||||
private void UpdateFlag(bool recursive = false) {
|
||||
// get the decal material property for the decal texture
|
||||
var textureProperty = materialProperties.AddOrGetTextureProperty("_Decal", true);
|
||||
|
||||
flagUrl = newFlagUrl;
|
||||
materialProperties.AddOrGetTextureProperty("_Decal", true).TextureUrl = newFlagUrl;
|
||||
string textureURL = useCustomFlag ? flagUrl : MissionFlagUrl;
|
||||
textureProperty.TextureUrl = textureURL;
|
||||
|
||||
if (DecalConfig.AspectRatios.ContainsKey(textureURL)) {
|
||||
var ratio = DecalConfig.AspectRatios[textureURL];
|
||||
this.Log($"Overriding aspect ratio for {textureURL} with {ratio}");
|
||||
textureProperty.AspectRatio = ratio;
|
||||
} else {
|
||||
textureProperty.AspectRatio = -1.0f;
|
||||
}
|
||||
|
||||
UpdateMaterials();
|
||||
UpdateScale();
|
||||
}
|
||||
|
||||
private void SetFlagSymmetryCounterparts(string newFlagUrl) {
|
||||
foreach (var counterpart in part.symmetryCounterparts) {
|
||||
var decal = counterpart.GetComponent<ModuleConformalFlag>();
|
||||
if (recursive) {
|
||||
// for each symmetry counterpart, copy this part's properties and update it in turn
|
||||
foreach (var counterpart in part.symmetryCounterparts) {
|
||||
var decal = counterpart.GetComponent<ModuleConformalFlag>();
|
||||
|
||||
decal.SetFlag(newFlagUrl);
|
||||
decal.useCustomFlag = useCustomFlag;
|
||||
decal.useCustomFlag = useCustomFlag;
|
||||
decal.flagUrl = flagUrl;
|
||||
decal.UpdateFlag();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|