mirror of
https://github.com/DCFApixels/Unity-DebugX.git
synced 2026-04-21 20:35:54 +08:00
finish update render & materials
This commit is contained in:
parent
7f0c121e68
commit
e0de4101b0
@ -1,34 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Line
|
||||
m_Shader: {fileID: 4800000, guid: 37036939f3d0a824c82a3f34093d4a42, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 1
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs: []
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _FakeLight: 0
|
||||
- _OnePass: 0
|
||||
- _VertexColor: 0
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
m_AllowLocking: 1
|
||||
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fce881fda18d0a44fb62c8375d3e2fd4
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -26,7 +26,6 @@ Material:
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _FAKELIGHT_ON
|
||||
- _VERTEXCOLOR_ON
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 1
|
||||
@ -100,6 +99,7 @@ Material:
|
||||
- _AddPrecomputedVelocity: 0
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Billboard: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
@ -109,6 +109,7 @@ Material:
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _Dot: 0
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
@ -127,7 +128,7 @@ Material:
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _VertexColor: 1
|
||||
- _VertexColor: 0
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
|
||||
@ -24,8 +24,7 @@ Material:
|
||||
m_Shader: {fileID: 4800000, guid: 37036939f3d0a824c82a3f34093d4a42, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _VERTEXCOLOR_ON
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 1
|
||||
@ -99,6 +98,7 @@ Material:
|
||||
- _AddPrecomputedVelocity: 0
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Billboard: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
@ -108,6 +108,7 @@ Material:
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _Dot: 0
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
@ -127,7 +128,7 @@ Material:
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _VertexColor: 1
|
||||
- _VertexColor: 0
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
|
||||
@ -24,9 +24,9 @@ Material:
|
||||
m_Shader: {fileID: 4800000, guid: 7bfe6625bfb0167438e98aa0d69e97e7, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
m_ValidKeywords:
|
||||
- _VERTEXCOLOR_ON
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 1
|
||||
m_DoubleSidedGI: 0
|
||||
@ -99,6 +99,7 @@ Material:
|
||||
- _AddPrecomputedVelocity: 0
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Billboard: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
@ -108,6 +109,7 @@ Material:
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _Dot: 0
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
|
||||
@ -98,6 +98,7 @@ Material:
|
||||
- _AddPrecomputedVelocity: 0
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Billboard: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
@ -107,9 +108,11 @@ Material:
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _Dot: 0
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _FakeLight: 0
|
||||
- _GlossMapScale: 0
|
||||
- _Glossiness: 0
|
||||
- _GlossyReflections: 0
|
||||
@ -124,6 +127,7 @@ Material:
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _VertexColor: 0
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
|
||||
@ -172,92 +172,6 @@ MeshRenderer:
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!1 &817216530089604692
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2185866943208229465}
|
||||
- component: {fileID: 7306071439557822573}
|
||||
- component: {fileID: 7642098115862499429}
|
||||
m_Layer: 0
|
||||
m_Name: Line
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &2185866943208229465
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 817216530089604692}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: -5, y: -2.5, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 2844384060761577604}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &7306071439557822573
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 817216530089604692}
|
||||
m_Mesh: {fileID: 4300000, guid: 873de0939b7f76947a258a8897199a8e, type: 2}
|
||||
--- !u!23 &7642098115862499429
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 817216530089604692}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||
m_RayTracingAccelStructBuildFlags: 1
|
||||
m_SmallMeshCulling: 1
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: fce881fda18d0a44fb62c8375d3e2fd4, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!1 &1299980064020930364
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -466,7 +380,6 @@ Transform:
|
||||
- {fileID: 5119875421667202613}
|
||||
- {fileID: 1046323005297189095}
|
||||
- {fileID: 7483746332942052062}
|
||||
- {fileID: 2185866943208229465}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &6318046265503597909
|
||||
|
||||
@ -1,84 +0,0 @@
|
||||
Shader "DCFApixels/DebugX/Handles Buillboard"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Transparent" "RenderType"="Transparent" "IgnoreProjector"="True" "ForceNoShadowCasting"="True" }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Fog { Mode Off }
|
||||
Lighting Off
|
||||
Offset -1, -1
|
||||
|
||||
ZTest On
|
||||
|
||||
CGINCLUDE
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_instancing
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
half4 color : COLOR;
|
||||
};
|
||||
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
UNITY_DEFINE_INSTANCED_PROP(float4, _Color)
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
float4 _DebugX_GlobalColor;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
|
||||
float4 worldOrigin = mul(UNITY_MATRIX_M, float4(0, 0, 0, 1));
|
||||
float4 viewOrigin = float4(UnityObjectToViewPos(float3(0, 0, 0)), 1);
|
||||
float4 worldPos = mul(UNITY_MATRIX_M, v.vertex);
|
||||
|
||||
float4 viewPos = worldPos - worldOrigin + viewOrigin;
|
||||
|
||||
float4 clipsPos = mul(UNITY_MATRIX_P, viewPos);
|
||||
o.vertex = clipsPos;
|
||||
|
||||
|
||||
o.color = v.color * UNITY_ACCESS_INSTANCED_PROP(Props, _Color) * _DebugX_GlobalColor;
|
||||
return o;
|
||||
}
|
||||
ENDCG
|
||||
|
||||
Pass
|
||||
{
|
||||
ZTest LEqual
|
||||
CGPROGRAM
|
||||
half4 frag (v2f i) : SV_Target
|
||||
{
|
||||
return i.color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
Pass
|
||||
{
|
||||
ZTest Greater
|
||||
CGPROGRAM
|
||||
half4 frag (v2f i) : SV_Target
|
||||
{
|
||||
return i.color * half4(1, 1, 1, 0.1);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fe57c76c30f7274f9ebb46c87d64036
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,105 +0,0 @@
|
||||
Shader "DCFApixels/DebugX/Handles Dot"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Transparent" "RenderType"="Transparent" "IgnoreProjector"="True" "ForceNoShadowCasting"="True" }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Fog { Mode Off }
|
||||
Lighting Off
|
||||
Offset -1, -1
|
||||
|
||||
ZTest On
|
||||
|
||||
CGINCLUDE
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_instancing
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
half4 color : COLOR;
|
||||
};
|
||||
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
UNITY_DEFINE_INSTANCED_PROP(float4, _Color)
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
float _DebugX_GlobalDotSize;
|
||||
float4 _DebugX_GlobalColor;
|
||||
|
||||
float GetHandleSize(float3 objectPosition)
|
||||
{
|
||||
float3 viewDir = normalize(_WorldSpaceCameraPos - objectPosition);
|
||||
|
||||
float distance = length(_WorldSpaceCameraPos - objectPosition);
|
||||
float isOrthographic = UNITY_MATRIX_P[3][3];
|
||||
distance = lerp(distance, 1, isOrthographic);
|
||||
|
||||
float fov = radians(UNITY_MATRIX_P[1][1] * 2.0);
|
||||
float scale = distance * (1 / fov) * 0.015;
|
||||
|
||||
return scale * _DebugX_GlobalDotSize;
|
||||
}
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
|
||||
float scaleMultiplier = GetHandleSize(mul(UNITY_MATRIX_M, float4(0, 0, 0, 1)).xyz);
|
||||
float4x4 M = UNITY_MATRIX_M;
|
||||
M._m00 *= scaleMultiplier;
|
||||
M._m11 *= scaleMultiplier;
|
||||
M._m22 *= scaleMultiplier;
|
||||
|
||||
float4 worldOrigin = mul(M, float4(0, 0, 0, 1));
|
||||
float4 viewOrigin = float4(UnityObjectToViewPos(float3(0, 0, 0)), 1);
|
||||
float4 worldPos = mul(M, v.vertex);
|
||||
|
||||
float4 viewPos = worldPos - worldOrigin + viewOrigin;
|
||||
|
||||
float4 clipsPos = mul(UNITY_MATRIX_P, viewPos);
|
||||
o.vertex = clipsPos;
|
||||
|
||||
|
||||
o.color = v.color * UNITY_ACCESS_INSTANCED_PROP(Props, _Color) * _DebugX_GlobalColor;
|
||||
return o;
|
||||
}
|
||||
ENDCG
|
||||
|
||||
Pass
|
||||
{
|
||||
ZTest LEqual
|
||||
CGPROGRAM
|
||||
half4 frag (v2f i) : SV_Target
|
||||
{
|
||||
return i.color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
Pass
|
||||
{
|
||||
ZTest Greater
|
||||
CGPROGRAM
|
||||
half4 frag (v2f i) : SV_Target
|
||||
{
|
||||
return i.color * half4(1, 1, 1, 0.1);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69efe102f685e6c4cb2e2f25b7f7bdc7
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
150
Runtime/Shaders/HandlesOverwrite.shader
Normal file
150
Runtime/Shaders/HandlesOverwrite.shader
Normal file
@ -0,0 +1,150 @@
|
||||
Shader "DCFApixels/DebugX/Handles Overwrite"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
[Toggle] _VertexColor("Vertex Color", Float) = 0
|
||||
[Toggle] _FakeLight("Fake Light", Float) = 0
|
||||
[Toggle] _Billboard("Billboard", Float) = 0
|
||||
[Toggle] _Dot("Dot", Float) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Transparent" "RenderType"="Transparent" "IgnoreProjector"="True" "ForceNoShadowCasting"="True" }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Fog { Mode Off }
|
||||
Lighting Off
|
||||
Offset -1, -1
|
||||
|
||||
ZTest Always
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_instancing
|
||||
#pragma shader_feature_local _VERTEXCOLOR_ON
|
||||
#pragma shader_feature_local _FAKELIGHT_ON
|
||||
#pragma shader_feature_local _ONEPASS_ON
|
||||
#pragma shader_feature_local _BILLBOARD_ON
|
||||
#pragma shader_feature_local _DOT_ON
|
||||
#pragma instancing_options procedural:setup
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
#if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)
|
||||
struct InstanceData
|
||||
{
|
||||
float4x4 m;
|
||||
float4 color;
|
||||
};
|
||||
StructuredBuffer<InstanceData> _DataBuffer;
|
||||
#endif
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
#if _FAKELIGHT_ON
|
||||
float3 normal : NORMAL;
|
||||
#endif
|
||||
#if _VERTEXCOLOR_ON
|
||||
float4 color : COLOR;
|
||||
#endif
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
half4 color : COLOR;
|
||||
};
|
||||
|
||||
float4 _Color;
|
||||
float4 _DebugX_GlobalColor;
|
||||
|
||||
void setup()
|
||||
{
|
||||
#if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)
|
||||
InstanceData data = _DataBuffer[unity_InstanceID];
|
||||
|
||||
UNITY_MATRIX_M = data.m; //UNITY_MATRIX_M
|
||||
_Color = data.color;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#if _DOT_ON
|
||||
float _DebugX_GlobalDotSize;
|
||||
float GetHandleSize(float3 objectPosition)
|
||||
{
|
||||
float3 viewDir = normalize(_WorldSpaceCameraPos - objectPosition);
|
||||
|
||||
float distance = length(_WorldSpaceCameraPos - objectPosition);
|
||||
float isOrthographic = UNITY_MATRIX_P[3][3];
|
||||
distance = lerp(distance, 1, isOrthographic);
|
||||
|
||||
float fov = radians(UNITY_MATRIX_P[1][1] * 2.0);
|
||||
float scale = distance * (1 / fov) * 0.015;
|
||||
|
||||
return scale * _DebugX_GlobalDotSize;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
|
||||
float4x4 M = UNITY_MATRIX_M;
|
||||
#if _DOT_ON
|
||||
float scaleMultiplier = GetHandleSize(mul(UNITY_MATRIX_M, float4(0, 0, 0, 1)).xyz);
|
||||
M._m00 *= scaleMultiplier;
|
||||
M._m11 *= scaleMultiplier;
|
||||
M._m22 *= scaleMultiplier;
|
||||
#endif
|
||||
|
||||
|
||||
#if _BILLBOARD_ON
|
||||
float4 worldOrigin = mul(M, float4(0, 0, 0, 1));
|
||||
float4 viewOrigin = float4(UnityObjectToViewPos(float3(0, 0, 0)), 1);
|
||||
float4 worldPos = mul(M, v.vertex);
|
||||
|
||||
float4 viewPos = worldPos - worldOrigin + viewOrigin;
|
||||
|
||||
float4 clipsPos = mul(UNITY_MATRIX_P, viewPos);
|
||||
o.vertex = clipsPos;
|
||||
#else
|
||||
o.vertex = UnityObjectToClipPos(v.vertex); //UNITY_MATRIX_VP
|
||||
#endif
|
||||
|
||||
|
||||
half4 color = _Color;
|
||||
#if _FAKELIGHT_ON
|
||||
float3 eyeNormal = normalize (mul ((float3x3)UNITY_MATRIX_IT_MV, v.normal).xyz);
|
||||
float nl = saturate(eyeNormal.z);
|
||||
float lighting = 0.333 + nl * 0.667 * 0.5;
|
||||
color.rgb = lighting * color.rgb;
|
||||
color = saturate(color) * _DebugX_GlobalColor;
|
||||
#endif
|
||||
|
||||
#if _VERTEXCOLOR_ON
|
||||
color *= v.color;
|
||||
#endif
|
||||
o.color = color * _DebugX_GlobalColor;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag (v2f i) : SV_Target
|
||||
{
|
||||
return i.color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,61 +0,0 @@
|
||||
Shader "DCFApixels/DebugX/Handles Unlit Overwrite"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Transparent" "RenderType"="Transparent" "IgnoreProjector"="True" "ForceNoShadowCasting"="True" }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Fog { Mode Off }
|
||||
Lighting Off
|
||||
Offset -1, -1
|
||||
|
||||
ZTest Always
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_instancing
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
half4 color : COLOR;
|
||||
};
|
||||
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
UNITY_DEFINE_INSTANCED_PROP(float4, _Color)
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
float4 _DebugX_GlobalColor;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.color = v.color * UNITY_ACCESS_INSTANCED_PROP(Props, _Color) * _DebugX_GlobalColor;
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag (v2f i) : SV_Target
|
||||
{
|
||||
return i.color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,10 @@ Shader "DCFApixels/DebugX/Handles Wire"
|
||||
Properties
|
||||
{
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
[Toggle] _VertexColor("Vertex Color", Float) = 0
|
||||
[Toggle] _FakeLight("Fake Light", Float) = 0
|
||||
[Toggle] _Billboard("Billboard", Float) = 0
|
||||
[Toggle] _Dot("Dot", Float) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
@ -13,49 +17,135 @@ Shader "DCFApixels/DebugX/Handles Wire"
|
||||
Lighting Off
|
||||
Offset -1, -1
|
||||
|
||||
ZTest Off
|
||||
ZTest On
|
||||
|
||||
CGINCLUDE
|
||||
#pragma vertex vert
|
||||
#pragma geometry geom
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_instancing
|
||||
#pragma shader_feature_local _VERTEXCOLOR_ON
|
||||
#pragma shader_feature_local _FAKELIGHT_ON
|
||||
#pragma shader_feature_local _ONEPASS_ON
|
||||
#pragma shader_feature_local _BILLBOARD_ON
|
||||
#pragma shader_feature_local _DOT_ON
|
||||
#pragma instancing_options procedural:setup
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
#if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)
|
||||
struct InstanceData
|
||||
{
|
||||
float4x4 m;
|
||||
float4 color;
|
||||
};
|
||||
StructuredBuffer<InstanceData> _DataBuffer;
|
||||
#endif
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
#if _FAKELIGHT_ON
|
||||
float3 normal : NORMAL;
|
||||
#endif
|
||||
#if _VERTEXCOLOR_ON
|
||||
float4 color : COLOR;
|
||||
#endif
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2g
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float4 vertex : SV_POSITION;
|
||||
half4 color : COLOR;
|
||||
};
|
||||
|
||||
struct g2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
UNITY_DEFINE_INSTANCED_PROP(float4, _Color)
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
float4 _Color;
|
||||
float4 _DebugX_GlobalColor;
|
||||
|
||||
v2g vert(appdata v)
|
||||
void setup()
|
||||
{
|
||||
#if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)
|
||||
InstanceData data = _DataBuffer[unity_InstanceID];
|
||||
|
||||
UNITY_MATRIX_M = data.m; //UNITY_MATRIX_M
|
||||
_Color = data.color;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#if _DOT_ON
|
||||
float _DebugX_GlobalDotSize;
|
||||
float GetHandleSize(float3 objectPosition)
|
||||
{
|
||||
float3 viewDir = normalize(_WorldSpaceCameraPos - objectPosition);
|
||||
|
||||
float distance = length(_WorldSpaceCameraPos - objectPosition);
|
||||
float isOrthographic = UNITY_MATRIX_P[3][3];
|
||||
distance = lerp(distance, 1, isOrthographic);
|
||||
|
||||
float fov = radians(UNITY_MATRIX_P[1][1] * 2.0);
|
||||
float scale = distance * (1 / fov) * 0.015;
|
||||
|
||||
return scale * _DebugX_GlobalDotSize;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
v2g vert (appdata_t v)
|
||||
{
|
||||
v2g o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.color = v.color * UNITY_ACCESS_INSTANCED_PROP(Props, _Color) * _DebugX_GlobalColor;
|
||||
|
||||
float4x4 M = UNITY_MATRIX_M;
|
||||
#if _DOT_ON
|
||||
float scaleMultiplier = GetHandleSize(mul(UNITY_MATRIX_M, float4(0, 0, 0, 1)).xyz);
|
||||
M._m00 *= scaleMultiplier;
|
||||
M._m11 *= scaleMultiplier;
|
||||
M._m22 *= scaleMultiplier;
|
||||
#endif
|
||||
|
||||
|
||||
#if _BILLBOARD_ON
|
||||
float4 worldOrigin = mul(M, float4(0, 0, 0, 1));
|
||||
float4 viewOrigin = float4(UnityObjectToViewPos(float3(0, 0, 0)), 1);
|
||||
float4 worldPos = mul(M, v.vertex);
|
||||
|
||||
float4 viewPos = worldPos - worldOrigin + viewOrigin;
|
||||
|
||||
float4 clipsPos = mul(UNITY_MATRIX_P, viewPos);
|
||||
o.vertex = clipsPos;
|
||||
#else
|
||||
o.vertex = UnityObjectToClipPos(v.vertex); //UNITY_MATRIX_VP
|
||||
#endif
|
||||
|
||||
|
||||
half4 color = _Color;
|
||||
#if _FAKELIGHT_ON
|
||||
float3 eyeNormal = normalize (mul ((float3x3)UNITY_MATRIX_IT_MV, v.normal).xyz);
|
||||
float nl = saturate(eyeNormal.z);
|
||||
float lighting = 0.333 + nl * 0.667 * 0.5;
|
||||
color.rgb = lighting * color.rgb;
|
||||
color = saturate(color) * _DebugX_GlobalColor;
|
||||
#endif
|
||||
|
||||
#if _VERTEXCOLOR_ON
|
||||
color *= v.color;
|
||||
#endif
|
||||
o.color = color * _DebugX_GlobalColor;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[maxvertexcount(6)]
|
||||
void geom(triangle v2g input[3], inout LineStream<g2f> lineStream)
|
||||
{
|
||||
@ -88,13 +178,14 @@ Shader "DCFApixels/DebugX/Handles Wire"
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
ZTest Greater
|
||||
CGPROGRAM
|
||||
half4 frag (g2f i) : SV_Target
|
||||
{
|
||||
return i.color * half4(1, 1, 1, 0.05);
|
||||
return i.color * half4(1, 1, 1, 0.1);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user