mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Add visible bounding boxes around projection area
This commit is contained in:
parent
a42084bf1c
commit
3c5fcedca4
@ -8,6 +8,7 @@ Shader "ConformalDecals/SelectionGlow"
|
|||||||
_RimEdgeOpacity("Rim Edge Opacity", Range(0,1)) = 0.2
|
_RimEdgeOpacity("Rim Edge Opacity", Range(0,1)) = 0.2
|
||||||
_RimFalloff("Rim Falloff", Range(0.01,5) ) = 0.1
|
_RimFalloff("Rim Falloff", Range(0.01,5) ) = 0.1
|
||||||
_RimColor("Rim Color", Color) = (0,0,0,0)
|
_RimColor("Rim Color", Color) = (0,0,0,0)
|
||||||
|
_RimOpacity("Rim Opacity", Range(0,1)) = 0.5
|
||||||
}
|
}
|
||||||
SubShader
|
SubShader
|
||||||
{
|
{
|
||||||
@ -27,6 +28,7 @@ Shader "ConformalDecals/SelectionGlow"
|
|||||||
half _RimEdgeOpacity;
|
half _RimEdgeOpacity;
|
||||||
float _RimFalloff;
|
float _RimFalloff;
|
||||||
float4 _RimColor;
|
float4 _RimColor;
|
||||||
|
half _RimOpacity;
|
||||||
|
|
||||||
#include "UnityCG.cginc"
|
#include "UnityCG.cginc"
|
||||||
#include "Lighting.cginc"
|
#include "Lighting.cginc"
|
||||||
@ -53,7 +55,7 @@ Shader "ConformalDecals/SelectionGlow"
|
|||||||
|
|
||||||
float3 worldViewDir = normalize(UnityWorldSpaceViewDir(i.worldPosition));
|
float3 worldViewDir = normalize(UnityWorldSpaceViewDir(i.worldPosition));
|
||||||
half rim = 1.0 - saturate(dot (normalize(worldViewDir), i.worldNormal));
|
half rim = 1.0 - saturate(dot (normalize(worldViewDir), i.worldNormal));
|
||||||
c.rgb = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
|
c.rgb = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a * _RimOpacity;
|
||||||
half edgeGlow = 0;
|
half edgeGlow = 0;
|
||||||
edgeGlow = max(edgeGlow, pow(1-saturate(i.uv.x / _RimEdgeGlow), _RimEdgePow));
|
edgeGlow = max(edgeGlow, pow(1-saturate(i.uv.x / _RimEdgeGlow), _RimEdgePow));
|
||||||
edgeGlow = max(edgeGlow, pow(1-saturate(i.uv.y / _RimEdgeGlow), _RimEdgePow));
|
edgeGlow = max(edgeGlow, pow(1-saturate(i.uv.y / _RimEdgeGlow), _RimEdgePow));
|
||||||
|
Binary file not shown.
@ -51,10 +51,6 @@ PART
|
|||||||
{
|
{
|
||||||
name = ModuleConformalDecal
|
name = ModuleConformalDecal
|
||||||
|
|
||||||
decalFront = Decal-Front
|
|
||||||
decalBack = Decal-Back
|
|
||||||
decalModel = Decal-Model
|
|
||||||
|
|
||||||
useBaseNormal = true
|
useBaseNormal = true
|
||||||
|
|
||||||
tile = 0, 2, 128, 112
|
tile = 0, 2, 128, 112
|
||||||
|
@ -51,10 +51,6 @@ PART
|
|||||||
{
|
{
|
||||||
name = ModuleConformalDecal
|
name = ModuleConformalDecal
|
||||||
|
|
||||||
decalFront = Decal-Front
|
|
||||||
decalBack = Decal-Back
|
|
||||||
decalModel = Decal-Model
|
|
||||||
|
|
||||||
useBaseNormal = true
|
useBaseNormal = true
|
||||||
|
|
||||||
tileSize = 64, 64
|
tileSize = 64, 64
|
||||||
|
@ -7,7 +7,6 @@ PART
|
|||||||
{
|
{
|
||||||
model = ConformalDecals/Assets/decal-blank
|
model = ConformalDecals/Assets/decal-blank
|
||||||
scale = 1.0, 1.0, 1.0
|
scale = 1.0, 1.0, 1.0
|
||||||
texture = blank, ConformalDecals/Flags/Peel-N-Stik
|
|
||||||
}
|
}
|
||||||
rescaleFactor = 1
|
rescaleFactor = 1
|
||||||
|
|
||||||
@ -52,10 +51,6 @@ PART
|
|||||||
{
|
{
|
||||||
name = ModuleConformalFlag
|
name = ModuleConformalFlag
|
||||||
|
|
||||||
decalFront = Decal-Front
|
|
||||||
decalBack = Decal-Back
|
|
||||||
decalModel = Decal-Model
|
|
||||||
|
|
||||||
useBaseNormal = true
|
useBaseNormal = true
|
||||||
|
|
||||||
defaultDepth = 0.2
|
defaultDepth = 0.2
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -25,12 +25,12 @@ namespace ConformalDecals {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Decal front transform name. Required
|
/// Decal front transform name. Required
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[KSPField] public string decalFront = string.Empty;
|
[KSPField] public string decalFront = "Decal-Front";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Decal back transform name. Required if <see cref="updateBackScale"/> is true.
|
/// Decal back transform name. Required if <see cref="updateBackScale"/> is true.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[KSPField] public string decalBack = string.Empty;
|
[KSPField] public string decalBack = "Decal-Back";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Decal model transform name. Is rescaled to preview the decal scale when unattached.
|
/// Decal model transform name. Is rescaled to preview the decal scale when unattached.
|
||||||
@ -38,7 +38,7 @@ namespace ConformalDecals {
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// If unspecified, the decal front transform is used instead.
|
/// If unspecified, the decal front transform is used instead.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[KSPField] public string decalModel = string.Empty;
|
[KSPField] public string decalModel = "Decal-Model";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Decal projector transform name. The decal will project along the +Z axis of this transform.
|
/// Decal projector transform name. The decal will project along the +Z axis of this transform.
|
||||||
@ -46,7 +46,7 @@ namespace ConformalDecals {
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// if unspecified, the part "model" transform will be used instead.
|
/// if unspecified, the part "model" transform will be used instead.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[KSPField] public string decalProjector = string.Empty;
|
[KSPField] public string decalProjector = "Decal-Projector";
|
||||||
|
|
||||||
// Parameters
|
// Parameters
|
||||||
|
|
||||||
@ -389,9 +389,11 @@ namespace ConformalDecals {
|
|||||||
|
|
||||||
this.Log($"Decal attached to {part.parent.partName}");
|
this.Log($"Decal attached to {part.parent.partName}");
|
||||||
|
|
||||||
// hide preview model
|
// hide model
|
||||||
decalFrontTransform.gameObject.SetActive(false);
|
decalModelTransform.gameObject.SetActive(false);
|
||||||
decalBackTransform.gameObject.SetActive(false);
|
|
||||||
|
// unhide projector
|
||||||
|
decalProjectorTransform.gameObject.SetActive(true);
|
||||||
|
|
||||||
// add to preCull delegate
|
// add to preCull delegate
|
||||||
Camera.onPreCull += Render;
|
Camera.onPreCull += Render;
|
||||||
@ -404,9 +406,11 @@ namespace ConformalDecals {
|
|||||||
protected void OnDetach() {
|
protected void OnDetach() {
|
||||||
_isAttached = false;
|
_isAttached = false;
|
||||||
|
|
||||||
// unhide preview model
|
// unhide model
|
||||||
decalFrontTransform.gameObject.SetActive(true);
|
decalModelTransform.gameObject.SetActive(true);
|
||||||
decalBackTransform.gameObject.SetActive(true);
|
|
||||||
|
// hide projector
|
||||||
|
decalProjectorTransform.gameObject.SetActive(false);
|
||||||
|
|
||||||
// remove from preCull delegate
|
// remove from preCull delegate
|
||||||
Camera.onPreCull -= Render;
|
Camera.onPreCull -= Render;
|
||||||
@ -452,9 +456,7 @@ namespace ConformalDecals {
|
|||||||
_orthoMatrix[0, 3] = 0.5f;
|
_orthoMatrix[0, 3] = 0.5f;
|
||||||
_orthoMatrix[1, 3] = 0.5f;
|
_orthoMatrix[1, 3] = 0.5f;
|
||||||
|
|
||||||
_orthoMatrix[0, 0] = 1 / size.x;
|
decalProjectorTransform.localScale = new Vector3(size.x, size.y, depth);
|
||||||
_orthoMatrix[1, 1] = 1 / size.y;
|
|
||||||
_orthoMatrix[2, 2] = 1 / depth;
|
|
||||||
|
|
||||||
// update projection
|
// update projection
|
||||||
foreach (var target in _targets) {
|
foreach (var target in _targets) {
|
||||||
|
Loading…
Reference in New Issue
Block a user