stash update materials

This commit is contained in:
DCFApixels 2025-03-05 10:32:19 +08:00
parent 76574124ca
commit 7f0c121e68
15 changed files with 266 additions and 177 deletions

View File

@ -46,7 +46,7 @@ namespace DCFApixels
#region Mesh //TODO потестить #region Mesh //TODO потестить
[IN(LINE)] [IN(LINE)]
public DrawHandler Mesh<TMat>(Mesh mesh, Vector3 position, Quaternion rotation, Vector3 size) public DrawHandler Mesh<TMat>(Mesh mesh, Vector3 position, Quaternion rotation, Vector3 size)
where TMat : struct, IStaticMaterial_InstancedProcedural where TMat : struct, IStaticMaterial
{ {
return Gizmo(new MeshGizmo<TMat>(mesh, position, rotation, size)); return Gizmo(new MeshGizmo<TMat>(mesh, position, rotation, size));
} }
@ -81,7 +81,7 @@ namespace DCFApixels
} }
} }
private readonly struct MeshGizmo<TMat> : IGizmo<MeshGizmo<TMat>> private readonly struct MeshGizmo<TMat> : IGizmo<MeshGizmo<TMat>>
where TMat : struct, IStaticMaterial_InstancedProcedural where TMat : struct, IStaticMaterial
{ {
public readonly Mesh Mesh; public readonly Mesh Mesh;
public readonly Quaternion Rotation; public readonly Quaternion Rotation;
@ -116,7 +116,7 @@ namespace DCFApixels
[IN(LINE)] [IN(LINE)]
public DrawHandler Mesh<TMesh, TMat>(Vector3 position, Quaternion rotation, Vector3 size) public DrawHandler Mesh<TMesh, TMat>(Vector3 position, Quaternion rotation, Vector3 size)
where TMesh : struct, IStaticMesh where TMesh : struct, IStaticMesh
where TMat : struct, IStaticMaterial_InstancedProcedural where TMat : struct, IStaticMaterial
{ {
return Gizmo(new InstancingMeshGizmo<TMesh, TMat>(position, rotation, size)); return Gizmo(new InstancingMeshGizmo<TMesh, TMat>(position, rotation, size));
} }
@ -153,7 +153,7 @@ namespace DCFApixels
} }
private readonly struct InstancingMeshGizmo<TMesh, TMat> : IGizmo<InstancingMeshGizmo<TMesh, TMat>> private readonly struct InstancingMeshGizmo<TMesh, TMat> : IGizmo<InstancingMeshGizmo<TMesh, TMat>>
where TMesh : struct, IStaticMesh where TMesh : struct, IStaticMesh
where TMat : struct, IStaticMaterial_InstancedProcedural where TMat : struct, IStaticMaterial
{ {
public readonly Quaternion Rotation; public readonly Quaternion Rotation;
public readonly Vector3 Position; public readonly Vector3 Position;
@ -184,7 +184,7 @@ namespace DCFApixels
#region Line #region Line
[IN(LINE)] [IN(LINE)]
public DrawHandler Line<TMat>(Vector3 start, Vector3 end) public DrawHandler Line<TMat>(Vector3 start, Vector3 end)
where TMat : struct, IStaticMaterial_InstancedProcedural where TMat : struct, IStaticMaterial
{ {
return Gizmo(new WireLineGizmo<TMat>(start, end)); return Gizmo(new WireLineGizmo<TMat>(start, end));
} }
@ -194,7 +194,7 @@ namespace DCFApixels
return Gizmo(new WireLineGizmo<UnlitMat>(start, end)); return Gizmo(new WireLineGizmo<UnlitMat>(start, end));
} }
private readonly struct WireLineGizmo<TMat> : IGizmo<WireLineGizmo<TMat>> private readonly struct WireLineGizmo<TMat> : IGizmo<WireLineGizmo<TMat>>
where TMat : struct, IStaticMaterial_InstancedProcedural where TMat : struct, IStaticMaterial
{ {
public readonly Vector3 Start; public readonly Vector3 Start;
public readonly Vector3 End; public readonly Vector3 End;
@ -256,7 +256,7 @@ namespace DCFApixels
} }
} }
private readonly IStaticMaterial_InstancedProcedural _material; private readonly IStaticMaterial _material;
private int _buffersLength = 0; private int _buffersLength = 0;
private PinnedArray<Matrix4x4> _matrices; private PinnedArray<Matrix4x4> _matrices;
@ -271,7 +271,7 @@ namespace DCFApixels
public virtual int ExecuteOrder => _material.GetExecuteOrder(); public virtual int ExecuteOrder => _material.GetExecuteOrder();
public virtual bool IsStaticRender => true; public virtual bool IsStaticRender => true;
public MeshRendererBase(IStaticMaterial_InstancedProcedural material) public MeshRendererBase(IStaticMaterial material)
{ {
_materialPropertyBlock = new MaterialPropertyBlock(); _materialPropertyBlock = new MaterialPropertyBlock();
_material = material; _material = material;
@ -316,7 +316,7 @@ namespace DCFApixels
} }
public void Render(CommandBuffer cb) public void Render(CommandBuffer cb)
{ {
Material material = _material.GetMaterial_InstancedProcedural(); Material material = _material.GetMaterial();
var items = new GizmosList<UnmanagedGizmoData>(_gizmos.Array, _prepareCount).As<GizmoData>().Items; var items = new GizmosList<UnmanagedGizmoData>(_gizmos.Array, _prepareCount).As<GizmoData>().Items;
_materialPropertyBlock.Clear(); _materialPropertyBlock.Clear();
_jobHandle.Complete(); _jobHandle.Complete();
@ -360,7 +360,7 @@ namespace DCFApixels
} }
private readonly IStaticMesh _mesh; private readonly IStaticMesh _mesh;
private readonly IStaticMaterial_InstancedProcedural _material; private readonly IStaticMaterial _material;
private readonly MaterialPropertyBlock _materialPropertyBlock; private readonly MaterialPropertyBlock _materialPropertyBlock;
private GraphicsBuffer _graphicsBuffer; private GraphicsBuffer _graphicsBuffer;
@ -373,13 +373,13 @@ namespace DCFApixels
private readonly bool _enableInstancing; private readonly bool _enableInstancing;
public InstancingMeshRendererBase(IStaticMesh mesh, IStaticMaterial_InstancedProcedural material) public InstancingMeshRendererBase(IStaticMesh mesh, IStaticMaterial material)
{ {
_mesh = mesh; _mesh = mesh;
_material = material; _material = material;
_materialPropertyBlock = new MaterialPropertyBlock(); _materialPropertyBlock = new MaterialPropertyBlock();
_drawDatas = PinnedArray<DrawData>.Pin(DummyArray<DrawData>.Get()); _drawDatas = PinnedArray<DrawData>.Pin(DummyArray<DrawData>.Get());
_enableInstancing = IsSupportsComputeShaders && _material.GetMaterial_InstancedProcedural().enableInstancing; _enableInstancing = IsSupportsComputeShaders && _material.GetMaterial().enableInstancing;
} }
public virtual int ExecuteOrder => _material.GetExecuteOrder(); public virtual int ExecuteOrder => _material.GetExecuteOrder();
public virtual bool IsStaticRender => true; public virtual bool IsStaticRender => true;
@ -419,7 +419,7 @@ namespace DCFApixels
Mesh mesh = _mesh.GetMesh(); Mesh mesh = _mesh.GetMesh();
if (_enableInstancing) if (_enableInstancing)
{ {
Material material = _material.GetMaterial_InstancedProcedural(); Material material = _material.GetMaterial();
_jobHandle.Complete(); _jobHandle.Complete();
_graphicsBuffer.SetData(_drawDatas.Array); _graphicsBuffer.SetData(_drawDatas.Array);
cb.DrawMeshInstancedProcedural(mesh, 0, material, -1, _prepareCount, _materialPropertyBlock); cb.DrawMeshInstancedProcedural(mesh, 0, material, -1, _prepareCount, _materialPropertyBlock);
@ -479,7 +479,7 @@ namespace DCFApixels
} }
} }
private readonly IStaticMesh _mesh = default(WireLineMesh); private readonly IStaticMesh _mesh = default(WireLineMesh);
private readonly IStaticMaterial_InstancedProcedural _material; private readonly IStaticMaterial _material;
private readonly MaterialPropertyBlock _materialPropertyBlock; private readonly MaterialPropertyBlock _materialPropertyBlock;
private GraphicsBuffer _graphicsBuffer; private GraphicsBuffer _graphicsBuffer;
@ -492,12 +492,12 @@ namespace DCFApixels
private readonly bool _enableInstancing; private readonly bool _enableInstancing;
public WireLineRendererBase(IStaticMaterial_InstancedProcedural material) public WireLineRendererBase(IStaticMaterial material)
{ {
_material = material; _material = material;
_materialPropertyBlock = new MaterialPropertyBlock(); _materialPropertyBlock = new MaterialPropertyBlock();
_drawDatas = PinnedArray<DrawData>.Pin(DummyArray<DrawData>.Get()); _drawDatas = PinnedArray<DrawData>.Pin(DummyArray<DrawData>.Get());
_enableInstancing = IsSupportsComputeShaders && _material.GetMaterial_InstancedProcedural().enableInstancing; _enableInstancing = IsSupportsComputeShaders && _material.GetMaterial().enableInstancing;
} }
public virtual int ExecuteOrder => _material.GetExecuteOrder(); public virtual int ExecuteOrder => _material.GetExecuteOrder();
public virtual bool IsStaticRender => true; public virtual bool IsStaticRender => true;
@ -534,7 +534,7 @@ namespace DCFApixels
Mesh mesh = _mesh.GetMesh(); Mesh mesh = _mesh.GetMesh();
if (_enableInstancing) if (_enableInstancing)
{ {
Material material = _material.GetMaterial_InstancedProcedural(); Material material = _material.GetMaterial();
_jobHandle.Complete(); _jobHandle.Complete();
_graphicsBuffer.SetData(_drawDatas.Array); _graphicsBuffer.SetData(_drawDatas.Array);
cb.DrawMeshInstancedProcedural(mesh, 0, material, -1, _prepareCount, _materialPropertyBlock); cb.DrawMeshInstancedProcedural(mesh, 0, material, -1, _prepareCount, _materialPropertyBlock);

View File

@ -202,7 +202,7 @@ namespace DCFApixels
public void Render(Camera camera, GizmosList<WidthLineGizmo> list, CommandBuffer cb) public void Render(Camera camera, GizmosList<WidthLineGizmo> list, CommandBuffer cb)
{ {
if (camera == null) { return; } if (camera == null) { return; }
default(UnlitOverwriteMat).GetMaterial_InstancedProcedural().SetPass(0); default(UnlitOverwriteMat).GetMaterial().SetPass(0);
GL.Begin(GL.QUADS); GL.Begin(GL.QUADS);
Vector3 cameraPosition = camera.transform.position; Vector3 cameraPosition = camera.transform.position;
foreach (ref readonly var item in list) foreach (ref readonly var item in list)
@ -256,7 +256,7 @@ namespace DCFApixels
public void Render(Camera camera, GizmosList<WidthOutLineGizmo> list, CommandBuffer cb) public void Render(Camera camera, GizmosList<WidthOutLineGizmo> list, CommandBuffer cb)
{ {
if (camera == null) { return; } if (camera == null) { return; }
default(UnlitOverwriteMat).GetMaterial_InstancedProcedural().SetPass(0); default(UnlitOverwriteMat).GetMaterial().SetPass(0);
GL.Begin(GL.LINES); GL.Begin(GL.LINES);
var cameraPosition = camera.transform.position; var cameraPosition = camera.transform.position;
foreach (ref readonly var item in list) foreach (ref readonly var item in list)
@ -318,7 +318,7 @@ namespace DCFApixels
{ {
if (camera == null) { return; } if (camera == null) { return; }
GL.PushMatrix(); GL.PushMatrix();
default(UnlitOverwriteMat).GetMaterial_InstancedProcedural().SetPass(0); default(UnlitOverwriteMat).GetMaterial().SetPass(0);
GL.Begin(GL.LINES); GL.Begin(GL.LINES);
var cameraPosition = camera.transform.position; var cameraPosition = camera.transform.position;
foreach (ref readonly var item in list) foreach (ref readonly var item in list)

View File

@ -21,10 +21,11 @@ Material:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: Billboard m_Name: Billboard
m_Shader: {fileID: 4800000, guid: 0fe57c76c30f7274f9ebb46c87d64036, type: 3} m_Shader: {fileID: 4800000, guid: 37036939f3d0a824c82a3f34093d4a42, type: 3}
m_Parent: {fileID: 0} m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0 m_ModifiedSerializedProperties: 0
m_ValidKeywords: [] m_ValidKeywords:
- _BILLBOARD_ON
m_InvalidKeywords: [] m_InvalidKeywords: []
m_LightmapFlags: 4 m_LightmapFlags: 4
m_EnableInstancingVariants: 1 m_EnableInstancingVariants: 1
@ -98,6 +99,7 @@ Material:
- _AddPrecomputedVelocity: 0 - _AddPrecomputedVelocity: 0
- _AlphaClip: 0 - _AlphaClip: 0
- _AlphaToMask: 0 - _AlphaToMask: 0
- _Billboard: 1
- _Blend: 0 - _Blend: 0
- _BlendModePreserveSpecular: 1 - _BlendModePreserveSpecular: 1
- _BumpScale: 1 - _BumpScale: 1
@ -107,9 +109,11 @@ Material:
- _Cutoff: 0.5 - _Cutoff: 0.5
- _DetailAlbedoMapScale: 1 - _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1 - _DetailNormalMapScale: 1
- _Dot: 0
- _DstBlend: 0 - _DstBlend: 0
- _DstBlendAlpha: 0 - _DstBlendAlpha: 0
- _EnvironmentReflections: 1 - _EnvironmentReflections: 1
- _FakeLight: 0
- _GlossMapScale: 0 - _GlossMapScale: 0
- _Glossiness: 0 - _Glossiness: 0
- _GlossyReflections: 0 - _GlossyReflections: 0
@ -124,6 +128,7 @@ Material:
- _SrcBlend: 1 - _SrcBlend: 1
- _SrcBlendAlpha: 1 - _SrcBlendAlpha: 1
- _Surface: 0 - _Surface: 0
- _VertexColor: 0
- _WorkflowMode: 1 - _WorkflowMode: 1
- _ZWrite: 1 - _ZWrite: 1
m_Colors: m_Colors:

View File

@ -21,10 +21,12 @@ Material:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: Dot m_Name: Dot
m_Shader: {fileID: 4800000, guid: 69efe102f685e6c4cb2e2f25b7f7bdc7, type: 3} m_Shader: {fileID: 4800000, guid: 37036939f3d0a824c82a3f34093d4a42, type: 3}
m_Parent: {fileID: 0} m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0 m_ModifiedSerializedProperties: 0
m_ValidKeywords: [] m_ValidKeywords:
- _BILLBOARD_ON
- _DOT_ON
m_InvalidKeywords: [] m_InvalidKeywords: []
m_LightmapFlags: 4 m_LightmapFlags: 4
m_EnableInstancingVariants: 1 m_EnableInstancingVariants: 1
@ -98,6 +100,7 @@ Material:
- _AddPrecomputedVelocity: 0 - _AddPrecomputedVelocity: 0
- _AlphaClip: 0 - _AlphaClip: 0
- _AlphaToMask: 0 - _AlphaToMask: 0
- _Billboard: 1
- _Blend: 0 - _Blend: 0
- _BlendModePreserveSpecular: 1 - _BlendModePreserveSpecular: 1
- _BumpScale: 1 - _BumpScale: 1
@ -107,9 +110,11 @@ Material:
- _Cutoff: 0.5 - _Cutoff: 0.5
- _DetailAlbedoMapScale: 1 - _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1 - _DetailNormalMapScale: 1
- _Dot: 1
- _DstBlend: 0 - _DstBlend: 0
- _DstBlendAlpha: 0 - _DstBlendAlpha: 0
- _EnvironmentReflections: 1 - _EnvironmentReflections: 1
- _FakeLight: 0
- _GlossMapScale: 0 - _GlossMapScale: 0
- _Glossiness: 0 - _Glossiness: 0
- _GlossyReflections: 0 - _GlossyReflections: 0
@ -124,6 +129,7 @@ Material:
- _SrcBlend: 1 - _SrcBlend: 1
- _SrcBlendAlpha: 1 - _SrcBlendAlpha: 1
- _Surface: 0 - _Surface: 0
- _VertexColor: 0
- _WorkflowMode: 1 - _WorkflowMode: 1
- _ZWrite: 1 - _ZWrite: 1
m_Colors: m_Colors:

View File

@ -26,6 +26,7 @@ Material:
m_Ints: [] m_Ints: []
m_Floats: m_Floats:
- _FakeLight: 0 - _FakeLight: 0
- _OnePass: 0
- _VertexColor: 0 - _VertexColor: 0
m_Colors: m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1} - _Color: {r: 1, g: 1, b: 1, a: 1}

View File

@ -21,10 +21,12 @@ Material:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: Lit m_Name: Lit
m_Shader: {fileID: 4800000, guid: b3126f69d0ed1ac439449358fc8a54aa, type: 3} m_Shader: {fileID: 4800000, guid: 37036939f3d0a824c82a3f34093d4a42, type: 3}
m_Parent: {fileID: 0} m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0 m_ModifiedSerializedProperties: 0
m_ValidKeywords: [] m_ValidKeywords:
- _FAKELIGHT_ON
- _VERTEXCOLOR_ON
m_InvalidKeywords: [] m_InvalidKeywords: []
m_LightmapFlags: 4 m_LightmapFlags: 4
m_EnableInstancingVariants: 1 m_EnableInstancingVariants: 1
@ -110,6 +112,7 @@ Material:
- _DstBlend: 0 - _DstBlend: 0
- _DstBlendAlpha: 0 - _DstBlendAlpha: 0
- _EnvironmentReflections: 1 - _EnvironmentReflections: 1
- _FakeLight: 1
- _GlossMapScale: 0 - _GlossMapScale: 0
- _Glossiness: 0 - _Glossiness: 0
- _GlossyReflections: 0 - _GlossyReflections: 0
@ -124,6 +127,7 @@ Material:
- _SrcBlend: 1 - _SrcBlend: 1
- _SrcBlendAlpha: 1 - _SrcBlendAlpha: 1
- _Surface: 0 - _Surface: 0
- _VertexColor: 1
- _WorkflowMode: 1 - _WorkflowMode: 1
- _ZWrite: 1 - _ZWrite: 1
m_Colors: m_Colors:

View File

@ -117,6 +117,7 @@ Material:
- _GlossyReflections: 0 - _GlossyReflections: 0
- _Metallic: 0 - _Metallic: 0
- _OcclusionStrength: 1 - _OcclusionStrength: 1
- _OnePass: 0
- _Parallax: 0.005 - _Parallax: 0.005
- _QueueOffset: 0 - _QueueOffset: 0
- _ReceiveShadows: 1 - _ReceiveShadows: 1

View File

@ -0,0 +1,139 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-8282512757102464268
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 9
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: UnlitOverwrite
m_Shader: {fileID: 4800000, guid: 7bfe6625bfb0167438e98aa0d69e97e7, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords:
- _VERTEXCOLOR_ON
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses:
- MOTIONVECTORS
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _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}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AddPrecomputedVelocity: 0
- _AlphaClip: 0
- _AlphaToMask: 0
- _Blend: 0
- _BlendModePreserveSpecular: 1
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _DstBlendAlpha: 0
- _EnvironmentReflections: 1
- _FakeLight: 0
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _OnePass: 0
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 0
- _VertexColor: 1
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c39ea10bc1b7eeb4b95b16a7d83e82d8
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -533,7 +533,7 @@ MeshRenderer:
m_RenderingLayerMask: 1 m_RenderingLayerMask: 1
m_RendererPriority: 0 m_RendererPriority: 0
m_Materials: m_Materials:
- {fileID: 2100000, guid: e3db4ecf82b06ef4fa7fdb30e68362fa, type: 2} - {fileID: 2100000, guid: c39ea10bc1b7eeb4b95b16a7d83e82d8, type: 2}
m_StaticBatchInfo: m_StaticBatchInfo:
firstSubMesh: 0 firstSubMesh: 0
subMeshCount: 0 subMeshCount: 0

View File

@ -1,11 +1,12 @@
Shader "DCFApixels/DebugX/Handles Unlit" Shader "DCFApixels/DebugX/Handles"
{ {
Properties Properties
{ {
_Color ("Color", Color) = (1,1,1,1) _Color ("Color", Color) = (1,1,1,1)
[Toggle] _VertexColor("Vertex Color", Float) = 0 [Toggle] _VertexColor("Vertex Color", Float) = 0
[Toggle] _FakeLight("Fake Light", Float) = 0 [Toggle] _FakeLight("Fake Light", Float) = 0
[Toggle] _OnePass("One Pass", Float) = 0 [Toggle] _Billboard("Billboard", Float) = 0
[Toggle] _Dot("Dot", Float) = 0
} }
SubShader SubShader
{ {
@ -25,11 +26,13 @@ Shader "DCFApixels/DebugX/Handles Unlit"
#pragma shader_feature_local _VERTEXCOLOR_ON #pragma shader_feature_local _VERTEXCOLOR_ON
#pragma shader_feature_local _FAKELIGHT_ON #pragma shader_feature_local _FAKELIGHT_ON
#pragma shader_feature_local _ONEPASS_ON #pragma shader_feature_local _ONEPASS_ON
#pragma shader_feature_local _BILLBOARD_ON
#pragma shader_feature_local _DOT_ON
#pragma instancing_options procedural:setup #pragma instancing_options procedural:setup
#include "UnityCG.cginc" #include "UnityCG.cginc"
#ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED #if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)
struct InstanceData struct InstanceData
{ {
float4x4 m; float4x4 m;
@ -37,32 +40,6 @@ Shader "DCFApixels/DebugX/Handles Unlit"
}; };
StructuredBuffer<InstanceData> _DataBuffer; StructuredBuffer<InstanceData> _DataBuffer;
#endif #endif
void setup()
{
#ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
InstanceData data = _DataBuffer[unity_InstanceID];
float4x4 m = data.m;
float rotation = m.w * m.w * _Time.y * 0.5f;
rotate2D(m.xz, rotation);
unity_ObjectToWorld._11_21_31_41 = float4(m.w, 0, 0, 0);
unity_ObjectToWorld._12_22_32_42 = float4(0, m.w, 0, 0);
unity_ObjectToWorld._13_23_33_43 = float4(0, 0, m.w, 0);
unity_ObjectToWorld._14_24_34_44 = float4(m.xyz, 1);
unity_WorldToObject = unity_ObjectToWorld;
unity_WorldToObject._14_24_34 *= -1;
unity_WorldToObject._11_22_33 = 1.0f / unity_WorldToObject._11_22_33;
_Color = data.color;
#endif
}
struct appdata_t struct appdata_t
{ {
float4 vertex : POSITION; float4 vertex : POSITION;
@ -72,7 +49,6 @@ Shader "DCFApixels/DebugX/Handles Unlit"
#if _VERTEXCOLOR_ON #if _VERTEXCOLOR_ON
float4 color : COLOR; float4 color : COLOR;
#endif #endif
uint instanceID : SV_InstanceID;
UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_INPUT_INSTANCE_ID
}; };
@ -85,18 +61,73 @@ Shader "DCFApixels/DebugX/Handles Unlit"
float4 _Color; float4 _Color;
float4 _DebugX_GlobalColor; 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 vert (appdata_t v)
{ {
v2f o; v2f o;
UNITY_SETUP_INSTANCE_ID(v);
#ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED float4x4 M = UNITY_MATRIX_M;
InstanceData data = _DataBuffer[v.instanceID]; #if _DOT_ON
float4 pos = mul(data.m, v.vertex); float scaleMultiplier = GetHandleSize(mul(UNITY_MATRIX_M, float4(0, 0, 0, 1)).xyz);
o.vertex = UnityObjectToClipPos(pos); M._m00 *= scaleMultiplier;
half4 color = data.color; 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 #else
o.vertex = UnityObjectToClipPos(v.vertex); o.vertex = UnityObjectToClipPos(v.vertex); //UNITY_MATRIX_VP
#endif
half4 color = _Color; 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 #endif
#if _VERTEXCOLOR_ON #if _VERTEXCOLOR_ON

View File

@ -1,86 +0,0 @@
Shader "DCFApixels/DebugX/Handles Lit"
{
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
{
float3 vertex : POSITION;
float3 normal : NORMAL;
float4 color : COLOR;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
half4 color : COLOR0;
};
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 icolor = UNITY_ACCESS_INSTANCED_PROP(Props, _Color);
if (icolor.a >= 0)
{
v.color = v.color * icolor;
}
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;
float4 color;
color.rgb = lighting * v.color.rgb;
color.a = v.color.a;
o.color = saturate(color) * _DebugX_GlobalColor;
o.vertex = UnityObjectToClipPos(v.vertex);
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.2);
}
ENDCG
}
}
}

View File

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: b3126f69d0ed1ac439449358fc8a54aa
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -7,10 +7,6 @@ namespace DCFApixels.DebugXCore
int GetExecuteOrder(); int GetExecuteOrder();
Material GetMaterial(); Material GetMaterial();
} }
public interface IStaticMaterial_InstancedProcedural : IStaticMaterial
{
Material GetMaterial_InstancedProcedural();
}
public interface IStaticMesh : IStaticData public interface IStaticMesh : IStaticData
{ {
Mesh GetMesh(); Mesh GetMesh();
@ -19,46 +15,39 @@ namespace DCFApixels.DebugXCore
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public readonly struct LitMat : IStaticMaterial_InstancedProcedural public readonly struct LitMat : IStaticMaterial
{ {
public int GetExecuteOrder() => 0; public int GetExecuteOrder() => 0;
public Material GetMaterial_InstancedProcedural() => DebugXAssets.Materials.Lit;
public Material GetMaterial() => DebugXAssets.Materials.Lit; public Material GetMaterial() => DebugXAssets.Materials.Lit;
} }
public readonly struct UnlitMat : IStaticMaterial_InstancedProcedural public readonly struct UnlitMat : IStaticMaterial
{ {
public int GetExecuteOrder() => 100_000; public int GetExecuteOrder() => 100_000;
public Material GetMaterial_InstancedProcedural() => DebugXAssets.Materials.Unlit;
public Material GetMaterial() => DebugXAssets.Materials.Unlit; public Material GetMaterial() => DebugXAssets.Materials.Unlit;
} }
public readonly struct BillboardMat : IStaticMaterial_InstancedProcedural public readonly struct BillboardMat : IStaticMaterial
{ {
public int GetExecuteOrder() => 200_000; public int GetExecuteOrder() => 200_000;
public Material GetMaterial_InstancedProcedural() => DebugXAssets.Materials.Billboard;
public Material GetMaterial() => DebugXAssets.Materials.Billboard; public Material GetMaterial() => DebugXAssets.Materials.Billboard;
} }
public readonly struct DotMat : IStaticMaterial_InstancedProcedural public readonly struct DotMat : IStaticMaterial
{ {
public int GetExecuteOrder() => 300_000; public int GetExecuteOrder() => 300_000;
public Material GetMaterial_InstancedProcedural() => DebugXAssets.Materials.Dot;
public Material GetMaterial() => DebugXAssets.Materials.Dot; public Material GetMaterial() => DebugXAssets.Materials.Dot;
} }
public readonly struct GeometryUnlitMat : IStaticMaterial_InstancedProcedural public readonly struct GeometryUnlitMat : IStaticMaterial
{ {
public int GetExecuteOrder() => 1_000_000; public int GetExecuteOrder() => 1_000_000;
public Material GetMaterial_InstancedProcedural() => DebugXAssets.Materials.Unlit;
public Material GetMaterial() => DebugXAssets.Materials.Unlit; public Material GetMaterial() => DebugXAssets.Materials.Unlit;
} }
public readonly struct UnlitOverwriteMat : IStaticMaterial_InstancedProcedural public readonly struct UnlitOverwriteMat : IStaticMaterial
{ {
public int GetExecuteOrder() => 1_000_000; public int GetExecuteOrder() => 1_000_000;
public Material GetMaterial_InstancedProcedural() => DebugXAssets.Materials.UnlitOverwrite;
public Material GetMaterial() => DebugXAssets.Materials.UnlitOverwrite; public Material GetMaterial() => DebugXAssets.Materials.UnlitOverwrite;
} }
public readonly struct WireMat : IStaticMaterial_InstancedProcedural public readonly struct WireMat : IStaticMaterial
{ {
public int GetExecuteOrder() => 1_000_000; public int GetExecuteOrder() => 1_000_000;
public Material GetMaterial_InstancedProcedural() => DebugXAssets.Materials.Wire;
public Material GetMaterial() => DebugXAssets.Materials.Wire; public Material GetMaterial() => DebugXAssets.Materials.Wire;
} }