├── .gitignore ├── Assets ├── GPUClothSimulation.meta ├── GPUClothSimulation │ ├── Debug.meta │ ├── Debug │ │ ├── DebugRenderMat.mat │ │ ├── DebugRenderMat.mat.meta │ │ ├── DebugRenderShader.shader │ │ ├── DebugRenderShader.shader.meta │ │ ├── GPUClothDebugRenderer.cs │ │ ├── GPUClothDebugRenderer.cs.meta │ │ ├── GPUClothSimulationDebugRender.unity │ │ └── GPUClothSimulationDebugRender.unity.meta │ ├── Materials.meta │ ├── Materials │ │ ├── ClothSurfaceMat.mat │ │ ├── ClothSurfaceMat.mat.meta │ │ ├── CollisionSphereMat.mat │ │ └── CollisionSphereMat.mat.meta │ ├── Scenes.meta │ ├── Scenes │ │ ├── GPUClothSimulation.unity │ │ └── GPUClothSimulation.unity.meta │ ├── Scripts.meta │ ├── Scripts │ │ ├── ColliderTranslate.cs │ │ ├── ColliderTranslate.cs.meta │ │ ├── GPUClothRenderer.cs │ │ ├── GPUClothRenderer.cs.meta │ │ ├── GPUClothSimulation.cs │ │ └── GPUClothSimulation.cs.meta │ ├── Shaders.meta │ └── Shaders │ │ ├── ClothSurface.shader │ │ ├── ClothSurface.shader.meta │ │ ├── Kernels.compute │ │ └── Kernels.compute.meta ├── KleinianGroup.meta ├── KleinianGroup │ ├── KleinianGroup.meta │ ├── KleinianGroup.unity │ ├── KleinianGroup.unity.meta │ ├── KleinianGroup │ │ ├── KleinianGroup.cs │ │ ├── KleinianGroup.cs.meta │ │ ├── KleinianGroup.mat │ │ ├── KleinianGroup.mat.meta │ │ ├── KleinianGroup.shader │ │ └── KleinianGroup.shader.meta │ ├── KleinianGroupCircleInverse.meta │ ├── KleinianGroupCircleInverse.unity │ ├── KleinianGroupCircleInverse.unity.meta │ └── KleinianGroupCircleInverse │ │ ├── KleinianGroupCircleInverse.anim │ │ ├── KleinianGroupCircleInverse.anim.meta │ │ ├── Main Camera.controller │ │ └── Main Camera.controller.meta ├── PoissonDiskSampling.meta ├── PoissonDiskSampling │ ├── Materials.meta │ ├── Materials │ │ ├── CircleGeometry.mat │ │ ├── CircleGeometry.mat.meta │ │ ├── SphereGeometry.mat │ │ └── SphereGeometry.mat.meta │ ├── Scenes.meta │ ├── Scenes │ │ ├── PoissonDiskSampling.unity │ │ └── PoissonDiskSampling.unity.meta │ ├── Scripts.meta │ ├── Scripts │ │ ├── Example2D.cs │ │ ├── Example2D.cs.meta │ │ ├── Example3D.cs │ │ ├── Example3D.cs.meta │ │ ├── ExampleBase.cs │ │ ├── ExampleBase.cs.meta │ │ ├── FastPoissonDiskSampling2D.cs │ │ ├── FastPoissonDiskSampling2D.cs.meta │ │ ├── FastPoissonDiskSampling3D.cs │ │ └── FastPoissonDiskSampling3D.cs.meta │ ├── Shaders.meta │ └── Shaders │ │ ├── CircleGeometry.shader │ │ ├── CircleGeometry.shader.meta │ │ ├── SphereGeometry.shader │ │ └── SphereGeometry.shader.meta ├── SpaceColonization.meta ├── SpaceColonization │ ├── Materials.meta │ ├── Materials │ │ ├── Edge.mat │ │ ├── Edge.mat.meta │ │ ├── Floor.mat │ │ ├── Floor.mat.meta │ │ ├── SkinnedTubularEdge.mat │ │ ├── SkinnedTubularEdge.mat.meta │ │ ├── TubularEdge.mat │ │ └── TubularEdge.mat.meta │ ├── Models.meta │ ├── Models │ │ ├── human_male_700.controller │ │ ├── human_male_700.controller.meta │ │ ├── human_male_700@Samba Dancing.fbx │ │ ├── human_male_700@Samba Dancing.fbx.meta │ │ ├── human_male_700_100.asset │ │ └── human_male_700_100.asset.meta │ ├── Scenes.meta │ ├── Scenes │ │ ├── Line.unity │ │ ├── Line.unity.meta │ │ ├── SkinnedAnimation.unity │ │ ├── SkinnedAnimation.unity.meta │ │ ├── TubularEdge.unity │ │ └── TubularEdge.unity.meta │ ├── Scripts.meta │ ├── Scripts │ │ ├── Attraction.cs │ │ ├── Attraction.cs.meta │ │ ├── Candidate.cs │ │ ├── Candidate.cs.meta │ │ ├── Edge.cs │ │ ├── Edge.cs.meta │ │ ├── GPUHelper.cs │ │ ├── GPUHelper.cs.meta │ │ ├── Kernel.cs │ │ ├── Kernel.cs.meta │ │ ├── Node.cs │ │ ├── Node.cs.meta │ │ ├── PingPongBuffer.cs │ │ ├── PingPongBuffer.cs.meta │ │ ├── Skinned.meta │ │ ├── Skinned │ │ │ ├── SkinnedAttraction.cs │ │ │ ├── SkinnedAttraction.cs.meta │ │ │ ├── SkinnedCandidate.cs │ │ │ ├── SkinnedCandidate.cs.meta │ │ │ ├── SkinnedNode.cs │ │ │ ├── SkinnedNode.cs.meta │ │ │ ├── SkinnedSpaceColonization.cs │ │ │ └── SkinnedSpaceColonization.cs.meta │ │ ├── SpaceColonization.cs │ │ ├── SpaceColonization.cs.meta │ │ ├── VolumeSampler.meta │ │ └── VolumeSampler │ │ │ ├── Editor.meta │ │ │ ├── Editor │ │ │ ├── VolumeSamplerWindow.cs │ │ │ └── VolumeSamplerWindow.cs.meta │ │ │ ├── Volume.cs │ │ │ ├── Volume.cs.meta │ │ │ ├── VolumeSampler.cs │ │ │ ├── VolumeSampler.cs.meta │ │ │ ├── VolumeVisualizer.cs │ │ │ └── VolumeVisualizer.cs.meta │ ├── Shaders.meta │ └── Shaders │ │ ├── Common.meta │ │ ├── Common │ │ ├── Attraction.hlsl │ │ ├── Attraction.hlsl.meta │ │ ├── Candidate.hlsl │ │ ├── Candidate.hlsl.meta │ │ ├── Edge.hlsl │ │ ├── Edge.hlsl.meta │ │ ├── Geometry.hlsl │ │ ├── Geometry.hlsl.meta │ │ ├── Node.hlsl │ │ ├── Node.hlsl.meta │ │ ├── Random.hlsl │ │ ├── Random.hlsl.meta │ │ ├── SkinnedAttraction.hlsl │ │ ├── SkinnedAttraction.hlsl.meta │ │ ├── SkinnedCandidate.hlsl │ │ ├── SkinnedCandidate.hlsl.meta │ │ ├── SkinnedNode.hlsl │ │ └── SkinnedNode.hlsl.meta │ │ ├── Compute.meta │ │ ├── Compute │ │ ├── SkinnedSpaceColonization.compute │ │ ├── SkinnedSpaceColonization.compute.meta │ │ ├── SpaceColonization.compute │ │ └── SpaceColonization.compute.meta │ │ ├── Render.meta │ │ └── Render │ │ ├── Edge.shader │ │ ├── Edge.shader.meta │ │ ├── SkinnedTubularEdgeCommon.hlsl │ │ ├── SkinnedTubularEdgeCommon.hlsl.meta │ │ ├── SkinnedTubularEdgeStandard.shader │ │ ├── SkinnedTubularEdgeStandard.shader.meta │ │ ├── TubularEdge.shader │ │ └── TubularEdge.shader.meta ├── StarGlow.meta ├── StarGlow │ ├── ImageEffectBase.meta │ ├── ImageEffectBase │ │ ├── ImageEffectBase.cs │ │ ├── ImageEffectBase.cs.meta │ │ ├── ImageEffectBase.mat │ │ ├── ImageEffectBase.mat.meta │ │ ├── ImageEffectBase.shader │ │ └── ImageEffectBase.shader.meta │ ├── Sample.mat │ ├── Sample.mat.meta │ ├── Sample.unity │ ├── Sample.unity.meta │ ├── StarGlow.cs │ ├── StarGlow.cs.meta │ ├── StarGlow.mat │ ├── StarGlow.mat.meta │ ├── StarGlow.shader │ └── StarGlow.shader.meta ├── Tessellation.meta ├── Tessellation │ ├── Materials.meta │ ├── Materials │ │ ├── AddSource.mat │ │ ├── AddSource.mat.meta │ │ ├── Tessellation.mat │ │ ├── Tessellation.mat.meta │ │ ├── TessellationSurface.mat │ │ └── TessellationSurface.mat.meta │ ├── Scenes.meta │ ├── Scenes │ │ ├── FuidTessellation.unity │ │ └── FuidTessellation.unity.meta │ ├── Scripts.meta │ ├── Scripts │ │ ├── MouseSourceProvider.cs │ │ ├── MouseSourceProvider.cs.meta │ │ ├── RenderEffect.cs │ │ ├── RenderEffect.cs.meta │ │ ├── RenderUtility.cs │ │ ├── RenderUtility.cs.meta │ │ ├── Solver.cs │ │ ├── Solver.cs.meta │ │ ├── TextureProvider.cs │ │ └── TextureProvider.cs.meta │ ├── Shaders.meta │ ├── Shaders │ │ ├── AddSource.shader │ │ ├── AddSource.shader.meta │ │ ├── Solver2D.compute │ │ ├── Solver2D.compute.meta │ │ ├── Tessellation.shader │ │ ├── Tessellation.shader.meta │ │ ├── TessellationDisplacement.shader │ │ ├── TessellationDisplacement.shader.meta │ │ ├── TessellationSurface.shader │ │ └── TessellationSurface.shader.meta │ ├── Textures.meta │ └── Textures │ │ ├── diffuse.tga │ │ ├── diffuse.tga.meta │ │ ├── normal.tga │ │ └── normal.tga.meta ├── TriangulationByEarClipping.meta └── TriangulationByEarClipping │ ├── Materials.meta │ ├── Materials │ ├── TestMaterial.mat │ └── TestMaterial.mat.meta │ ├── Scenes.meta │ ├── Scenes │ ├── DrawTest.unity │ ├── DrawTest.unity.meta │ ├── TriangulationTest.unity │ └── TriangulationTest.unity.meta │ ├── Scripts.meta │ ├── Scripts │ ├── ArrayVector3.cs │ ├── ArrayVector3.cs.meta │ ├── DrawingTest.cs │ ├── DrawingTest.cs.meta │ ├── GeometryUtil.cs │ ├── GeometryUtil.cs.meta │ ├── Polygon.cs │ ├── Polygon.cs.meta │ ├── TreeNode.cs │ ├── TreeNode.cs.meta │ ├── Triangle.cs │ ├── Triangle.cs.meta │ ├── Triangulation.cs │ ├── Triangulation.cs.meta │ ├── TriangulrationTest.cs │ └── TriangulrationTest.cs.meta │ ├── Textures.meta │ └── Textures │ ├── kaiware.png │ └── kaiware.png.meta ├── Logs └── Packages-Update.log ├── Packages └── manifest.json ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityConnectSettings.asset └── VFXManager.asset └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | /[Bb]uilds/ 6 | /Assets/AssetStoreTools* 7 | 8 | # Visual Studio 2015 cache directory 9 | /.vs/ 10 | 11 | # Autogenerated VS/MD/Consulo solution and project files 12 | ExportedObj/ 13 | .consulo/ 14 | *.csproj 15 | *.unityproj 16 | *.sln 17 | *.suo 18 | *.tmp 19 | *.user 20 | *.userprefs 21 | *.pidb 22 | *.booproj 23 | *.svd 24 | *.pdb 25 | 26 | # Unity3D generated meta files 27 | *.pidb.meta 28 | 29 | # Unity3D Generated File On Crash Reports 30 | sysinfo.txt 31 | 32 | # Builds 33 | *.apk 34 | *.unitypackage 35 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49cb3aea67d78d64eb6ed586dde0c46c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Debug.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 747e15945fecb5a4785c5f9464f806ad 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Debug/DebugRenderMat.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: DebugRenderMat 11 | m_Shader: {fileID: 4800000, guid: 09e199ecb9a88614cb2cfb80dbdf7451, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 1, g: 0, b: 0, a: 0.5019608} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Debug/DebugRenderMat.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 10b45fcb15dbcc84aacdf172a9af4b96 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Debug/DebugRenderShader.shader: -------------------------------------------------------------------------------- 1 | Shader "Unlit/DebugSpringShader" 2 | { 3 | Properties 4 | { 5 | _MainTex ("Texture", 2D) = "white" {} 6 | } 7 | CGINCLUDE 8 | #include "UnityCG.cginc" 9 | 10 | struct v2g_mass 11 | { 12 | float4 vertex : POSITION; 13 | }; 14 | 15 | struct g2f_mass 16 | { 17 | float4 position : SV_POSITION; 18 | float2 uv : TEXCOORD0; 19 | }; 20 | 21 | struct springIds 22 | { 23 | int2 a; 24 | int2 b; 25 | }; 26 | 27 | struct v2g_spring 28 | { 29 | float4 vertex0 : POSITION; 30 | float4 vertex1 : TEXCOORD0; 31 | }; 32 | 33 | struct g2f_spring 34 | { 35 | float4 position : SV_POSITION; 36 | }; 37 | 38 | sampler2D _PositionTex; 39 | float4 _PositionTex_TexelSize; 40 | StructuredBuffer _SpringIdsBuffer; 41 | 42 | float4 _Color; 43 | float _ParticleSize; 44 | 45 | v2g_mass vert_mass(uint id : SV_VertexID) 46 | { 47 | v2g_mass o = (v2g_mass)0; 48 | float2 tr = _PositionTex_TexelSize.zw; 49 | float2 ts = _PositionTex_TexelSize.xy; 50 | float2 uv = float2( 51 | fmod(id, tr.x) * ts.x, 52 | floor(int(id / tr.x)) * ts.y 53 | ); 54 | float3 v = tex2Dlod(_PositionTex, float4(uv.xy, 0, 0)).xyz; 55 | o.vertex = float4(v.xyz, 1.0); 56 | return o; 57 | } 58 | 59 | // ポイントスプライトの各頂点の位置 60 | static const float3 g_positions[4] = 61 | { 62 | float3(-1, 1, 0), 63 | float3(1, 1, 0), 64 | float3(-1,-1, 0), 65 | float3(1,-1, 0), 66 | }; 67 | // 各頂点のUV座標値 68 | static const float2 g_texcoords[4] = 69 | { 70 | float2(0, 1), 71 | float2(1, 1), 72 | float2(0, 0), 73 | float2(1, 0), 74 | }; 75 | 76 | [maxvertexcount(4)] 77 | void geom_mass(point v2g_mass In[1], inout TriangleStream SpriteStream) 78 | { 79 | g2f_mass o = (g2f_mass)0; 80 | 81 | float3 vertpos = In[0].vertex.xyz; 82 | [unroll] 83 | for (int i = 0; i < 4; i++) 84 | { 85 | float3 pos = g_positions[i] * _ParticleSize; 86 | pos = mul(unity_CameraToWorld, pos) + vertpos; 87 | o.position = UnityObjectToClipPos(float4(pos, 1.0)); 88 | o.uv = g_texcoords[i]; 89 | SpriteStream.Append(o); 90 | } 91 | SpriteStream.RestartStrip(); 92 | } 93 | 94 | fixed4 frag_mass(g2f_mass i) : SV_Target 95 | { 96 | float2 diff = i.uv.xy - float2(0.5, 0.5); 97 | if (dot(diff, diff) > 0.25) 98 | discard; 99 | 100 | fixed4 col = _Color; 101 | return col; 102 | } 103 | 104 | v2g_spring vert_spring(uint id : SV_VertexID) 105 | { 106 | v2g_spring o = (v2g_spring)0; 107 | springIds ids = _SpringIdsBuffer[id]; 108 | float4 v0 = tex2Dlod(_PositionTex, float4(ids.a * _PositionTex_TexelSize.xy, 0, 0)); 109 | float4 v1 = tex2Dlod(_PositionTex, float4(ids.b * _PositionTex_TexelSize.xy, 0, 0)); 110 | o.vertex0 = UnityObjectToClipPos(v0); 111 | o.vertex1 = UnityObjectToClipPos(v1); 112 | return o; 113 | } 114 | 115 | [maxvertexcount(2)] 116 | void geom_spring(point v2g_spring points[1], inout LineStream stream) 117 | { 118 | g2f_spring o = (g2f_spring)0; 119 | 120 | float4 pos0 = points[0].vertex0; 121 | float4 pos1 = points[0].vertex1; 122 | 123 | o.position = pos0; 124 | stream.Append(o); 125 | 126 | o.position = pos1; 127 | stream.Append(o); 128 | 129 | stream.RestartStrip(); 130 | } 131 | 132 | fixed4 frag_spring(g2f_spring i) : SV_Target 133 | { 134 | fixed4 col = _Color; 135 | return col; 136 | } 137 | ENDCG 138 | 139 | SubShader 140 | { 141 | Tags{ "RenderType" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } 142 | LOD 100 143 | 144 | Blend SrcAlpha One 145 | ZWrite Off 146 | 147 | // Pass 0: Draw Mass 148 | Pass 149 | { 150 | CGPROGRAM 151 | #pragma target 5.0 152 | #pragma vertex vert_mass 153 | #pragma geometry geom_mass 154 | #pragma fragment frag_mass 155 | ENDCG 156 | } 157 | 158 | // Pass 1: Draw Spring 159 | Pass 160 | { 161 | CGPROGRAM 162 | #pragma target 5.0 163 | #pragma vertex vert_spring 164 | #pragma geometry geom_spring 165 | #pragma fragment frag_spring 166 | ENDCG 167 | } 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Debug/DebugRenderShader.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09e199ecb9a88614cb2cfb80dbdf7451 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Debug/GPUClothDebugRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 563005406440fe14daee5edfac962fec 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Debug/GPUClothSimulationDebugRender.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8aee9f840c8cbb4d862024ceeb80c55 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 858c20aa8626f4841b6a9593d283ea95 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Materials/ClothSurfaceMat.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: ClothSurfaceMat 11 | m_Shader: {fileID: 4800000, guid: 1b132cb86291bf447866944be3e69d9b, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _NormalTex: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _OcclusionMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | - _ParallaxMap: 59 | m_Texture: {fileID: 0} 60 | m_Scale: {x: 1, y: 1} 61 | m_Offset: {x: 0, y: 0} 62 | - _PositionTex: 63 | m_Texture: {fileID: 0} 64 | m_Scale: {x: 1, y: 1} 65 | m_Offset: {x: 0, y: 0} 66 | m_Floats: 67 | - _A: 1 68 | - _BumpScale: 1 69 | - _Cutoff: 0.5 70 | - _DetailNormalMapScale: 1 71 | - _DstBlend: 0 72 | - _GlossMapScale: 1 73 | - _Glossiness: 0.5 74 | - _GlossyReflections: 1 75 | - _Metallic: 0 76 | - _Mode: 0 77 | - _OcclusionStrength: 1 78 | - _Parallax: 0.02 79 | - _SmoothnessTextureChannel: 0 80 | - _SpecularHighlights: 1 81 | - _SrcBlend: 1 82 | - _UVSec: 0 83 | - _ZWrite: 1 84 | m_Colors: 85 | - _Color: {r: 0, g: 0.2726555, b: 1, a: 1} 86 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 87 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Materials/ClothSurfaceMat.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb091c92f84471b4b9a579adb3789120 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Materials/CollisionSphereMat.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: CollisionSphereMat 11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | - _SpecGlossMap: 59 | m_Texture: {fileID: 0} 60 | m_Scale: {x: 1, y: 1} 61 | m_Offset: {x: 0, y: 0} 62 | m_Floats: 63 | - _BumpScale: 1 64 | - _ColorMask: 15 65 | - _Cutoff: 0.5 66 | - _DetailNormalMapScale: 1 67 | - _DstBlend: 0 68 | - _GlossMapScale: 1 69 | - _Glossiness: 0.5 70 | - _GlossyReflections: 1 71 | - _Metallic: 0 72 | - _Mode: 0 73 | - _OcclusionStrength: 1 74 | - _Parallax: 0.02 75 | - _Shininess: 0.7 76 | - _SmoothnessTextureChannel: 0 77 | - _SpecularHighlights: 1 78 | - _SrcBlend: 1 79 | - _Stencil: 0 80 | - _StencilComp: 8 81 | - _StencilOp: 0 82 | - _StencilReadMask: 255 83 | - _StencilWriteMask: 255 84 | - _UVSec: 0 85 | - _UseUIAlphaClip: 0 86 | - _ZWrite: 1 87 | m_Colors: 88 | - _Color: {r: 1, g: 0, b: 0.03836775, a: 1} 89 | - _Emission: {r: 0, g: 0, b: 0, a: 0} 90 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 0} 91 | - _SpecColor: {r: 1, g: 1, b: 1, a: 1} 92 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Materials/CollisionSphereMat.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 04700ddf6991f994aa230e28a2a1e41a 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8c5516f84bdaea49818cc6e5338b515 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Scenes/GPUClothSimulation.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99206ce6e41ab9944ba5f131232ee4b4 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8743ace194d950843a1e5252a394015a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Scripts/ColliderTranslate.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class ColliderTranslate : MonoBehaviour 6 | { 7 | 8 | public float TranslateCenterZ = 0.0f; 9 | public float TranslateLengthZ = 4.0f; 10 | 11 | void Update() 12 | { 13 | var pos = transform.localPosition; 14 | 15 | transform.localPosition = new Vector3(pos.x, pos.y, TranslateCenterZ + Mathf.Cos(Time.time * 0.125f) * TranslateLengthZ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Scripts/ColliderTranslate.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f9fe7412582371648a925cebff39dccb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Scripts/GPUClothRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3be9dcd7e3c094047b7dc289efd91db2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Scripts/GPUClothSimulation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3fe7ce99e11d16f49985250036c30ea3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - CollideSphereTransform: {instanceID: 0} 8 | - KernelCS: {fileID: 7200000, guid: e474e34e988c3e54cac2294d0e20aa8e, type: 3} 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7f581b149072e944b9bbb721b06cd579 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Shaders/ClothSurface.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/GPUClothSimulation/ClothSurface" 2 | { 3 | Properties 4 | { 5 | _Color ("Color", Color ) = (1,1,1,1) 6 | _MainTex ("Albedo (RGB)", 2D ) = "white" {} 7 | _Glossiness ("Smoothness", Range(0,1)) = 0.5 8 | _Metallic ("Metallic", Range(0,1)) = 0.0 9 | 10 | _PositionTex ("Position Tex", 2D) = "black" {} 11 | _NormalTex ("Normal Tex", 2D) = "gray" {} 12 | 13 | } 14 | SubShader 15 | { 16 | Tags { "RenderType"="Opaque" } 17 | LOD 200 18 | 19 | Cull Off 20 | 21 | CGPROGRAM 22 | #pragma surface surf Standard fullforwardshadows vertex:vert 23 | #pragma target 3.0 24 | 25 | sampler2D _MainTex; 26 | 27 | struct Input 28 | { 29 | float2 uv_MainTex; 30 | }; 31 | 32 | half _Glossiness; 33 | half _Metallic; 34 | 35 | fixed4 _Color; 36 | 37 | sampler2D _PositionTex; // 位置データ 38 | sampler2D _NormalTex; // 法線データ 39 | 40 | void vert(inout appdata_full v) 41 | { 42 | // 位置情報を取得しセット 43 | v.vertex.xyz = tex2Dlod(_PositionTex, float4(v.texcoord.xy, 0.0, 0.0)).xyz; 44 | // 法線情報を取得しセット 45 | v.normal.xyz = tex2Dlod(_NormalTex, float4(v.texcoord.xy, 0.0, 0.0)).xyz; 46 | } 47 | 48 | void surf (Input IN, inout SurfaceOutputStandard o) 49 | { 50 | fixed4 c = tex2D (_MainTex, IN.uv_MainTex.xy) * _Color; 51 | o.Albedo = c.rgb; 52 | o.Metallic = _Metallic; 53 | o.Smoothness = _Glossiness; 54 | o.Alpha = c.a; 55 | } 56 | ENDCG 57 | } 58 | FallBack "Diffuse" 59 | } 60 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Shaders/ClothSurface.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b132cb86291bf447866944be3e69d9b 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Shaders/Kernels.compute: -------------------------------------------------------------------------------- 1 | #pragma kernel CSInit 2 | #pragma kernel CSSimulation 3 | 4 | #define NUM_THREADS_XY 32 // カーネルのスレッド数 5 | 6 | // 位置データ(1つ前のタイムステップ)読み込み用 7 | Texture2D _PositionPrevBufferRO; 8 | // 位置データ 読み込み用 9 | Texture2D _PositionBufferRO; 10 | // 位置データ(1つ前のタイムステップ)書き込み用 11 | RWTexture2D _PositionPrevBufferRW; 12 | // 位置データ 書き込み用 13 | RWTexture2D _PositionBufferRW; 14 | // 法線データ 書き込み用 15 | RWTexture2D _NormalBufferRW; 16 | 17 | int2 _ClothResolution; // 布の解像度(パーティクル数)(横, 縦) 18 | float2 _TotalClothLength; // 布の総合的な長さ 19 | 20 | float _RestLength; // バネの自然長 21 | 22 | float3 _Gravity; // 重力 23 | float _Stiffness; // 布の伸縮度合いを決定する定数 24 | float _Damp; // 布の速度の減衰率 25 | float _InverseMass; // 1.0/質量 26 | 27 | float _TimeStep; // タイムステップの大きさ 28 | 29 | bool _EnableCollideSphere; // 衝突処理を行うかのフラグ 30 | float4 _CollideSphereParams; // 衝突処理用パラメータ(pos.xyz, radius) 31 | 32 | // 近傍のパーティクルのIDオフセット(x, y)の配列 33 | static const int2 m_Directions[12] = 34 | { 35 | int2(-1, -1), // 0 36 | int2( 0, -1), // 1 37 | int2( 1, -1), // 2 38 | int2( 1, 0), // 3 39 | int2( 1, 1), // 4 40 | int2( 0, 1), // 5 41 | int2(-1, 1), // 6 42 | int2(-1, 0), // 7 43 | int2(-2, -2), // 8 44 | int2( 2, -2), // 9 45 | int2( 2, 2), // 10 46 | int2(-2, 2) // 11 47 | }; 48 | // 近傍のパーティクルのIDのオフセットを返す 49 | int2 NextNeigh(int n) 50 | { 51 | return m_Directions[n]; 52 | } 53 | 54 | // シミュレーション用バッファの初期化を行うカーネル 55 | [numthreads(NUM_THREADS_XY, NUM_THREADS_XY, 1)] 56 | void CSInit(uint3 DTid : SV_DispatchThreadID) 57 | { 58 | uint2 idx = DTid.xy; 59 | 60 | // 位置 61 | float3 pos = float3(idx.x * _RestLength, idx.y * _RestLength, 0); 62 | pos.xy -= _TotalClothLength.xy * 0.5; 63 | // 法線 64 | float3 nrm = float3(0, 0, -1); 65 | // バッファに書き込み 66 | _PositionPrevBufferRW[idx] = float4(pos.xyz, 1.0); 67 | _PositionBufferRW[idx] = float4(pos.xyz, 1.0); 68 | _NormalBufferRW[idx] = float4(nrm.xyz, 1.0); 69 | } 70 | 71 | // シミュレーションを行うカーネル 72 | [numthreads(NUM_THREADS_XY, NUM_THREADS_XY, 1)] 73 | void CSSimulation(uint2 DTid : SV_DispatchThreadID) 74 | { 75 | int2 idx = (int2)DTid.xy; 76 | // 布の解像度(パーティクル数)(横, 縦) 77 | int2 res = _ClothResolution.xy; 78 | // 位置を読み込み 79 | float3 pos = _PositionBufferRO[idx.xy].xyz; 80 | // 位置(ひとつ前のタイムステップ)の読み込み 81 | float3 posPrev = _PositionPrevBufferRO[idx.xy].xyz; 82 | // 位置とひとつ前のタイムステップの位置より, 速度を計算 83 | float3 vel = (pos - posPrev) / _TimeStep; 84 | 85 | float3 normal = (float3)0; // 法線 86 | float3 lastDiff = (float3)0; // 法線計算時に使用する方向ベクトル格納用変数 87 | float iters = 0.0; // 法線計算時のイテレーション数加算用変数 88 | 89 | // パーティクルにかかる力, 初期値として重力の値を代入 90 | float3 force = _Gravity.xyz; 91 | // 1.0 / 質量 92 | float invMass = _InverseMass; 93 | 94 | // 布の上辺であれば位置を固定するために計算しない 95 | if (idx.y == _ClothResolution.y - 1) 96 | return; 97 | 98 | // 近傍のパーティクル(12個)についての計算を行う 99 | [unroll] 100 | for (int k = 0; k < 12; k++) 101 | { 102 | // 近傍パーティクルのID(座標)のオフセット 103 | int2 neighCoord = NextNeigh(k); 104 | // X軸, 端のパーティクルについては計算しない 105 | if (((idx.x+neighCoord.x) < 0) || ((idx.x+neighCoord.x) > (res.x-1))) 106 | continue; 107 | // Y軸, 端のパーティクルについては計算しない 108 | if (((idx.y+neighCoord.y) < 0) || ((idx.y+neighCoord.y) > (res.y-1))) 109 | continue; 110 | // 近傍のパーティクルのID 111 | int2 idxNeigh = int2(idx.x + neighCoord.x, idx.y + neighCoord.y); 112 | // 近傍のパーティクルの位置 113 | float3 posNeigh = _PositionBufferRO[idxNeigh].xyz; 114 | // 近傍のパーティクルの位置の差 115 | float3 posDiff = posNeigh - pos; 116 | 117 | // 法線の計算 118 | // 基点から近傍のパーティクルへの方向ベクトル 119 | float3 currDiff = normalize(posDiff); 120 | if ((iters > 0.0) && (k < 8)) 121 | { 122 | // 1つ前に調べた近傍パーティクルとの方向ベクトルと 123 | // 現在のものの角度が鈍角であれば 124 | float a = dot(currDiff, lastDiff); 125 | if (a > 0.0) { 126 | // 外積による直行するベクトルを求めて加算 127 | normal += cross(lastDiff, currDiff); 128 | } 129 | } 130 | lastDiff = currDiff; // 次の近傍パーティクルとの計算時のために保持 131 | 132 | // 近傍パーティクルとのバネの自然長を計算 133 | float restLength = length(neighCoord * _RestLength); 134 | // バネの力を計算 135 | force += (currDiff*(length(posDiff)-restLength))*_Stiffness-vel*_Damp; 136 | // 加算 137 | if (k < 8) iters += 1.0; 138 | } 139 | // 法線ベクトルを計算 140 | normal = normalize(normal / -(iters - 1.0)); 141 | 142 | // 加速度 143 | float3 acc = (float3)0.0; 144 | // 運動の法則を適用(加速度の大きさは,力の大きさに比例し質量に反比例する) 145 | acc = force * invMass; 146 | 147 | // ベレ法による位置計算 148 | float3 tmp = pos; 149 | pos = pos * 2.0 - posPrev + acc * (_TimeStep * _TimeStep); 150 | posPrev = tmp; // ひとつ前のタイムステップの位置 151 | 152 | // 衝突を計算 153 | if (_EnableCollideSphere) 154 | { 155 | float3 center = _CollideSphereParams.xyz; // 中心位置 156 | float radius = _CollideSphereParams.w; // 半径 157 | 158 | if (length(pos - center) < radius) 159 | { 160 | // 衝突球の中心から,布のパーティクルの位置への単位ベクトルを計算 161 | float3 collDir = normalize(pos - center); 162 | // 衝突球の表面にパーティクルの位置を移動 163 | pos = center + collDir * radius; 164 | } 165 | } 166 | 167 | // 書き込み 168 | _PositionBufferRW[idx.xy] = float4(pos.xyz, 1.0); 169 | _PositionPrevBufferRW[idx.xy] = float4(posPrev.xyz, 1.0); 170 | _NormalBufferRW[idx.xy] = float4(normal.xyz, 1.0); 171 | } -------------------------------------------------------------------------------- /Assets/GPUClothSimulation/Shaders/Kernels.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e474e34e988c3e54cac2294d0e20aa8e 3 | ComputeShaderImporter: 4 | externalObjects: {} 5 | currentAPIMask: 4 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/KleinianGroup.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec625e3a547ab4b439477e10d2628e7e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/KleinianGroup/KleinianGroup.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 689b898abba0b7e4a8b0065338a92dc8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/KleinianGroup/KleinianGroup.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 36af61faac3554c47962cd3bcb4ccf5b 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/KleinianGroup/KleinianGroup/KleinianGroup.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace KleinianGroup 4 | { 5 | [ExecuteAlways] 6 | [RequireComponent(typeof(Camera))] 7 | public class KleinianGroup : MonoBehaviour 8 | { 9 | public Material material; 10 | public int pass; 11 | public Color hitColor = Color.red; 12 | public Color backColor = Color.gray; 13 | public int iteration = 500; 14 | public float scale = 1f; 15 | public Vector2 offset; 16 | public Vector4 circle = new Vector4(0,0,0,1); 17 | public Vector2 kleinUV = new Vector2(2, 0); 18 | 19 | public bool useUVAnimation; 20 | public AnimationCurve animKleinU; 21 | public AnimationCurve animKleinV; 22 | 23 | public float timeScale = 1f; 24 | 25 | float time => Time.time * timeScale; 26 | 27 | private void OnRenderImage(RenderTexture source, RenderTexture destination) 28 | { 29 | material.SetColor("_HitColor", hitColor); 30 | material.SetColor("_BackColor", backColor); 31 | material.SetInt("_Iteration", iteration); 32 | material.SetFloat("_Scale", scale); 33 | material.SetVector("_Offset", offset); 34 | material.SetVector("_Circle", circle); 35 | 36 | Vector2 uv = kleinUV; 37 | if ( useUVAnimation) 38 | { 39 | uv = new Vector2( 40 | animKleinU.Evaluate(time), 41 | animKleinV.Evaluate(time) 42 | ); 43 | } 44 | material.SetVector("_KleinUV", uv); 45 | Graphics.Blit(source, destination, material, pass); 46 | } 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /Assets/KleinianGroup/KleinianGroup/KleinianGroup.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ecb3ae2b3f6f12b40acb357552545e5b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - material: {fileID: 2100000, guid: a23c84d47049aba4ea85a0497dcedc03, type: 2} 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/KleinianGroup/KleinianGroup/KleinianGroup.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: KleinianGroup 11 | m_Shader: {fileID: 4800000, guid: a96dca26d18792b4f8f15b00ebfcad33, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Iteration: 50 67 | - _Metallic: 0 68 | - _Mode: 0 69 | - _OcclusionStrength: 1 70 | - _Parallax: 0.02 71 | - _Scale: 1.9 72 | - _SmoothnessTextureChannel: 0 73 | - _SpecularHighlights: 1 74 | - _SrcBlend: 1 75 | - _UVSec: 0 76 | - _ZWrite: 1 77 | m_Colors: 78 | - _BackColor: {r: 1, g: 0.97255427, b: 0.874, a: 1} 79 | - _Circle: {r: 0, g: 0, b: 0, a: 1} 80 | - _Color: {r: 1, g: 1, b: 1, a: 1} 81 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 82 | - _HitColor: {r: 0.0746262, g: 0.23055694, b: 0.3679245, a: 1} 83 | - _KleinUV: {r: 1.9864494, g: 0.0063085477, b: 0, a: 0} 84 | - _Offset: {r: 0, g: 0, b: 0, a: 0} 85 | -------------------------------------------------------------------------------- /Assets/KleinianGroup/KleinianGroup/KleinianGroup.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a23c84d47049aba4ea85a0497dcedc03 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/KleinianGroup/KleinianGroup/KleinianGroup.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a96dca26d18792b4f8f15b00ebfcad33 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/KleinianGroup/KleinianGroupCircleInverse.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4fa44d3a8a329634b9b19f51a038b849 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/KleinianGroup/KleinianGroupCircleInverse.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e760eac3d00dc24a8047e844cadc305 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/KleinianGroup/KleinianGroupCircleInverse/KleinianGroupCircleInverse.anim.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3beb78c74a0b4224b8ca66baaa343bca 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 7400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/KleinianGroup/KleinianGroupCircleInverse/Main Camera.controller: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!91 &9100000 4 | AnimatorController: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_Name: Main Camera 10 | serializedVersion: 5 11 | m_AnimatorParameters: [] 12 | m_AnimatorLayers: 13 | - serializedVersion: 5 14 | m_Name: Base Layer 15 | m_StateMachine: {fileID: 1107874236094656874} 16 | m_Mask: {fileID: 0} 17 | m_Motions: [] 18 | m_Behaviours: [] 19 | m_BlendingMode: 0 20 | m_SyncedLayerIndex: -1 21 | m_DefaultWeight: 0 22 | m_IKPass: 0 23 | m_SyncedLayerAffectsTiming: 0 24 | m_Controller: {fileID: 9100000} 25 | --- !u!1102 &1102837906447294894 26 | AnimatorState: 27 | serializedVersion: 5 28 | m_ObjectHideFlags: 1 29 | m_CorrespondingSourceObject: {fileID: 0} 30 | m_PrefabInstance: {fileID: 0} 31 | m_PrefabAsset: {fileID: 0} 32 | m_Name: KleinianGroupCircleInverse 33 | m_Speed: 1 34 | m_CycleOffset: 0 35 | m_Transitions: [] 36 | m_StateMachineBehaviours: [] 37 | m_Position: {x: 50, y: 50, z: 0} 38 | m_IKOnFeet: 0 39 | m_WriteDefaultValues: 1 40 | m_Mirror: 0 41 | m_SpeedParameterActive: 0 42 | m_MirrorParameterActive: 0 43 | m_CycleOffsetParameterActive: 0 44 | m_TimeParameterActive: 0 45 | m_Motion: {fileID: 7400000, guid: 3beb78c74a0b4224b8ca66baaa343bca, type: 2} 46 | m_Tag: 47 | m_SpeedParameter: 48 | m_MirrorParameter: 49 | m_CycleOffsetParameter: 50 | m_TimeParameter: 51 | --- !u!1107 &1107874236094656874 52 | AnimatorStateMachine: 53 | serializedVersion: 5 54 | m_ObjectHideFlags: 1 55 | m_CorrespondingSourceObject: {fileID: 0} 56 | m_PrefabInstance: {fileID: 0} 57 | m_PrefabAsset: {fileID: 0} 58 | m_Name: Base Layer 59 | m_ChildStates: 60 | - serializedVersion: 1 61 | m_State: {fileID: 1102837906447294894} 62 | m_Position: {x: 200, y: 0, z: 0} 63 | m_ChildStateMachines: [] 64 | m_AnyStateTransitions: [] 65 | m_EntryTransitions: [] 66 | m_StateMachineTransitions: {} 67 | m_StateMachineBehaviours: [] 68 | m_AnyStatePosition: {x: 50, y: 20, z: 0} 69 | m_EntryPosition: {x: 50, y: 120, z: 0} 70 | m_ExitPosition: {x: 800, y: 120, z: 0} 71 | m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} 72 | m_DefaultState: {fileID: 1102837906447294894} 73 | -------------------------------------------------------------------------------- /Assets/KleinianGroup/KleinianGroupCircleInverse/Main Camera.controller.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d733206916c3da949bacde39c245943d 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 9100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ce8d8bac5704354c9795de11b77614e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9def18a939072914fb3a9620c776507b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Materials/CircleGeometry.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: CircleGeometry 11 | m_Shader: {fileID: 4800000, guid: 810972addea1cf94b9c09314c1af36a9, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 1, g: 1, b: 1, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Materials/CircleGeometry.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 96425c5d3353cbb458e3eb7bd92a05ae 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Materials/SphereGeometry.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: SphereGeometry 11 | m_Shader: {fileID: 4800000, guid: 709281758598ad74b9de4060cd4f4c4c, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 1, g: 1, b: 1, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Materials/SphereGeometry.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d45fe5303c49a2f45b39934e24fbf31e 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 762f81734eea12c458e0f1c369e3b7da 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Scenes/PoissonDiskSampling.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc61c9a7c7224ef4b8dcbd57ccd0c457 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c9fee29542db8a49ade31a5f75dbe75 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Scripts/Example2D.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | using System; 4 | using System.Runtime.InteropServices; 5 | 6 | namespace PoissonDiskSampling 7 | { 8 | [AddComponentMenu("")] 9 | public class Example2D : ExampleBase 10 | { 11 | protected override Func GetLooper() 12 | => FastPoissonDiskSampling2D.StepSampling(this.bottomLeftBack, this.topRightForward, this.minimumDistance, this.iterationPerPoint, out this.points); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Scripts/Example2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3944dbe073878b74da7defe3b2370ff6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Scripts/Example3D.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Runtime.InteropServices; 5 | using UnityEngine; 6 | 7 | namespace PoissonDiskSampling 8 | { 9 | [AddComponentMenu("")] 10 | public class Example3D : ExampleBase 11 | { 12 | protected override Func GetLooper() 13 | => FastPoissonDiskSampling3D.StepSampling(this.bottomLeftBack, this.topRightForward, this.minimumDistance, this.iterationPerPoint, out this.points); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Scripts/Example3D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 65e182676b5d2f94998e847a737af791 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Scripts/ExampleBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Runtime.InteropServices; 5 | using UnityEngine; 6 | 7 | namespace PoissonDiskSampling 8 | { 9 | public abstract class ExampleBase : MonoBehaviour where T : struct 10 | { 11 | public const int MaxPoint = 50000; 12 | 13 | [Header("For Sampling")] 14 | [SerializeField] 15 | protected T bottomLeftBack = default; 16 | [SerializeField] 17 | protected T topRightForward = default; 18 | [SerializeField] 19 | protected float minimumDistance = 10f; 20 | [SerializeField] 21 | protected int iterationPerPoint = 30; 22 | 23 | [Header("For Viewing")] 24 | [SerializeField] 25 | protected float delay = 0.01f; 26 | [SerializeField] 27 | protected Material geometryMaterial = null; 28 | [SerializeField] 29 | protected float radiusRate = 0.5f; 30 | 31 | protected List points = new List(); 32 | protected ComputeBuffer buffer = null; 33 | 34 | 35 | protected virtual void Awake() 36 | { 37 | this.buffer = new ComputeBuffer(MaxPoint, Marshal.SizeOf(typeof(T)), ComputeBufferType.Default); 38 | StartCoroutine(this.Loop()); 39 | } 40 | 41 | protected virtual IEnumerator Loop() 42 | { 43 | var looper = this.GetLooper(); 44 | var result = true; 45 | 46 | do 47 | { 48 | yield return new WaitForSeconds(this.delay); 49 | result = looper(); 50 | } 51 | while(result == true); 52 | } 53 | 54 | protected abstract Func GetLooper(); 55 | 56 | protected virtual void OnDestroy() 57 | { 58 | this.buffer?.Dispose(); 59 | } 60 | 61 | protected virtual void OnRenderObject() 62 | { 63 | this.buffer.SetData(this.points); 64 | this.geometryMaterial.SetBuffer("_Points", this.buffer); 65 | this.geometryMaterial.SetFloat("_Radius", this.minimumDistance * this.radiusRate * 0.5f); 66 | 67 | this.geometryMaterial.SetPass(0); 68 | Graphics.DrawProcedural(MeshTopology.Points, this.points.Count, 1); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Scripts/ExampleBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a410b7fab44b34849a8bae85e5ba8113 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Scripts/FastPoissonDiskSampling2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: afa720f782ff0424b93e8f18d8dd7ea6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Scripts/FastPoissonDiskSampling3D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 31c71424ede78374882098b2b86f1b86 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5b4fd797f2414d449630a490c30bcbc 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Shaders/CircleGeometry.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/CircleGeometry" 2 | { 3 | Properties 4 | { 5 | _Color("Color", Color) = (1.0, 1.0, 1.0, 1.0) 6 | } 7 | SubShader 8 | { 9 | Tags { "RenderType"="Opaque" } 10 | LOD 100 11 | 12 | Pass 13 | { 14 | CGPROGRAM 15 | #pragma vertex vert 16 | #pragma geometry geom 17 | #pragma fragment frag 18 | 19 | #include "UnityCG.cginc" 20 | 21 | struct v2g 22 | { 23 | uint id : ANY; 24 | }; 25 | 26 | struct g2f 27 | { 28 | float4 pos : SV_POSITION; 29 | }; 30 | 31 | #define PHI_COUNT 45 32 | #define STEP_PHI (UNITY_TWO_PI / PHI_COUNT) 33 | 34 | uniform float4 _Color; 35 | uniform float _Radius; 36 | uniform Buffer _Points; 37 | 38 | v2g vert (uint id : SV_VertexID) 39 | { 40 | v2g o; 41 | o.id = id; 42 | return o; 43 | } 44 | 45 | float4 getPos(float3 center, float radius, float phi) 46 | { 47 | return mul(UNITY_MATRIX_VP, float4(center + radius * float3(cos(phi), 0.0, sin(phi)), 1.0f)); 48 | } 49 | 50 | [maxvertexcount(256)] 51 | void geom(point v2g input[1], inout TriangleStream outStream) 52 | { 53 | v2g data = input[0]; 54 | g2f output[PHI_COUNT + 1]; 55 | 56 | float radius = _Radius; 57 | float3 center = float3(_Points[data.id].x, 0.0, _Points[data.id].y); 58 | output[0].pos = mul(UNITY_MATRIX_VP, float4(center.xyz, 1.0)); 59 | 60 | // Vertices. 61 | [unroll] 62 | for (int i = 0; i < PHI_COUNT; i++) 63 | { 64 | output[i + 1].pos = getPos(center, radius, STEP_PHI * i); 65 | } 66 | 67 | // Triangles. 68 | [unroll] 69 | for (i = 1; i <= PHI_COUNT; i++) 70 | { 71 | int next = i + 1 > PHI_COUNT ? 1 : i + 1; 72 | 73 | outStream.Append(output[0]); 74 | outStream.Append(output[next]); 75 | outStream.Append(output[i]); 76 | 77 | outStream.RestartStrip(); 78 | } 79 | } 80 | 81 | fixed4 frag (g2f i) : SV_Target 82 | { 83 | return _Color; 84 | } 85 | ENDCG 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Shaders/CircleGeometry.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 810972addea1cf94b9c09314c1af36a9 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Shaders/SphereGeometry.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/SphereGeometry" 2 | { 3 | Properties 4 | { 5 | _Color("Color", Color) = (1.0, 1.0, 1.0, 1.0) 6 | } 7 | SubShader 8 | { 9 | Tags { "RenderType"="Opaque" } 10 | LOD 100 11 | 12 | Pass 13 | { 14 | CGPROGRAM 15 | #pragma vertex vert 16 | #pragma geometry geom 17 | #pragma fragment frag 18 | 19 | #include "UnityCG.cginc" 20 | 21 | struct v2g 22 | { 23 | uint id : ANY; 24 | }; 25 | 26 | struct g2f 27 | { 28 | float4 pos : SV_POSITION; 29 | }; 30 | 31 | #define THETA_COUNT 7 32 | #define PHI_COUNT 15 33 | 34 | #define STEP_THETA (UNITY_PI / (THETA_COUNT + 1)) 35 | #define STEP_PHI (UNITY_TWO_PI / PHI_COUNT) 36 | 37 | #define VERTEX_COUNT (THETA_COUNT * PHI_COUNT + 2) 38 | 39 | uniform float4 _Color; 40 | uniform float _Radius; 41 | uniform Buffer _Points; 42 | 43 | v2g vert (uint id : SV_VertexID) 44 | { 45 | v2g o; 46 | o.id = id; 47 | return o; 48 | } 49 | 50 | float3 getCoordinates(float theta, float phi) 51 | { 52 | return float3( 53 | sin(theta) * cos(phi), 54 | cos(theta), 55 | sin(theta) * sin(phi) 56 | ); 57 | } 58 | 59 | float4 getPos(float3 center, float radius, float theta, float phi) 60 | { 61 | return mul(UNITY_MATRIX_VP, float4(center + radius * getCoordinates(theta, phi), 1.0f)); 62 | } 63 | 64 | [maxvertexcount(256)] 65 | void geom(point v2g input[1], inout TriangleStream outStream) 66 | { 67 | v2g data = input[0]; 68 | g2f output[VERTEX_COUNT]; 69 | 70 | float radius = _Radius; 71 | float3 center = _Points[data.id]; 72 | output[0].pos = mul(UNITY_MATRIX_VP, float4(center.xyz, 1.0)); 73 | 74 | // Vertices. 75 | int id = 0; 76 | output[id++].pos = getPos(center, radius, 0.0f, 0.0f); 77 | 78 | [unroll] 79 | for (int i = 1; i <= THETA_COUNT; i++) 80 | { 81 | float theta = STEP_THETA * i; 82 | [unroll] 83 | for (int j = 0; j < PHI_COUNT; j++) 84 | { 85 | output[id++].pos = getPos(center, radius, theta, STEP_PHI * j); 86 | } 87 | } 88 | 89 | output[id++].pos = getPos(center, radius, UNITY_PI, 0.0f); 90 | 91 | // Triangles. 92 | for (i = 1; i <= PHI_COUNT; i++) 93 | { 94 | outStream.Append(output[0]); 95 | 96 | for (int j = 0; j < THETA_COUNT; j++) 97 | { 98 | int index = j * PHI_COUNT + i; 99 | int next = index + 1; 100 | 101 | next = next - PHI_COUNT * min(max(next - PHI_COUNT * (j + 1), 0), 1); 102 | 103 | outStream.Append(output[next]); 104 | outStream.Append(output[index]); 105 | } 106 | 107 | outStream.Append(output[VERTEX_COUNT - 1]); 108 | outStream.RestartStrip(); 109 | } 110 | } 111 | 112 | fixed4 frag (g2f i) : SV_Target 113 | { 114 | return _Color; 115 | } 116 | ENDCG 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /Assets/PoissonDiskSampling/Shaders/SphereGeometry.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 709281758598ad74b9de4060cd4f4c4c 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SpaceColonization.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 57c90a68f39e64741a3d619f39f7cbe2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2b7e0c1f7e14aa14587b6f91f795d621 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Materials/Edge.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Edge 11 | m_Shader: {fileID: 4800000, guid: 7f0b1817b5ef95b44bb44ee2a4dec420, type: 3} 12 | m_ShaderKeywords: _ANIMATION_ON 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _Animation: 1 60 | - _BumpScale: 1 61 | - _Cutoff: 0.5 62 | - _DetailNormalMapScale: 1 63 | - _DstBlend: 0 64 | - _GlossMapScale: 1 65 | - _Glossiness: 0.5 66 | - _GlossyReflections: 1 67 | - _Metallic: 0 68 | - _Mode: 0 69 | - _OcclusionStrength: 1 70 | - _Parallax: 0.02 71 | - _SmoothnessTextureChannel: 0 72 | - _SpecularHighlights: 1 73 | - _SrcBlend: 1 74 | - _UVSec: 0 75 | - _ZWrite: 1 76 | m_Colors: 77 | - _Color: {r: 1, g: 1, b: 1, a: 1} 78 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 79 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Materials/Edge.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 284e7dc2f7c81d5479850cf34c7e6e1f 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Materials/Floor.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Floor 11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.43 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 0.8679245, g: 0.8679245, b: 0.8679245, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Materials/Floor.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ba874246e894d6642911a376669598cb 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Materials/SkinnedTubularEdge.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: SkinnedTubularEdge 11 | m_Shader: {fileID: 4800000, guid: c78dc1c3ff175c540ae3d6009d463e52, type: 3} 12 | m_ShaderKeywords: _ANIMATION_ON 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 1 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _Animation: 1 60 | - _BumpScale: 1 61 | - _Cutoff: 0.5 62 | - _DetailNormalMapScale: 1 63 | - _DstBlend: 0 64 | - _GlossMapScale: 1 65 | - _Glossiness: 0.5 66 | - _GlossyReflections: 1 67 | - _Metallic: 0.146 68 | - _Mode: 0 69 | - _OcclusionStrength: 1 70 | - _Parallax: 0.02 71 | - _SmoothnessTextureChannel: 0 72 | - _SpecularHighlights: 1 73 | - _SrcBlend: 1 74 | - _Thickness: 0.01 75 | - _UVSec: 0 76 | - _ZWrite: 1 77 | m_Colors: 78 | - _Color: {r: 0.7264151, g: 0.7264151, b: 0.7264151, a: 1} 79 | - _Emission: {r: 2, g: 2, b: 2, a: 1} 80 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 81 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Materials/SkinnedTubularEdge.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e1c34b59c7739144ad5202cc87b53df 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Materials/TubularEdge.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: TubularEdge 11 | m_Shader: {fileID: 4800000, guid: c2576b03b6d2e3f49ad758e19e610a36, type: 3} 12 | m_ShaderKeywords: _ANIMATION_ON 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _Animation: 1 60 | - _BumpScale: 1 61 | - _Cutoff: 0.5 62 | - _DetailNormalMapScale: 1 63 | - _DstBlend: 0 64 | - _GlossMapScale: 1 65 | - _Glossiness: 0.5 66 | - _GlossyReflections: 1 67 | - _Metallic: 0 68 | - _Mode: 0 69 | - _OcclusionStrength: 1 70 | - _Parallax: 0.02 71 | - _SmoothnessTextureChannel: 0 72 | - _SpecularHighlights: 1 73 | - _SrcBlend: 1 74 | - _Thickness: 0.033 75 | - _UVSec: 0 76 | - _ZWrite: 1 77 | m_Colors: 78 | - _Color: {r: 1, g: 1, b: 1, a: 1} 79 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 80 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Materials/TubularEdge.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b2514d1f7cf380a4290e5177882cdba9 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Models.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 336726bfdb901544f92fbbb0e264ed34 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Models/human_male_700.controller: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!91 &9100000 4 | AnimatorController: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_Name: human_male_700 10 | serializedVersion: 5 11 | m_AnimatorParameters: [] 12 | m_AnimatorLayers: 13 | - serializedVersion: 5 14 | m_Name: Base Layer 15 | m_StateMachine: {fileID: 1107319615709022410} 16 | m_Mask: {fileID: 0} 17 | m_Motions: [] 18 | m_Behaviours: [] 19 | m_BlendingMode: 0 20 | m_SyncedLayerIndex: -1 21 | m_DefaultWeight: 0 22 | m_IKPass: 0 23 | m_SyncedLayerAffectsTiming: 0 24 | m_Controller: {fileID: 9100000} 25 | --- !u!1101 &1101659585629861856 26 | AnimatorStateTransition: 27 | m_ObjectHideFlags: 1 28 | m_CorrespondingSourceObject: {fileID: 0} 29 | m_PrefabInstance: {fileID: 0} 30 | m_PrefabAsset: {fileID: 0} 31 | m_Name: 32 | m_Conditions: [] 33 | m_DstStateMachine: {fileID: 0} 34 | m_DstState: {fileID: 1102533228640490352} 35 | m_Solo: 0 36 | m_Mute: 0 37 | m_IsExit: 0 38 | serializedVersion: 3 39 | m_TransitionDuration: 10.088146 40 | m_TransitionOffset: 0 41 | m_ExitTime: 0.86017674 42 | m_HasExitTime: 1 43 | m_HasFixedDuration: 1 44 | m_InterruptionSource: 0 45 | m_OrderedInterruption: 1 46 | m_CanTransitionToSelf: 1 47 | --- !u!1102 &1102533228640490352 48 | AnimatorState: 49 | serializedVersion: 5 50 | m_ObjectHideFlags: 1 51 | m_CorrespondingSourceObject: {fileID: 0} 52 | m_PrefabInstance: {fileID: 0} 53 | m_PrefabAsset: {fileID: 0} 54 | m_Name: Samba Dancing 55 | m_Speed: 0.35 56 | m_CycleOffset: 0 57 | m_Transitions: 58 | - {fileID: 1101659585629861856} 59 | m_StateMachineBehaviours: [] 60 | m_Position: {x: 50, y: 50, z: 0} 61 | m_IKOnFeet: 0 62 | m_WriteDefaultValues: 1 63 | m_Mirror: 0 64 | m_SpeedParameterActive: 0 65 | m_MirrorParameterActive: 0 66 | m_CycleOffsetParameterActive: 0 67 | m_TimeParameterActive: 0 68 | m_Motion: {fileID: 7400000, guid: 13da760a15a71db4886bc3caf1a0931c, type: 3} 69 | m_Tag: 70 | m_SpeedParameter: 71 | m_MirrorParameter: 72 | m_CycleOffsetParameter: 73 | m_TimeParameter: 74 | --- !u!1107 &1107319615709022410 75 | AnimatorStateMachine: 76 | serializedVersion: 5 77 | m_ObjectHideFlags: 1 78 | m_CorrespondingSourceObject: {fileID: 0} 79 | m_PrefabInstance: {fileID: 0} 80 | m_PrefabAsset: {fileID: 0} 81 | m_Name: Base Layer 82 | m_ChildStates: 83 | - serializedVersion: 1 84 | m_State: {fileID: 1102533228640490352} 85 | m_Position: {x: 24, y: 192, z: 0} 86 | m_ChildStateMachines: [] 87 | m_AnyStateTransitions: [] 88 | m_EntryTransitions: [] 89 | m_StateMachineTransitions: {} 90 | m_StateMachineBehaviours: [] 91 | m_AnyStatePosition: {x: 50, y: 20, z: 0} 92 | m_EntryPosition: {x: 50, y: 120, z: 0} 93 | m_ExitPosition: {x: 800, y: 120, z: 0} 94 | m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} 95 | m_DefaultState: {fileID: 1102533228640490352} 96 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Models/human_male_700.controller.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19d77099504d8084fb0683c85fef9f31 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 9100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Models/human_male_700@Samba Dancing.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndieVisualLab/UnityGraphicsProgramming4/dd6822e22acb96118385f92a66eb7a285f2fae76/Assets/SpaceColonization/Models/human_male_700@Samba Dancing.fbx -------------------------------------------------------------------------------- /Assets/SpaceColonization/Models/human_male_700_100.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 84ec302fbf7e45a4699d6a920bdf5838 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ab32cd66dd6c0b409ea906f51db4ea4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scenes/Line.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d2741ffcb71d3cd4288843b8143232b8 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scenes/SkinnedAnimation.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df0b47d2bc6677542a00d2a66aab7971 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scenes/TubularEdge.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 68732794a2a34cf469b57d9b9450f49b 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 527d6e5ba5c585a4cb44c0e987a5feb4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/Attraction.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | 5 | using UnityEngine; 6 | 7 | namespace SpaceColonization 8 | { 9 | 10 | [StructLayout (LayoutKind.Sequential)] 11 | public struct Attraction { 12 | public Vector3 position; 13 | public int nearest; 14 | public uint found; 15 | public uint active; 16 | } 17 | 18 | } 19 | 20 | 21 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/Attraction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db39395e921f13249b8b4a6e372090f4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/Candidate.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | 5 | using UnityEngine; 6 | 7 | namespace SpaceColonization 8 | { 9 | 10 | [StructLayout (LayoutKind.Sequential)] 11 | public struct Candidate 12 | { 13 | public Vector3 position; 14 | public int node; 15 | } 16 | 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/Candidate.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5fde4bf9a07c6de488ca20207c0ce81e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/Edge.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | 5 | using UnityEngine; 6 | 7 | namespace SpaceColonization 8 | { 9 | 10 | [StructLayout (LayoutKind.Sequential)] 11 | public struct Edge { 12 | public int a, b; 13 | } 14 | 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/Edge.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 66ccd5e31bbca8c4a8dd619c6af87f9f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/GPUHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public static class GPUHelper { 6 | 7 | public static void Dispatch1D(ComputeShader compute, Kernel kernel, int count) 8 | { 9 | compute.Dispatch(kernel.Index, GetKernelBlock(count, (int)kernel.ThreadX), 1, 1); 10 | } 11 | 12 | public static void Dispatch2D(ComputeShader compute, Kernel kernel, int width, int height) 13 | { 14 | uint tx, ty, tz; 15 | compute.GetKernelThreadGroupSizes(kernel.Index, out tx, out ty, out tz); 16 | compute.Dispatch(kernel.Index, GetKernelBlock(width, (int)kernel.ThreadX), GetKernelBlock(height, (int)kernel.ThreadY), 1); 17 | } 18 | 19 | public static void Dispatch3D(ComputeShader compute, Kernel kernel, int width, int height, int depth) 20 | { 21 | uint tx, ty, tz; 22 | compute.GetKernelThreadGroupSizes(kernel.Index, out tx, out ty, out tz); 23 | compute.Dispatch(kernel.Index, GetKernelBlock(width, (int)kernel.ThreadX), GetKernelBlock(height, (int)kernel.ThreadY), GetKernelBlock(depth, (int)kernel.ThreadZ)); 24 | } 25 | 26 | public static void Dispatch1D(ComputeShader compute, int kernel, int count) 27 | { 28 | uint tx, ty, tz; 29 | compute.GetKernelThreadGroupSizes(kernel, out tx, out ty, out tz); 30 | compute.Dispatch(kernel, GetKernelBlock(count, (int)tx), (int)ty, (int)tz); 31 | } 32 | 33 | public static void Dispatch2D(ComputeShader compute, int kernel, int width, int height) 34 | { 35 | uint tx, ty, tz; 36 | compute.GetKernelThreadGroupSizes(kernel, out tx, out ty, out tz); 37 | compute.Dispatch(kernel, GetKernelBlock(width, (int)tx), GetKernelBlock(height, (int)ty), 1); 38 | } 39 | 40 | public static void Dispatch3D(ComputeShader compute, int kernel, int width, int height, int depth) 41 | { 42 | uint tx, ty, tz; 43 | compute.GetKernelThreadGroupSizes(kernel, out tx, out ty, out tz); 44 | compute.Dispatch(kernel, GetKernelBlock(width, (int)tx), GetKernelBlock(height, (int)ty), GetKernelBlock(depth, (int)tz)); 45 | } 46 | 47 | static int GetKernelBlock(int count, int blockSize) 48 | { 49 | return (count + blockSize - 1) / blockSize; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/GPUHelper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dfef7a9f16b098241b7662b2d7b2543a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/Kernel.cs: -------------------------------------------------------------------------------- 1 |  2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | public class Kernel 7 | { 8 | public int Index { get { return index; } } 9 | public uint ThreadX { get { return threadX; } } 10 | public uint ThreadY { get { return threadY; } } 11 | public uint ThreadZ { get { return threadZ; } } 12 | 13 | int index; 14 | uint threadX, threadY, threadZ; 15 | 16 | public Kernel(ComputeShader shader, string key) 17 | { 18 | index = shader.FindKernel(key); 19 | if (index < 0) 20 | { 21 | Debug.LogWarning("Can't find kernel"); 22 | return; 23 | } 24 | shader.GetKernelThreadGroupSizes(index, out threadX, out threadY, out threadZ); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/Kernel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 022dccdabb3a59e4389235df1dca76b4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/Node.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | 5 | using UnityEngine; 6 | 7 | namespace SpaceColonization 8 | { 9 | 10 | [StructLayout (LayoutKind.Sequential)] 11 | public struct Node { 12 | public Vector3 position; 13 | public float t; 14 | public float offset; 15 | public float mass; 16 | public int from; 17 | public uint active; 18 | } 19 | 20 | } 21 | 22 | 23 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/Node.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c3f20d5e1beb2a7429f7407bded750f8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/PingPongBuffer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Runtime.InteropServices; 5 | 6 | using UnityEngine; 7 | 8 | public class PingPongBuffer : System.IDisposable { 9 | 10 | protected ComputeBuffer buffer0, buffer1; 11 | 12 | public ComputeBuffer Read { get { return buffer0; } } 13 | public ComputeBuffer Write { get { return buffer1; } } 14 | 15 | public PingPongBuffer(int count, int stride, ComputeBufferType type = ComputeBufferType.Default) 16 | { 17 | buffer0 = new ComputeBuffer(count, stride, type); 18 | buffer1 = new ComputeBuffer(count, stride, type); 19 | } 20 | 21 | public void SetData(Array data) 22 | { 23 | buffer0.SetData(data); 24 | buffer1.SetData(data); 25 | } 26 | 27 | public void SetCounterValue(uint counter) 28 | { 29 | buffer0.SetCounterValue(counter); 30 | buffer1.SetCounterValue(counter); 31 | } 32 | 33 | public void Swap() 34 | { 35 | var tmp = buffer0; 36 | buffer0 = buffer1; 37 | buffer1 = tmp; 38 | } 39 | 40 | public void Dispose() 41 | { 42 | buffer0.Dispose(); 43 | buffer1.Dispose(); 44 | } 45 | 46 | public static implicit operator ComputeBuffer(PingPongBuffer buf) 47 | { 48 | return buf.Read; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/PingPongBuffer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 057c719b815a9804eb93724cff692442 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/Skinned.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a82a0bbf8413c64c8b4a665215e069d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/Skinned/SkinnedAttraction.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | 5 | using UnityEngine; 6 | 7 | namespace SpaceColonization 8 | { 9 | 10 | [StructLayout (LayoutKind.Sequential)] 11 | public struct SkinnedAttraction { 12 | public Vector3 position; 13 | public int bone; 14 | public int nearest; 15 | public uint found; 16 | public uint active; 17 | } 18 | 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/Skinned/SkinnedAttraction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e19b298fe22fe55468ff3c2d4e6795cd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/Skinned/SkinnedCandidate.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | 5 | using UnityEngine; 6 | 7 | namespace SpaceColonization 8 | { 9 | 10 | [StructLayout (LayoutKind.Sequential)] 11 | public struct SkinnedCandidate 12 | { 13 | public Vector3 position; 14 | public int node; 15 | public int bone; 16 | } 17 | 18 | } 19 | 20 | 21 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/Skinned/SkinnedCandidate.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 083cff9bb49a5704393130e8d1b42fc6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/Skinned/SkinnedNode.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | 5 | using UnityEngine; 6 | 7 | namespace SpaceColonization 8 | { 9 | 10 | [StructLayout (LayoutKind.Sequential)] 11 | public struct SkinnedNode { 12 | public Vector3 position; 13 | public Vector3 animated; 14 | public int index0; 15 | public float t; 16 | public float offset; 17 | public float mass; 18 | public int from; 19 | public uint active; 20 | } 21 | 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/Skinned/SkinnedNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33ace16d0ddcb0d47a945ac6a0a9eb8a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/Skinned/SkinnedSpaceColonization.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc7d7bc289b6d7d46a772569090e7287 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - compute: {fileID: 7200000, guid: 13deb82e849713f49a0ff696b6ce14ee, type: 3} 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/SpaceColonization.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9389e2d01f6cfb44e9b73fc4c5aac10c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - compute: {fileID: 7200000, guid: 13deb82e849713f49a0ff696b6ce14ee, type: 3} 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/VolumeSampler.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49e654fc695de9048aea74de4bcd1b48 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/VolumeSampler/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 64ee3f63b505ce146bee884919247a1c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/VolumeSampler/Editor/VolumeSamplerWindow.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | using UnityEngine; 6 | using UnityEditor; 7 | 8 | namespace SpaceColonization.VolumeSampler 9 | { 10 | 11 | public class VolumeSamplerWindow : EditorWindow 12 | { 13 | 14 | protected string path = "Assets/Volume.asset"; 15 | protected int resolution = 16; 16 | protected float radius = 1f; 17 | Object mesh; 18 | 19 | [MenuItem("Window/VolumeSampler")] 20 | static void Init() 21 | { 22 | var window = EditorWindow.GetWindow(typeof(VolumeSamplerWindow)); 23 | window.Show(); 24 | } 25 | 26 | protected void OnGUI() 27 | { 28 | const float headerSize = 120f; 29 | 30 | using (new EditorGUILayout.HorizontalScope()) 31 | { 32 | GUILayout.Label("Source mesh file", GUILayout.Width(headerSize)); 33 | mesh = EditorGUILayout.ObjectField(mesh, typeof(Mesh), true); 34 | } 35 | 36 | using (new EditorGUILayout.HorizontalScope()) 37 | { 38 | GUILayout.Label("Grid resolution", GUILayout.Width(headerSize)); 39 | resolution = EditorGUILayout.IntField(resolution); 40 | } 41 | 42 | using (new EditorGUILayout.HorizontalScope()) 43 | { 44 | GUILayout.Label("Sample distance", GUILayout.Width(headerSize)); 45 | radius = EditorGUILayout.FloatField(radius); 46 | } 47 | 48 | using (new EditorGUILayout.HorizontalScope()) 49 | { 50 | GUILayout.Label("Output path", GUILayout.Width(headerSize)); 51 | path = EditorGUILayout.TextField(path); 52 | } 53 | 54 | GUI.enabled = (mesh != null); 55 | if (GUILayout.Button("Build")) 56 | { 57 | Build(mesh as Mesh, path, resolution, radius); 58 | } 59 | } 60 | 61 | protected void Build( 62 | Mesh mesh, 63 | string path, 64 | int resolution, float radius 65 | ) 66 | { 67 | var volume = VolumeSampler.Sample(mesh, resolution, radius); 68 | AssetDatabase.CreateAsset(volume, path); 69 | AssetDatabase.SaveAssets(); 70 | AssetDatabase.Refresh(); 71 | } 72 | 73 | } 74 | 75 | } 76 | 77 | 78 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/VolumeSampler/Editor/VolumeSamplerWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 899ec8239ded4024daa6ec9f22f158a5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/VolumeSampler/Volume.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace SpaceColonization.VolumeSampler 6 | { 7 | 8 | public class Volume : ScriptableObject 9 | { 10 | 11 | public List Points { get { return points; } } 12 | public int Width { get { return width; } } 13 | public int Height { get { return height; } } 14 | public int Depth { get { return depth; } } 15 | public float UnitLength { get { return unitLength; } } 16 | 17 | [SerializeField] protected int width, height, depth; 18 | [SerializeField] protected float unitLength; 19 | [SerializeField] protected List points; 20 | 21 | public void Initialize(int w, int h, int d, float u, List pts) 22 | { 23 | width = w; 24 | height = h; 25 | depth = d; 26 | unitLength = u; 27 | points = pts; 28 | } 29 | 30 | } 31 | 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/VolumeSampler/Volume.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 96fb4416e3a3edb478f3e89dbd592fdb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/VolumeSampler/VolumeSampler.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a655603d3f2417246a8897202de5a8cb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/VolumeSampler/VolumeVisualizer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace SpaceColonization.VolumeSampler 6 | { 7 | 8 | public class VolumeVisualizer : MonoBehaviour 9 | { 10 | 11 | [SerializeField] protected Volume volume; 12 | 13 | protected void OnDrawGizmos() 14 | { 15 | if (volume == null) return; 16 | 17 | Gizmos.matrix = transform.localToWorldMatrix; 18 | volume.Points.ForEach(p => 19 | { 20 | Gizmos.DrawWireSphere(p, volume.UnitLength * 0.1f); 21 | }); 22 | } 23 | 24 | } 25 | 26 | } 27 | 28 | 29 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Scripts/VolumeSampler/VolumeVisualizer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e99932d727d25941ab3fb8d6f437747 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1609631658296de4b9184441b8d2d1f2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6bae516437ada0f44bfdbcaf0e767e61 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common/Attraction.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef __ATTRACTION_INCLUDED__ 2 | #define __ATTRACTION_INCLUDED__ 3 | 4 | struct Attraction 5 | { 6 | float3 position; 7 | uint nearest; 8 | bool found; 9 | bool active; 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common/Attraction.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6bcf6105119ed20448dc248a4bd9a933 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common/Candidate.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef __CANDIDATE_INCLUDED__ 2 | #define __CANDIDATE_INCLUDED__ 3 | 4 | struct Candidate 5 | { 6 | float3 position; 7 | uint node; 8 | }; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common/Candidate.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87c965be907d809478737a85d5809729 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common/Edge.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef __EDGE_INCLUDED__ 2 | #define __EDGE_INCLUDED__ 3 | 4 | struct Edge 5 | { 6 | int a, b; 7 | }; 8 | 9 | #endif // __EDGE_INCLUDED__ 10 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common/Edge.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e934f23b4d4f5d54cacc0bb9fb06c930 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common/Geometry.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef __GEOMETRY__ 2 | #define __GEOMETRY__ 3 | 4 | struct AABB 5 | { 6 | float3 min; 7 | float3 max; 8 | }; 9 | 10 | struct Ray 11 | { 12 | float3 origin; 13 | float3 dir; 14 | float3 invdir; 15 | int signs[3]; 16 | 17 | bool intersects(AABB aabb) 18 | { 19 | float tmin, tmax, tymin, tymax, tzmin, tzmax; 20 | 21 | float3 bounds[2]; 22 | bounds[0] = aabb.min; 23 | bounds[1] = aabb.max; 24 | 25 | tmin = (bounds[signs[0]].x - origin.x) * invdir.x; 26 | tmax = (bounds[1 - signs[0]].x - origin.x) * invdir.x; 27 | tymin = (bounds[signs[1]].y - origin.y) * invdir.y; 28 | tymax = (bounds[1 - signs[1]].y - origin.y) * invdir.y; 29 | 30 | if ((tmin > tymax) || (tymin > tmax)) 31 | return false; 32 | 33 | if (tymin > tmin) 34 | tmin = tymin; 35 | 36 | if (tymax < tmax) 37 | tmax = tymax; 38 | 39 | tzmin = (bounds[signs[2]].z - origin.z) * invdir.z; 40 | tzmax = (bounds[1 - signs[2]].z - origin.z) * invdir.z; 41 | 42 | if ((tmin > tzmax) || (tzmin > tmax)) 43 | return false; 44 | 45 | if (tzmin > tmin) 46 | tmin = tzmin; 47 | 48 | if (tzmax < tmax) 49 | tmax = tzmax; 50 | 51 | return true; 52 | } 53 | 54 | }; 55 | 56 | Ray CreateRay(float3 origin, float3 dir) 57 | { 58 | Ray r; 59 | r.origin = origin; 60 | r.dir = dir; 61 | r.invdir = 1.0 / dir; 62 | r.signs[0] = (r.invdir.x < 0); 63 | r.signs[1] = (r.invdir.y < 0); 64 | r.signs[2] = (r.invdir.z < 0); 65 | return r; 66 | } 67 | 68 | float distance_line_to_point(float3 a, float3 b, float3 p) 69 | { 70 | float3 d = normalize(b - a); 71 | float3 v = p - a; 72 | float t = dot(v, d); 73 | float3 pd = a + t * d; // p on ab 74 | return distance(pd, p); 75 | } 76 | 77 | #endif -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common/Geometry.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a04676045ddd4142888e338f4dc51dd 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common/Node.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef __NODE_INCLUDED__ 2 | #define __NODE_INCLUDED__ 3 | 4 | struct Node 5 | { 6 | float3 position; 7 | float t; 8 | float offset; 9 | float mass; 10 | int from; 11 | bool active; 12 | }; 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common/Node.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 93e8b2dc7a1be3845a1b7979bfe1ac00 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common/Random.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef __RANDOM_INCLUDED__ 2 | #define __RANDOM_INCLUDED__ 3 | 4 | #ifndef PI 5 | #define PI 3.14159265359f 6 | #endif 7 | 8 | float nrand(float2 co) 9 | { 10 | return frac(sin(dot(co.xy, float2(12.9898, 78.233))) * 43758.5453); 11 | } 12 | 13 | float nrand(float2 uv, float salt) 14 | { 15 | uv += float2(salt, 0.0); 16 | return nrand(uv); 17 | } 18 | 19 | float3 nrand3(float2 seed) 20 | { 21 | float t = sin(seed.x + seed.y * 1e3); 22 | return float3(frac(t * 1e4), frac(t * 1e6), frac(t * 1e5)); 23 | } 24 | 25 | float2 random_point_on_circle(float2 uv) 26 | { 27 | float theta = nrand(uv) * PI * 2; 28 | return float2(cos(theta), sin(theta)); 29 | } 30 | 31 | // Uniformaly distributed points on a unit sphere 32 | // http://mathworld.wolfram.com/SpherePointPicking.html 33 | float3 random_point_on_sphere(float2 uv) 34 | { 35 | float u = nrand(uv) * 2 - 1; 36 | float theta = nrand(uv + 0.333) * PI * 2; 37 | float u2 = sqrt(1 - u * u); 38 | return float3(u2 * cos(theta), u2 * sin(theta), u); 39 | } 40 | 41 | #endif // __RANDOM_INCLUDED__ 42 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common/Random.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ebf2e82e5398fd4cb17698f385adf2a 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common/SkinnedAttraction.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef __ATTRACTION_INCLUDED__ 2 | #define __ATTRACTION_INCLUDED__ 3 | 4 | struct SkinnedAttraction 5 | { 6 | float3 position; 7 | uint bone; 8 | uint nearest; 9 | bool found; 10 | bool active; 11 | }; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common/SkinnedAttraction.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a224fcfa0d47fc84282e29e572d523e7 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common/SkinnedCandidate.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef __CANDIDATE_INCLUDED__ 2 | #define __CANDIDATE_INCLUDED__ 3 | 4 | struct SkinnedCandidate 5 | { 6 | float3 position; 7 | uint node; 8 | uint bone; 9 | }; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common/SkinnedCandidate.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c97c38af33e500c4f8670f83a8334061 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common/SkinnedNode.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef __NODE_INCLUDED__ 2 | #define __NODE_INCLUDED__ 3 | 4 | struct SkinnedNode 5 | { 6 | float3 position; 7 | float3 animated; 8 | int index0; 9 | float t; 10 | float offset; 11 | float mass; 12 | int from; 13 | bool active; 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Common/SkinnedNode.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91861e694ffe4194a964a6d887aef49f 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa468bd47d032d54688595e934563e63 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Compute/SkinnedSpaceColonization.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89146387ce1e1f3428322d7d2302034e 3 | ComputeShaderImporter: 4 | externalObjects: {} 5 | currentAPIMask: 4 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Compute/SpaceColonization.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 13deb82e849713f49a0ff696b6ce14ee 3 | ComputeShaderImporter: 4 | externalObjects: {} 5 | currentAPIMask: 4 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Render.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be3c0f1e62fe4154db60eef0ef46385b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Render/Edge.shader: -------------------------------------------------------------------------------- 1 | Shader "SpaceColonization/Edge" 2 | { 3 | 4 | Properties 5 | { 6 | _Color ("Color", Color) = (1, 1, 1, 1) 7 | } 8 | 9 | SubShader 10 | { 11 | Tags { "RenderType" = "Opaque" "Queue" = "Transparent" } 12 | LOD 100 13 | 14 | Pass 15 | { 16 | Blend One One 17 | ZTest Always 18 | ZWrite On 19 | Cull Off 20 | 21 | CGPROGRAM 22 | 23 | #pragma vertex vert 24 | #pragma fragment frag 25 | #pragma multi_compile_instancing 26 | #pragma instancing_options procedural:setup 27 | 28 | #include "UnityCG.cginc" 29 | #include "../Common/Node.hlsl" 30 | #include "../Common/Edge.hlsl" 31 | 32 | struct appdata 33 | { 34 | float4 vertex : POSITION; 35 | float2 uv : TEXCOORD0; 36 | uint vid : SV_VertexID; 37 | UNITY_VERTEX_INPUT_INSTANCE_ID 38 | }; 39 | 40 | struct v2f 41 | { 42 | float4 position : SV_POSITION; 43 | float2 uv : TEXCOORD0; 44 | float2 uv2 : TEXCOORD1; 45 | float alpha : COLOR; 46 | UNITY_VERTEX_INPUT_INSTANCE_ID 47 | }; 48 | 49 | StructuredBuffer _Nodes; 50 | StructuredBuffer _Edges; 51 | uint _EdgesCount; 52 | 53 | float4 _Color; 54 | 55 | float4x4 _World2Local, _Local2World; 56 | 57 | void setup() { 58 | unity_WorldToObject = _World2Local; 59 | unity_ObjectToWorld = _Local2World; 60 | } 61 | 62 | v2f vert(appdata IN, uint iid : SV_InstanceID) 63 | { 64 | v2f OUT; 65 | UNITY_SETUP_INSTANCE_ID(IN); 66 | UNITY_TRANSFER_INSTANCE_ID(IN, OUT); 67 | 68 | Edge e = _Edges[iid]; 69 | Node a = _Nodes[e.a]; 70 | Node b = _Nodes[e.b]; 71 | float3 ap = a.position; 72 | float3 bp = b.position; 73 | float3 dir = bp - ap; 74 | bp = ap + normalize(dir) * length(dir) * b.t; 75 | float3 position = lerp(ap, bp, IN.vid); 76 | 77 | float4 vertex = float4(position, 1); 78 | OUT.position = UnityObjectToClipPos(vertex); 79 | OUT.uv = IN.uv; 80 | OUT.uv2 = float2(lerp(a.offset, b.offset, IN.vid), 0); 81 | 82 | OUT.alpha = (a.active && b.active) && (iid < _EdgesCount); 83 | 84 | return OUT; 85 | } 86 | 87 | fixed4 frag(v2f IN) : SV_Target 88 | { 89 | return _Color * IN.alpha; 90 | } 91 | 92 | ENDCG 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Render/Edge.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7f0b1817b5ef95b44bb44ee2a4dec420 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Render/SkinnedTubularEdgeCommon.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: afbdeba714ad9cf4e9495c18db218119 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Render/SkinnedTubularEdgeStandard.shader: -------------------------------------------------------------------------------- 1 | Shader "SpaceColonization/SkinnedTubularEdgeStandard" 2 | { 3 | 4 | Properties 5 | { 6 | _Thickness ("Thickness", Range(0.001, 0.1)) = 0.1 7 | 8 | _Color ("Color", Color) = (1, 1, 1, 1) 9 | [HDR] _Emission ("Emission", Color) = (1, 1, 1, 1) 10 | 11 | [Space] 12 | _Glossiness ("Smoothness", Range(0, 1)) = 0.5 13 | [Gamma] _Metallic ("Metallic", Range(0, 1)) = 0 14 | } 15 | 16 | SubShader 17 | { 18 | Tags { "RenderType" = "Opaque" } 19 | LOD 100 20 | 21 | Pass 22 | { 23 | Tags { "LightMode" = "Deferred" } 24 | CGPROGRAM 25 | #pragma target 4.0 26 | #pragma vertex vert 27 | #pragma geometry geom 28 | #pragma fragment frag 29 | #pragma multi_compile_prepassfinal noshadowmask nodynlightmap nodirlightmap nolightmap 30 | #pragma multi_compile_instancing 31 | #pragma instancing_options procedural:setup 32 | #include "./SkinnedTubularEdgeCommon.hlsl" 33 | ENDCG 34 | } 35 | 36 | Pass 37 | { 38 | Tags { "LightMode" = "ShadowCaster" } 39 | CGPROGRAM 40 | #pragma target 4.0 41 | #pragma vertex vert 42 | #pragma geometry geom 43 | #pragma fragment frag 44 | #pragma multi_compile_shadowcaster noshadowmask nodynlightmap nodirlightmap nolightmap 45 | #pragma multi_compile_instancing 46 | #pragma instancing_options procedural:setup 47 | #include "./SkinnedTubularEdgeCommon.hlsl" 48 | ENDCG 49 | } 50 | 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Render/SkinnedTubularEdgeStandard.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c78dc1c3ff175c540ae3d6009d463e52 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Render/TubularEdge.shader: -------------------------------------------------------------------------------- 1 | Shader "SpaceColonization/TubularEdge" 2 | { 3 | 4 | Properties 5 | { 6 | _Color ("Color", Color) = (1, 1, 1, 1) 7 | _Thickness ("Thickness", Range(0.01, 0.1)) = 0.1 8 | } 9 | 10 | CGINCLUDE 11 | 12 | #include "UnityCG.cginc" 13 | #include "../Common/Node.hlsl" 14 | #include "../Common/Edge.hlsl" 15 | 16 | StructuredBuffer _Nodes; 17 | StructuredBuffer _Edges; 18 | uint _EdgesCount; 19 | 20 | float4 _Color; 21 | half _Thickness; 22 | 23 | float4x4 _World2Local, _Local2World; 24 | 25 | struct appdata 26 | { 27 | float4 vertex : POSITION; 28 | float2 uv : TEXCOORD0; 29 | uint vid : SV_VertexID; 30 | UNITY_VERTEX_INPUT_INSTANCE_ID 31 | }; 32 | 33 | struct v2g 34 | { 35 | float3 position : NORMAL; 36 | float3 viewDir : TANGENT; 37 | float2 uv : TEXCOORD0; 38 | float2 uv2 : TEXCOORD1; 39 | float alpha : COLOR; 40 | UNITY_VERTEX_INPUT_INSTANCE_ID 41 | }; 42 | 43 | struct g2f 44 | { 45 | float4 position : SV_POSITION; 46 | float3 normal : NORMAL; 47 | float2 uv : TEXCOORD0; 48 | float2 uv2 : TEXCOORD1; 49 | }; 50 | 51 | void setup() { 52 | unity_WorldToObject = _World2Local; 53 | unity_ObjectToWorld = _Local2World; 54 | } 55 | 56 | v2g vert(appdata IN, uint iid : SV_InstanceID) 57 | { 58 | v2g OUT; 59 | UNITY_SETUP_INSTANCE_ID(IN); 60 | UNITY_TRANSFER_INSTANCE_ID(IN, OUT); 61 | 62 | Edge e = _Edges[iid]; 63 | Node a = _Nodes[e.a]; 64 | Node b = _Nodes[e.b]; 65 | float3 ap = a.position; 66 | float3 bp = b.position; 67 | float3 dir = bp - ap; 68 | bp = ap + normalize(dir) * length(dir) * b.t; 69 | float3 position = lerp(ap, bp, IN.vid); 70 | OUT.position = mul(unity_ObjectToWorld, float4(position, 1)).xyz; 71 | OUT.viewDir = WorldSpaceViewDir(float4(position, 1)); 72 | OUT.uv = IN.uv; 73 | OUT.uv2 = float2(lerp(a.offset, b.offset, IN.vid), 0); 74 | OUT.alpha = (a.active && b.active) && (iid < _EdgesCount); 75 | 76 | return OUT; 77 | } 78 | 79 | [maxvertexcount(64)] 80 | void geom(line v2g IN[2], inout TriangleStream OUT) { 81 | v2g p0 = IN[0]; 82 | v2g p1 = IN[1]; 83 | 84 | float alpha = p0.alpha; 85 | 86 | float3 t = normalize(p1.position - p0.position); 87 | float3 n = normalize(p0.viewDir); 88 | float3 bn = cross(t, n); 89 | n = cross(t, bn); 90 | 91 | float3 tp = lerp(p0.position, p1.position, alpha); 92 | float thickness = _Thickness * alpha; 93 | 94 | static const uint rows = 6, cols = 6; 95 | static const float rows_inv = 1.0 / rows, cols_inv = 1.0 / (cols - 1); 96 | 97 | g2f o0, o1; 98 | o0.uv = p0.uv; o0.uv2 = p0.uv2; 99 | o1.uv = p1.uv; o1.uv2 = p1.uv2; 100 | 101 | // create side 102 | for (uint i = 0; i < cols; i++) { 103 | float r = (i * cols_inv) * UNITY_TWO_PI; 104 | 105 | float s, c; 106 | sincos(r, s, c); 107 | float3 normal = normalize(n * c + bn * s); 108 | 109 | float3 w0 = p0.position + normal * thickness; 110 | float3 w1 = p1.position + normal * thickness; 111 | o0.normal = o1.normal = normal; 112 | 113 | o0.position = UnityWorldToClipPos(w0); 114 | OUT.Append(o0); 115 | 116 | o1.position = UnityWorldToClipPos(w1); 117 | OUT.Append(o1); 118 | } 119 | OUT.RestartStrip(); 120 | 121 | // create tip 122 | uint row, col; 123 | for (row = 0; row < rows; row++) 124 | { 125 | float s0 = sin((row * rows_inv) * UNITY_HALF_PI); 126 | float s1 = sin(((row + 1) * rows_inv) * UNITY_HALF_PI); 127 | for (col = 0; col < cols; col++) 128 | { 129 | float r = (col * cols_inv) * UNITY_TWO_PI; 130 | 131 | float s, c; 132 | sincos(r, s, c); 133 | 134 | float3 n0 = normalize(n * c * (1.0 - s0) + bn * s * (1.0 - s0) + t * s0); 135 | float3 n1 = normalize(n * c * (1.0 - s1) + bn * s * (1.0 - s1) + t * s1); 136 | 137 | o0.position = UnityWorldToClipPos(float4(tp + n0 * thickness, 1)); 138 | o0.normal = n0; 139 | OUT.Append(o0); 140 | 141 | o1.position = UnityWorldToClipPos(float4(tp + n1 * thickness, 1)); 142 | o1.normal = n1; 143 | OUT.Append(o1); 144 | } 145 | OUT.RestartStrip(); 146 | } 147 | } 148 | 149 | fixed4 frag(g2f IN) : SV_Target 150 | { 151 | float3 normal = IN.normal; 152 | fixed3 normal01 = (normal + 1.0) * 0.5; 153 | fixed4 color = _Color; 154 | color.rgb *= normal01.xyz; 155 | return color; 156 | } 157 | 158 | ENDCG 159 | 160 | SubShader 161 | { 162 | Tags { "RenderType" = "Opaque" "Queue" = "Geometry" } 163 | LOD 100 164 | 165 | Pass 166 | { 167 | CGPROGRAM 168 | #pragma vertex vert 169 | #pragma geometry geom 170 | #pragma fragment frag 171 | #pragma multi_compile_instancing 172 | #pragma instancing_options procedural:setup 173 | ENDCG 174 | } 175 | } 176 | 177 | } 178 | -------------------------------------------------------------------------------- /Assets/SpaceColonization/Shaders/Render/TubularEdge.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c2576b03b6d2e3f49ad758e19e610a36 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/StarGlow.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d269631bad511a458b9f70166d23788 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/StarGlow/ImageEffectBase.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 86d846a242e69cb4e887f94f82cfcab1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/StarGlow/ImageEffectBase/ImageEffectBase.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | [ExecuteInEditMode] 4 | [RequireComponent(typeof(Camera))] 5 | public class ImageEffectBase : MonoBehaviour 6 | { 7 | #region Field 8 | 9 | public Material material; 10 | 11 | #endregion Field 12 | 13 | #region Method 14 | 15 | protected virtual void Start() 16 | { 17 | if (!SystemInfo.supportsImageEffects 18 | || !this.material 19 | || !this.material.shader.isSupported) 20 | { 21 | base.enabled = false; 22 | } 23 | } 24 | 25 | protected virtual void OnRenderImage(RenderTexture source, RenderTexture destination) 26 | { 27 | Graphics.Blit(source, destination, this.material); 28 | } 29 | 30 | #endregion Method 31 | } -------------------------------------------------------------------------------- /Assets/StarGlow/ImageEffectBase/ImageEffectBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c99cdcd90dee9b4eb69b3b89e4dfac5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - material: {fileID: 2100000, guid: a6ef705d54e028a44821b6a5996b2571, type: 2} 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/StarGlow/ImageEffectBase/ImageEffectBase.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: ImageEffectBase 10 | m_Shader: {fileID: 4800000, guid: 3f1856e1833bed241ade4708d4c5cc6c, type: 3} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 4 13 | m_EnableInstancingVariants: 0 14 | m_DoubleSidedGI: 0 15 | m_CustomRenderQueue: -1 16 | stringTagMap: {} 17 | disabledShaderPasses: [] 18 | m_SavedProperties: 19 | serializedVersion: 3 20 | m_TexEnvs: 21 | - _BumpMap: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | - _DetailAlbedoMap: 26 | m_Texture: {fileID: 0} 27 | m_Scale: {x: 1, y: 1} 28 | m_Offset: {x: 0, y: 0} 29 | - _DetailMask: 30 | m_Texture: {fileID: 0} 31 | m_Scale: {x: 1, y: 1} 32 | m_Offset: {x: 0, y: 0} 33 | - _DetailNormalMap: 34 | m_Texture: {fileID: 0} 35 | m_Scale: {x: 1, y: 1} 36 | m_Offset: {x: 0, y: 0} 37 | - _EmissionMap: 38 | m_Texture: {fileID: 0} 39 | m_Scale: {x: 1, y: 1} 40 | m_Offset: {x: 0, y: 0} 41 | - _MainTex: 42 | m_Texture: {fileID: 0} 43 | m_Scale: {x: 1, y: 1} 44 | m_Offset: {x: 0, y: 0} 45 | - _MetallicGlossMap: 46 | m_Texture: {fileID: 0} 47 | m_Scale: {x: 1, y: 1} 48 | m_Offset: {x: 0, y: 0} 49 | - _OcclusionMap: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | - _ParallaxMap: 54 | m_Texture: {fileID: 0} 55 | m_Scale: {x: 1, y: 1} 56 | m_Offset: {x: 0, y: 0} 57 | m_Floats: 58 | - _BumpScale: 1 59 | - _Cutoff: 0.5 60 | - _DetailNormalMapScale: 1 61 | - _DstBlend: 0 62 | - _GlossMapScale: 1 63 | - _Glossiness: 0.5 64 | - _GlossyReflections: 1 65 | - _Metallic: 0 66 | - _Mode: 0 67 | - _OcclusionStrength: 1 68 | - _Parallax: 0.02 69 | - _SmoothnessTextureChannel: 0 70 | - _SpecularHighlights: 1 71 | - _SrcBlend: 1 72 | - _UVSec: 0 73 | - _ZWrite: 1 74 | m_Colors: 75 | - _Color: {r: 1, g: 1, b: 1, a: 1} 76 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 77 | -------------------------------------------------------------------------------- /Assets/StarGlow/ImageEffectBase/ImageEffectBase.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a6ef705d54e028a44821b6a5996b2571 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/StarGlow/ImageEffectBase/ImageEffectBase.shader: -------------------------------------------------------------------------------- 1 | Shader "ImageEffect/Base" 2 | { 3 | Properties 4 | { 5 | _MainTex("Texture", 2D) = "white" {} 6 | } 7 | SubShader 8 | { 9 | Pass 10 | { 11 | CGPROGRAM 12 | 13 | #include "UnityCG.cginc" 14 | #pragma vertex vert_img 15 | #pragma fragment frag 16 | 17 | sampler2D _MainTex; 18 | 19 | fixed4 frag(v2f_img input) : SV_Target 20 | { 21 | float4 color = tex2D(_MainTex, input.uv); 22 | color.rgb = 1 - color.rgb; 23 | 24 | return color; 25 | } 26 | 27 | ENDCG 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Assets/StarGlow/ImageEffectBase/ImageEffectBase.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f1856e1833bed241ade4708d4c5cc6c 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/StarGlow/Sample.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Sample 11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 1, g: 1, b: 1, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Assets/StarGlow/Sample.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0741d2c8cf6adc64391c4d288d20bb58 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/StarGlow/Sample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f367124fed2a06642b60b85eddec5082 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/StarGlow/StarGlow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e23bce2a07d82744a6626dfe2a18517 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - material: {fileID: 2100000, guid: 777412ced6fd53845ace1e4f73e236bb, type: 2} 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/StarGlow/StarGlow.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: StarGlow 11 | m_Shader: {fileID: 4800000, guid: d4369e748fcad8446be0516e390f5a16, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BLOOM_TYPE: 0 60 | - _BrightnessThreshold: 0.628 61 | - _BumpScale: 1 62 | - _COMPOSITE_TYPE: 4 63 | - _Cutoff: 0.5 64 | - _DITHER: 1 65 | - _DITHER_TYPE: 1 66 | - _DetailNormalMapScale: 1 67 | - _DstBlend: 0 68 | - _GlossMapScale: 1 69 | - _Glossiness: 0.5 70 | - _GlossyReflections: 1 71 | - _HalfFilterSizePx: 26.2 72 | - _Intensity: 2.29 73 | - _Metallic: 0 74 | - _Mode: 0 75 | - _OcclusionStrength: 1 76 | - _Parallax: 0.02 77 | - _SamplingFrequency: 9.67 78 | - _SmoothnessTextureChannel: 0 79 | - _SpecularHighlights: 1 80 | - _SrcBlend: 1 81 | - _Type: 0 82 | - _UVSec: 0 83 | - _ZWrite: 1 84 | m_Colors: 85 | - _Color: {r: 1, g: 1, b: 1, a: 1} 86 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 87 | - _Parameter: {r: 1, g: 1.3, b: 0.7, a: 0} 88 | -------------------------------------------------------------------------------- /Assets/StarGlow/StarGlow.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 777412ced6fd53845ace1e4f73e236bb 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/StarGlow/StarGlow.shader: -------------------------------------------------------------------------------- 1 | Shader "ImageEffect/StarGlow" 2 | { 3 | Properties 4 | { 5 | [HideInInspector] 6 | _MainTex("Texture", 2D) = "white" {} 7 | 8 | [KeywordEnum(ADDITIVE, SCREEN, COLORED_ADDITIVE, COLORED_SCREEN, DEBUG)] 9 | _COMPOSITE_TYPE("Composite Type", Float) = 0 10 | 11 | _Parameter("(Threhold, Intensity, Attenuation, -)", Vector) = (0.8, 1.0, 0.95, 0.0) 12 | } 13 | SubShader 14 | { 15 | CGINCLUDE 16 | 17 | #include "UnityCG.cginc" 18 | 19 | sampler2D _MainTex; 20 | float4 _MainTex_ST; 21 | float4 _MainTex_TexelSize; 22 | float4 _Parameter; 23 | 24 | #define BRIGHTNESS_THRESHOLD _Parameter.x 25 | #define INTENSITY _Parameter.y 26 | #define ATTENUATION _Parameter.z 27 | 28 | ENDCG 29 | 30 | // STEP:0 31 | // Debug. 32 | 33 | Pass 34 | { 35 | CGPROGRAM 36 | 37 | #pragma vertex vert_img 38 | #pragma fragment frag 39 | 40 | fixed4 frag(v2f_img input) : SV_Target 41 | { 42 | return tex2D(_MainTex, input.uv); 43 | } 44 | 45 | ENDCG 46 | } 47 | 48 | // STEP:1 49 | // Get resized brightness image. 50 | 51 | Pass 52 | { 53 | CGPROGRAM 54 | 55 | #pragma vertex vert_img 56 | #pragma fragment frag 57 | 58 | fixed4 frag(v2f_img input) : SV_Target 59 | { 60 | float4 color = tex2D(_MainTex, input.uv); 61 | return max(color - BRIGHTNESS_THRESHOLD, 0) * INTENSITY; 62 | } 63 | 64 | ENDCG 65 | } 66 | 67 | // STEP:2 68 | // Get blurred brightness image. 69 | 70 | Pass 71 | { 72 | CGPROGRAM 73 | 74 | #pragma vertex vert 75 | #pragma fragment frag 76 | 77 | int _Iteration; 78 | float2 _Offset; 79 | 80 | struct v2f_starglow 81 | { 82 | float4 pos : SV_POSITION; 83 | half2 uv : TEXCOORD0; 84 | half power : TEXCOORD1; 85 | half2 offset : TEXCOORD2; 86 | }; 87 | 88 | v2f_starglow vert(appdata_img v) 89 | { 90 | v2f_starglow o; 91 | 92 | o.pos = UnityObjectToClipPos (v.vertex); 93 | o.uv = v.texcoord; 94 | o.power = pow(4, _Iteration - 1); 95 | o.offset = _MainTex_TexelSize.xy * _Offset * o.power; 96 | 97 | return o; 98 | } 99 | 100 | float4 frag(v2f_starglow input) : SV_Target 101 | { 102 | half4 color = half4(0, 0, 0, 0); 103 | half2 uv = input.uv; 104 | 105 | for (int j = 0; j < 4; j++) 106 | { 107 | color += saturate(tex2D(_MainTex, uv) * pow(ATTENUATION, input.power * j)); 108 | uv += input.offset; 109 | } 110 | 111 | return color; 112 | } 113 | 114 | ENDCG 115 | } 116 | 117 | // STEP:3 118 | // Composite each blurred brightness image. 119 | 120 | Pass 121 | { 122 | Blend OneMinusDstColor One 123 | 124 | CGPROGRAM 125 | 126 | #pragma vertex vert_img 127 | #pragma fragment frag 128 | 129 | fixed4 frag(v2f_img input) : SV_Target 130 | { 131 | return tex2D(_MainTex, input.uv); 132 | } 133 | 134 | ENDCG 135 | } 136 | 137 | // STEP:4 138 | // Composite to original. 139 | 140 | Pass 141 | { 142 | CGPROGRAM 143 | 144 | #pragma vertex vert_img 145 | #pragma fragment frag 146 | #pragma multi_compile _COMPOSITE_TYPE_ADDITIVE _COMPOSITE_TYPE_SCREEN _COMPOSITE_TYPE_COLORED_ADDITIVE _COMPOSITE_TYPE_COLORED_SCREEN _COMPOSITE_TYPE_DEBUG 147 | 148 | sampler2D _CompositeTex; 149 | float4 _CompositeColor; 150 | 151 | fixed4 frag(v2f_img input) : SV_Target 152 | { 153 | float4 mainColor = tex2D(_MainTex, input.uv); 154 | float4 compositeColor = tex2D(_CompositeTex, input.uv); 155 | 156 | #if defined(_COMPOSITE_TYPE_COLORED_ADDITIVE) || defined(_COMPOSITE_TYPE_COLORED_SCREEN) 157 | 158 | compositeColor.rgb = (compositeColor.r + compositeColor.g + compositeColor.b) 159 | * 0.3333 * _CompositeColor; 160 | 161 | #endif 162 | 163 | #if defined(_COMPOSITE_TYPE_SCREEN) || defined(_COMPOSITE_TYPE_COLORED_SCREEN) 164 | 165 | return saturate(mainColor + compositeColor - saturate(mainColor * compositeColor)); 166 | 167 | #elif defined(_COMPOSITE_TYPE_ADDITIVE) || defined(_COMPOSITE_TYPE_COLORED_ADDITIVE) 168 | 169 | return saturate(mainColor + compositeColor); 170 | 171 | #else 172 | 173 | return compositeColor; 174 | 175 | #endif 176 | } 177 | 178 | ENDCG 179 | } 180 | } 181 | } -------------------------------------------------------------------------------- /Assets/StarGlow/StarGlow.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d4369e748fcad8446be0516e390f5a16 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Tessellation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6343d2e5911ed074e81e0a50fa3547ae 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Tessellation/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 946d18a4bc3e2e040a90141615ac8129 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Tessellation/Materials/AddSource.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: AddSource 11 | m_Shader: {fileID: 4800000, guid: e03d5bba968f8d24a865450a2f8c90d4, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _Radius: 0.072 71 | - _SmoothnessTextureChannel: 0 72 | - _SpecularHighlights: 1 73 | - _SrcBlend: 1 74 | - _UVSec: 0 75 | - _ZWrite: 1 76 | m_Colors: 77 | - _Color: {r: 1, g: 1, b: 1, a: 1} 78 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 79 | - _Source: {r: 0.98328197, g: 0.18208925, b: 0.7553588, a: 0.23534483} 80 | -------------------------------------------------------------------------------- /Assets/Tessellation/Materials/AddSource.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 300c2938381bc3e478c96769a5e2f95d 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Tessellation/Materials/Tessellation.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Tessellation 11 | m_Shader: {fileID: 4800000, guid: a88752755817daa488dd454fecb21493, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _DispTex: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _EmissionMap: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MainTex: 47 | m_Texture: {fileID: 2800000, guid: a7a9b7d0f2d38d34e8aa614e453fad1d, type: 3} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _MetallicGlossMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _NormalMap: 55 | m_Texture: {fileID: 2800000, guid: 2e33cce1d800daa43b067ac4e2559c16, type: 3} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | - _OcclusionMap: 59 | m_Texture: {fileID: 0} 60 | m_Scale: {x: 1, y: 1} 61 | m_Offset: {x: 0, y: 0} 62 | - _ParallaxMap: 63 | m_Texture: {fileID: 0} 64 | m_Scale: {x: 1, y: 1} 65 | m_Offset: {x: 0, y: 0} 66 | m_Floats: 67 | - _BumpScale: 1 68 | - _Cutoff: 0.5 69 | - _DetailNormalMapScale: 1 70 | - _Displacement: 0.3 71 | - _DstBlend: 0 72 | - _EdgeLength: 15 73 | - _Gloss: 0.581 74 | - _GlossMapScale: 1 75 | - _Glossiness: 0.5 76 | - _GlossyReflections: 1 77 | - _Metallic: 0 78 | - _Mode: 0 79 | - _OcclusionStrength: 1 80 | - _Parallax: 0.02 81 | - _SmoothnessTextureChannel: 0 82 | - _Specular: 0.366 83 | - _SpecularHighlights: 1 84 | - _SrcBlend: 1 85 | - _UVSec: 0 86 | - _ZWrite: 1 87 | m_Colors: 88 | - _Color: {r: 0, g: 0, b: 0, a: 1} 89 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 90 | - _SpecColor: {r: 1, g: 1, b: 1, a: 0.5} 91 | -------------------------------------------------------------------------------- /Assets/Tessellation/Materials/Tessellation.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 629df15111b562c4eb09f97c59b7417b 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Tessellation/Materials/TessellationSurface.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: TessellationSurface 11 | m_Shader: {fileID: 4800000, guid: c65abc0b6c0b7a04a8d7598224816ca4, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _DispTex: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _EmissionMap: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MainTex: 47 | m_Texture: {fileID: 2800000, guid: a7a9b7d0f2d38d34e8aa614e453fad1d, type: 3} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _MetallicGlossMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _NormalMap: 55 | m_Texture: {fileID: 2800000, guid: 2e33cce1d800daa43b067ac4e2559c16, type: 3} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | - _OcclusionMap: 59 | m_Texture: {fileID: 0} 60 | m_Scale: {x: 1, y: 1} 61 | m_Offset: {x: 0, y: 0} 62 | - _ParallaxMap: 63 | m_Texture: {fileID: 0} 64 | m_Scale: {x: 1, y: 1} 65 | m_Offset: {x: 0, y: 0} 66 | m_Floats: 67 | - _BumpScale: 1 68 | - _Cutoff: 0.5 69 | - _DetailNormalMapScale: 1 70 | - _Displacement: 0.5 71 | - _DstBlend: 0 72 | - _EdgeLength: 2 73 | - _Gloss: 0.276 74 | - _GlossMapScale: 1 75 | - _Glossiness: 0.5 76 | - _GlossyReflections: 1 77 | - _Metallic: 0 78 | - _Mode: 0 79 | - _Negative: 0 80 | - _OcclusionStrength: 1 81 | - _Parallax: 0.02 82 | - _SmoothnessTextureChannel: 0 83 | - _Specular: 0.366 84 | - _SpecularHighlights: 1 85 | - _SrcBlend: 1 86 | - _UVSec: 0 87 | - _ZWrite: 1 88 | m_Colors: 89 | - _Color: {r: 0, g: 0, b: 0, a: 1} 90 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 91 | - _SpecColor: {r: 1, g: 1, b: 1, a: 0.5} 92 | -------------------------------------------------------------------------------- /Assets/Tessellation/Materials/TessellationSurface.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fafeff40cf0693940a51a78e3fbd94e4 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Tessellation/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5eadb58114d79f84d81fde54fc21d1a8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Tessellation/Scenes/FuidTessellation.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 194919459e5cd454493ea4d18e4ed559 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Tessellation/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fcaee8a9ea3820449bce0d490bc07f17 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Tessellation/Scripts/MouseSourceProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace Fluid 5 | { 6 | public class MouseSourceProvider : MonoBehaviour 7 | { 8 | string source2dProp = "_Source"; 9 | string sourceRadiusProp = "_Radius"; 10 | int source2dId, sourceRadiusId; 11 | Vector3 lastMousePos; 12 | 13 | [SerializeField] 14 | Material addSourceMat = null; 15 | 16 | [SerializeField] 17 | float sourceRadius = 0.03f; 18 | 19 | public RenderTexture addSourceTex; 20 | public SourceEvent OnSourceUpdated; 21 | 22 | void Awake() 23 | { 24 | source2dId = Shader.PropertyToID(source2dProp); 25 | sourceRadiusId = Shader.PropertyToID(sourceRadiusProp); 26 | } 27 | 28 | void Update() 29 | { 30 | InitializeSourceTex(Screen.width, Screen.height); 31 | UpdateSource(); 32 | } 33 | 34 | void OnDestroy() 35 | { 36 | ReleaseForceField(); 37 | } 38 | 39 | void InitializeSourceTex(int width, int height) 40 | { 41 | if (addSourceTex == null || addSourceTex.width != width || addSourceTex.height != height) 42 | { 43 | ReleaseForceField(); 44 | addSourceTex = new RenderTexture(width, height, 0, RenderTextureFormat.ARGBFloat); 45 | } 46 | } 47 | 48 | void UpdateSource() 49 | { 50 | var mousePos = Input.mousePosition; 51 | var dpdt = UpdateMousePos(mousePos); 52 | var velocitySource = Vector2.zero; 53 | var uv = Vector2.zero; 54 | 55 | if (Input.GetMouseButton(0)) 56 | { 57 | uv = Camera.main.ScreenToViewportPoint(mousePos); 58 | velocitySource = Vector2.ClampMagnitude(dpdt, 1f); 59 | addSourceMat.SetVector(source2dId, new Vector4(velocitySource.x, velocitySource.y, uv.x, uv.y)); 60 | addSourceMat.SetFloat(sourceRadiusId, sourceRadius); 61 | Graphics.Blit(null, addSourceTex, addSourceMat); 62 | NotifySourceTexUpdate(); 63 | } 64 | else 65 | { 66 | NotifyNoSourceTexUpdate(); 67 | } 68 | } 69 | 70 | void NotifySourceTexUpdate() 71 | { 72 | OnSourceUpdated.Invoke(addSourceTex); 73 | } 74 | 75 | void NotifyNoSourceTexUpdate() 76 | { 77 | OnSourceUpdated.Invoke(null); 78 | } 79 | 80 | Vector3 UpdateMousePos(Vector3 mousePos) 81 | { 82 | var dpdt = mousePos - lastMousePos; 83 | lastMousePos = mousePos; 84 | return dpdt; 85 | } 86 | 87 | void ReleaseForceField() 88 | { 89 | Destroy(addSourceTex); 90 | } 91 | 92 | [Serializable] 93 | public class SourceEvent : UnityEngine.Events.UnityEvent { } 94 | } 95 | } -------------------------------------------------------------------------------- /Assets/Tessellation/Scripts/MouseSourceProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76d6bb005a31bfe4c9bac13cef8d8edb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Tessellation/Scripts/RenderEffect.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Render 4 | { 5 | public class RenderEffect : MonoBehaviour 6 | { 7 | public TextureEvent OnCreateTex; 8 | public RenderTexture Output { get; private set; } 9 | 10 | [SerializeField] string propName = "_PropName"; 11 | [SerializeField] Material[] effects = new Material[0]; 12 | [SerializeField] bool show = true; 13 | [SerializeField] RenderTextureFormat format = RenderTextureFormat.ARGBFloat; 14 | [SerializeField] TextureWrapMode wrapMode = TextureWrapMode.Repeat; 15 | [SerializeField] int downSample = 0; 16 | 17 | RenderTexture[] rts = new RenderTexture[2]; 18 | 19 | void Update() 20 | { 21 | if (Input.GetKeyDown(KeyCode.Alpha6)) 22 | show = !show; 23 | } 24 | 25 | void OnRenderImage(RenderTexture s, RenderTexture d) 26 | { 27 | CheckRTs(s); 28 | Graphics.Blit(s, rts[0]); 29 | foreach (var m in effects) 30 | { 31 | Graphics.Blit(rts[0], rts[1], m); 32 | SwapRTs(); 33 | } 34 | 35 | Graphics.Blit(rts[0], Output); 36 | Shader.SetGlobalTexture(propName, Output); 37 | if (show) 38 | Graphics.Blit(Output, d); 39 | else 40 | Graphics.Blit(s, d); 41 | } 42 | 43 | void CheckRTs(RenderTexture s) 44 | { 45 | if (rts[0] == null || rts[0].width != s.width >> downSample || rts[0].height != s.height >> downSample) 46 | { 47 | for (var i = 0; i < rts.Length; i++) 48 | { 49 | var rt = rts[i]; 50 | rts[i] = RenderUtility.CreateRenderTexture(s.width >> downSample, s.height >> downSample, 16, format, wrapMode, FilterMode.Bilinear, rt); 51 | } 52 | Output = RenderUtility.CreateRenderTexture(s.width >> downSample, s.height >> downSample, 16, format, wrapMode, FilterMode.Bilinear, Output); 53 | OnCreateTex.Invoke(Output); 54 | } 55 | } 56 | 57 | void SwapRTs() 58 | { 59 | var tmp = rts[0]; 60 | rts[0] = rts[1]; 61 | rts[1] = tmp; 62 | } 63 | 64 | void OnDisabled() 65 | { 66 | foreach (var rt in rts) 67 | RenderUtility.ReleaseRenderTexture(rt); 68 | RenderUtility.ReleaseRenderTexture(Output); 69 | } 70 | 71 | [System.Serializable] 72 | public class TextureEvent : UnityEngine.Events.UnityEvent { } 73 | } 74 | } 75 | 76 | -------------------------------------------------------------------------------- /Assets/Tessellation/Scripts/RenderEffect.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 31ffc847797c2354790359022a52be3a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Tessellation/Scripts/RenderUtility.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | 4 | namespace Render 5 | { 6 | public class RenderUtility : MonoBehaviour 7 | { 8 | public static RenderTexture CreateRenderTexture(int width, int height, int depth, RenderTextureFormat format, TextureWrapMode wrapMode = TextureWrapMode.Repeat, FilterMode filterMode = FilterMode.Bilinear, RenderTexture rt = null) 9 | { 10 | if (rt != null) 11 | { 12 | if (rt.width == width && rt.height == height) return rt; 13 | } 14 | 15 | ReleaseRenderTexture(rt); 16 | rt = new RenderTexture(width, height, depth, format); 17 | rt.enableRandomWrite = true; 18 | rt.wrapMode = wrapMode; 19 | rt.filterMode = filterMode; 20 | rt.Create(); 21 | ClearRenderTexture(rt, Color.clear); 22 | return rt; 23 | } 24 | 25 | public static RenderTexture CreateVolumetricRenderTexture(int width, int height, int volumeDepth, int depth, RenderTextureFormat format, TextureWrapMode wrapMode = TextureWrapMode.Repeat, FilterMode filterMode = FilterMode.Bilinear, RenderTexture rt = null) 26 | { 27 | if (rt != null) 28 | { 29 | if (rt.width == width && rt.height == height) return rt; 30 | } 31 | 32 | ReleaseRenderTexture(rt); 33 | rt = new RenderTexture(width, height, depth, format); 34 | rt.dimension = TextureDimension.Tex3D; 35 | rt.volumeDepth = volumeDepth; 36 | rt.enableRandomWrite = true; 37 | rt.wrapMode = wrapMode; 38 | rt.filterMode = filterMode; 39 | rt.Create(); 40 | ClearRenderTexture(rt, Color.clear); 41 | return rt; 42 | } 43 | 44 | public static void ReleaseRenderTexture(RenderTexture rt) 45 | { 46 | if (rt == null) return; 47 | 48 | rt.Release(); 49 | Destroy(rt); 50 | } 51 | 52 | public static void ClearRenderTexture(RenderTexture target, Color bg) 53 | { 54 | var active = RenderTexture.active; 55 | RenderTexture.active = target; 56 | GL.Clear(true, true, bg); 57 | RenderTexture.active = active; 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /Assets/Tessellation/Scripts/RenderUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e43e28a144e57d741b909f59a8943bbd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Tessellation/Scripts/Solver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f872f7744354e1e4cab6bd1fb50043d2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Tessellation/Scripts/TextureProvider.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class TextureProvider : MonoBehaviour 4 | { 5 | [SerializeField] Renderer render = null; 6 | [SerializeField] string provideTexProp = "_DispTex"; 7 | MaterialPropertyBlock mpb = null; 8 | int provideId; 9 | 10 | public Texture ProvideTex { get; set; } 11 | 12 | void Start() 13 | { 14 | mpb = new MaterialPropertyBlock(); 15 | provideId = Shader.PropertyToID(provideTexProp); 16 | if (!render) render = GetComponent(); 17 | } 18 | 19 | void Update() 20 | { 21 | if (!ProvideTex) return; 22 | mpb.SetTexture(provideId, ProvideTex); 23 | render.SetPropertyBlock(mpb); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Assets/Tessellation/Scripts/TextureProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 42297168b5e1a1445aaa6387c46e1386 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Tessellation/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf00b11560d617a48a9200f2d2e5ed3f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Tessellation/Shaders/AddSource.shader: -------------------------------------------------------------------------------- 1 | Shader "Fluid/AddSource" { 2 | Properties { 3 | _Source ("Adding source", Vector) = (0, 1, 0.5, 0.5) //xy = velocity, zw = center pos 4 | _Radius ("Radius", Float) = 10 5 | } 6 | SubShader { 7 | Cull Off ZWrite Off ZTest Always 8 | 9 | Pass { 10 | CGPROGRAM 11 | #pragma vertex vert 12 | #pragma fragment frag 13 | 14 | #include "UnityCG.cginc" 15 | 16 | struct appdata { 17 | float4 vertex : POSITION; 18 | float2 uv : TEXCOORD0; 19 | }; 20 | 21 | struct v2f { 22 | float2 uv : TEXCOORD0; 23 | float4 vertex : SV_POSITION; 24 | }; 25 | 26 | float4 _Source; 27 | float _Radius; 28 | 29 | v2f vert (appdata v) { 30 | v2f o; 31 | o.vertex = UnityObjectToClipPos(v.vertex); 32 | o.uv = v.uv; 33 | return o; 34 | } 35 | 36 | float4 frag (v2f i) : SV_Target { 37 | float aspect = _ScreenParams.x / _ScreenParams.y; 38 | float2 dpdt = (i.uv - _Source.zw) / float2(_Radius.x, _Radius.x * aspect); 39 | return float4(_Source.xy * saturate(1.0 - dot(dpdt, dpdt)), saturate(1.0 - dot(dpdt, dpdt)), 0); 40 | } 41 | ENDCG 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Assets/Tessellation/Shaders/AddSource.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e03d5bba968f8d24a865450a2f8c90d4 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Tessellation/Shaders/Solver2D.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 50afbfd09b32dad41a082447862bf9b1 3 | ComputeShaderImporter: 4 | externalObjects: {} 5 | currentAPIMask: 4 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Tessellation/Shaders/Tessellation.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a88752755817daa488dd454fecb21493 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Tessellation/Shaders/TessellationDisplacement.shader: -------------------------------------------------------------------------------- 1 | Shader "Tessellation/TessellationSurface" 2 | { 3 | Properties 4 | { 5 | _EdgeLength ("Edge length", Range(2,50)) = 15 6 | _MainTex ("Base (RGB)", 2D) = "white" {} 7 | _DispTex ("Disp Texture", 2D) = "black" {} 8 | _NormalMap ("Normalmap", 2D) = "bump" {} 9 | _Displacement ("Displacement", Range(0, 40.0)) = 0.3 10 | [Toggle] _Negative("Negative Displacement", Float) = 0 11 | _Color ("Color", color) = (1,1,1,0) 12 | _SpecColor ("Spec color", color) = (0.5,0.5,0.5,0.5) 13 | _Specular ("Specular", Range(0, 1) ) = 0.078125 14 | _Gloss ("Gloss", Range(0, 1) ) = 0.078125 15 | } 16 | SubShader 17 | { 18 | Tags { "RenderType"="Opaque" } 19 | LOD 300 20 | 21 | CGPROGRAM 22 | #pragma surface surf BlinnPhong addshadow fullforwardshadows vertex:disp tessellate:tessEdge nolightmap 23 | #pragma target 4.6 24 | #include "Tessellation.cginc" 25 | #pragma shader_feature _NEGATIVE_ON 26 | 27 | struct appdata { 28 | float4 vertex : POSITION; 29 | float4 tangent : TANGENT; 30 | float3 normal : NORMAL; 31 | float2 texcoord : TEXCOORD0; 32 | }; 33 | 34 | sampler2D _DispTex; 35 | float _Displacement; 36 | float _EdgeLength; 37 | float _Specular; 38 | float _Gloss; 39 | 40 | float4 tessEdge (appdata v0, appdata v1, appdata v2) 41 | { 42 | return UnityEdgeLengthBasedTessCull(v0.vertex, v1.vertex, v2.vertex, _EdgeLength, _Displacement * 1.5f); 43 | } 44 | 45 | void disp (inout appdata v) 46 | { 47 | float d = tex2Dlod(_DispTex, float4(v.texcoord.xy,0,0)).r * _Displacement; 48 | #ifdef _NEGATIVE_ON 49 | v.vertex.xyz -= v.normal * d; 50 | #else 51 | v.vertex.xyz += v.normal * d; 52 | #endif 53 | } 54 | 55 | struct Input { 56 | float2 uv_MainTex; 57 | }; 58 | 59 | sampler2D _MainTex; 60 | sampler2D _NormalMap; 61 | fixed4 _Color; 62 | 63 | void surf (Input IN, inout SurfaceOutput o) { 64 | half4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; 65 | o.Albedo = c.rgb; 66 | o.Specular = _Specular; 67 | o.Gloss = _Gloss; 68 | o.Normal = UnpackNormal(tex2D(_NormalMap, IN.uv_MainTex)); 69 | } 70 | ENDCG 71 | } 72 | FallBack "Diffuse" 73 | } 74 | -------------------------------------------------------------------------------- /Assets/Tessellation/Shaders/TessellationDisplacement.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0b91c1f579471a3429b7f1fa4c5bbf25 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Tessellation/Shaders/TessellationSurface.shader: -------------------------------------------------------------------------------- 1 | Shader "Tessellation/TessellationSurface" 2 | { 3 | Properties 4 | { 5 | _EdgeLength ("Edge length", Range(2,50)) = 15 6 | _MainTex ("Base (RGB)", 2D) = "white" {} 7 | _DispTex ("Disp Texture", 2D) = "black" {} 8 | _NormalMap ("Normalmap", 2D) = "bump" {} 9 | _Displacement ("Displacement", Range(0, 40.0)) = 0.3 10 | [Toggle] _Negative("Negative Displacement", Float) = 0 11 | _Color ("Color", color) = (1,1,1,0) 12 | _SpecColor ("Spec color", color) = (0.5,0.5,0.5,0.5) 13 | _Specular ("Specular", Range(0, 1) ) = 0.078125 14 | _Gloss ("Gloss", Range(0, 1) ) = 0.078125 15 | } 16 | SubShader 17 | { 18 | Tags { "RenderType"="Opaque" } 19 | LOD 300 20 | 21 | CGPROGRAM 22 | #pragma surface surf BlinnPhong addshadow fullforwardshadows vertex:disp tessellate:tessEdge nolightmap 23 | #pragma target 4.6 24 | #include "Tessellation.cginc" 25 | #pragma shader_feature _NEGATIVE_ON 26 | 27 | struct appdata { 28 | float4 vertex : POSITION; 29 | float4 tangent : TANGENT; 30 | float3 normal : NORMAL; 31 | float2 texcoord : TEXCOORD0; 32 | }; 33 | 34 | sampler2D _DispTex; 35 | float _Displacement; 36 | float _EdgeLength; 37 | float _Specular; 38 | float _Gloss; 39 | 40 | float4 tessEdge (appdata v0, appdata v1, appdata v2) 41 | { 42 | //return UnityEdgeLengthBasedTess (v0.vertex, v1.vertex, v2.vertex, _EdgeLength); 43 | return UnityEdgeLengthBasedTessCull(v0.vertex, v1.vertex, v2.vertex, _EdgeLength, _Displacement * 1.5f); 44 | } 45 | 46 | void disp (inout appdata v) 47 | { 48 | float d = tex2Dlod(_DispTex, float4(v.texcoord.xy,0,0)).r * _Displacement; 49 | #ifdef _NEGATIVE_ON 50 | v.vertex.xyz -= v.normal * d; 51 | #else 52 | v.vertex.xyz += v.normal * d; 53 | #endif 54 | } 55 | 56 | struct Input { 57 | float2 uv_MainTex; 58 | }; 59 | 60 | sampler2D _MainTex; 61 | sampler2D _NormalMap; 62 | fixed4 _Color; 63 | 64 | void surf (Input IN, inout SurfaceOutput o) { 65 | half4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; 66 | o.Albedo = c.rgb; 67 | o.Specular = _Specular; 68 | o.Gloss = _Gloss; 69 | o.Normal = UnpackNormal(tex2D(_NormalMap, IN.uv_MainTex)); 70 | } 71 | ENDCG 72 | } 73 | FallBack "Diffuse" 74 | } 75 | -------------------------------------------------------------------------------- /Assets/Tessellation/Shaders/TessellationSurface.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c65abc0b6c0b7a04a8d7598224816ca4 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Tessellation/Textures.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fcf34f7b6ac10c341bb08fbf3defce61 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Tessellation/Textures/diffuse.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndieVisualLab/UnityGraphicsProgramming4/dd6822e22acb96118385f92a66eb7a285f2fae76/Assets/Tessellation/Textures/diffuse.tga -------------------------------------------------------------------------------- /Assets/Tessellation/Textures/diffuse.tga.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7a9b7d0f2d38d34e8aa614e453fad1d 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 9 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | platformSettings: 61 | - serializedVersion: 2 62 | buildTarget: DefaultTexturePlatform 63 | maxTextureSize: 2048 64 | resizeAlgorithm: 0 65 | textureFormat: -1 66 | textureCompression: 1 67 | compressionQuality: 50 68 | crunchedCompression: 0 69 | allowsAlphaSplitting: 0 70 | overridden: 0 71 | androidETC2FallbackOverride: 0 72 | spriteSheet: 73 | serializedVersion: 2 74 | sprites: [] 75 | outline: [] 76 | physicsShape: [] 77 | bones: [] 78 | spriteID: 79 | vertices: [] 80 | indices: 81 | edges: [] 82 | weights: [] 83 | spritePackingTag: 84 | pSDRemoveMatte: 0 85 | pSDShowRemoveMatteOption: 0 86 | userData: 87 | assetBundleName: 88 | assetBundleVariant: 89 | -------------------------------------------------------------------------------- /Assets/Tessellation/Textures/normal.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndieVisualLab/UnityGraphicsProgramming4/dd6822e22acb96118385f92a66eb7a285f2fae76/Assets/Tessellation/Textures/normal.tga -------------------------------------------------------------------------------- /Assets/Tessellation/Textures/normal.tga.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e33cce1d800daa43b067ac4e2559c16 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 9 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 0 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: 2 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 1 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | platformSettings: 61 | - serializedVersion: 2 62 | buildTarget: DefaultTexturePlatform 63 | maxTextureSize: 2048 64 | resizeAlgorithm: 0 65 | textureFormat: -1 66 | textureCompression: 1 67 | compressionQuality: 50 68 | crunchedCompression: 0 69 | allowsAlphaSplitting: 0 70 | overridden: 0 71 | androidETC2FallbackOverride: 0 72 | - serializedVersion: 2 73 | buildTarget: Standalone 74 | maxTextureSize: 2048 75 | resizeAlgorithm: 0 76 | textureFormat: -1 77 | textureCompression: 1 78 | compressionQuality: 50 79 | crunchedCompression: 0 80 | allowsAlphaSplitting: 0 81 | overridden: 0 82 | androidETC2FallbackOverride: 0 83 | spriteSheet: 84 | serializedVersion: 2 85 | sprites: [] 86 | outline: [] 87 | physicsShape: [] 88 | bones: [] 89 | spriteID: 90 | vertices: [] 91 | indices: 92 | edges: [] 93 | weights: [] 94 | spritePackingTag: 95 | pSDRemoveMatte: 0 96 | pSDShowRemoveMatteOption: 0 97 | userData: 98 | assetBundleName: 99 | assetBundleVariant: 100 | -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d3f6792005ec2fc40a01fe9e400e786d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49259ce87dbbcdc4f9ab8b39331d03ec 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Materials/TestMaterial.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: TestMaterial 11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 2800000, guid: a088a95b03bbb254db0110a1f7f810d2, type: 3} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 1, g: 1, b: 1, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Materials/TestMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 11dc62e76e6cb7a45b238d3ca7e5ee44 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f704ae4b4f98ae41a0bce26658850c1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Scenes/DrawTest.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd15549fa443011478304729a2cd5b15 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Scenes/TriangulationTest.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99c9720ab356a0642a771bea13969a05 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22321e5745cdeb144bbb57077776c193 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Scripts/ArrayVector3.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace EarClippingTriangulation 6 | { 7 | [System.Serializable] 8 | public class ArrayVector3 9 | { 10 | public Vector3[] array; 11 | } 12 | } -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Scripts/ArrayVector3.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33cf6ff9e614ad746afa0ddf208a4d2a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Scripts/DrawingTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace EarClippingTriangulation 6 | { 7 | /// 8 | /// マウスで頂点を配置して多角形を作成する 9 | /// 10 | public class DrawingTest : MonoBehaviour 11 | { 12 | [SerializeField] 13 | Camera camera; 14 | [SerializeField] 15 | Transform marker; 16 | 17 | Material lineMaterial; 18 | Triangulation tri; 19 | 20 | List points = new List(); 21 | 22 | List pointList = new List(); 23 | 24 | // Start is called before the first frame update 25 | void Start() 26 | { 27 | tri = GetComponent(); 28 | 29 | } 30 | 31 | // Update is called once per frame 32 | void Update() 33 | { 34 | // 左クリックで点を打つ 35 | if (Input.GetMouseButtonDown(0)) 36 | { 37 | Vector3 pos = Input.mousePosition; 38 | pos.z = 5; 39 | Vector3 worldPos = camera.ScreenToWorldPoint(pos); 40 | marker.position = worldPos; 41 | 42 | Debug.Log("pos " + pos + " worldPos " + worldPos); 43 | points.Add(worldPos); 44 | } 45 | 46 | // 右クリックで三角形分割する 47 | if (Input.GetMouseButtonDown(1) && (points.Count > 2)) 48 | { 49 | ArrayVector3 array = new ArrayVector3(); 50 | array.array = points.ToArray(); 51 | pointList.Add(array); 52 | points.Clear(); 53 | 54 | Triangulation(); 55 | } 56 | 57 | if (Input.GetKeyDown(KeyCode.C)) 58 | { 59 | pointList.Clear(); 60 | points.Clear(); 61 | if (tri != null) 62 | { 63 | tri.ClearPolygon(); 64 | } 65 | } 66 | 67 | if(Input.GetKeyDown(KeyCode.U)) 68 | { 69 | pointList.RemoveAt(pointList.Count - 1); 70 | points.Clear(); 71 | Triangulation(); 72 | } 73 | } 74 | 75 | void Triangulation() 76 | { 77 | if (tri != null) 78 | { 79 | tri.ClearPolygon(); 80 | 81 | for (int i = 0; i < pointList.Count; i++) 82 | { 83 | tri.AddPolygon(new Polygon(pointList[i].array)); 84 | } 85 | 86 | tri.Triangulate(); 87 | } 88 | } 89 | 90 | private void OnRenderObject() 91 | { 92 | if (points.Count == 0) 93 | return; 94 | 95 | if (!lineMaterial) 96 | { 97 | // Unity has a built-in shader that is useful for drawing 98 | // simple colored things. 99 | Shader shader = Shader.Find("Hidden/Internal-Colored"); 100 | lineMaterial = new Material(shader); 101 | lineMaterial.hideFlags = HideFlags.HideAndDontSave; 102 | // Turn on alpha blending 103 | lineMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); 104 | lineMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); 105 | // Turn backface culling off 106 | lineMaterial.SetInt("_Cull", (int)UnityEngine.Rendering.CullMode.Off); 107 | // Turn off depth writes 108 | lineMaterial.SetInt("_ZWrite", 0); 109 | } 110 | 111 | // Apply the line material 112 | lineMaterial.SetPass(0); 113 | 114 | GL.PushMatrix(); 115 | // Set transformation matrix for drawing to 116 | // match our transform 117 | GL.MultMatrix(transform.localToWorldMatrix); 118 | 119 | // Draw lines 120 | GL.Begin(GL.LINE_STRIP); 121 | for (int i = 0; i <= points.Count; ++i) 122 | { 123 | int index = i % points.Count; 124 | // Vertex colors change from red to green 125 | GL.Color(Color.HSVToRGB(Mathf.Sin(Time.time * 0.5f) * 0.5f + 0.5f, 1, 1)); 126 | // One vertex at transform position 127 | GL.Vertex(points[index]); 128 | } 129 | GL.End(); 130 | GL.PopMatrix(); 131 | } 132 | 133 | void DrawPolygon(Vector3[] vertices, Color color) 134 | { 135 | Gizmos.color = color; 136 | for (int i = 0; i < vertices.Length; i++) 137 | { 138 | int nextIndex = (i + 1) % vertices.Length; 139 | 140 | Gizmos.DrawLine(vertices[i], vertices[nextIndex]); 141 | #if UNITY_EDITOR 142 | UnityEditor.Handles.color = color; 143 | UnityEditor.Handles.Label(vertices[i], "[" + i + "]"); 144 | #endif 145 | } 146 | } 147 | 148 | private void OnDrawGizmos() 149 | { 150 | DrawPolygon(points.ToArray(), Color.magenta); 151 | } 152 | } 153 | } -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Scripts/DrawingTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3cb7779489008f54bb86002048dc6187 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Scripts/GeometryUtil.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b4106b41f083170478ad002d87195988 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Scripts/Polygon.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2b05e10a25aa5444ba526a0875cbe3f9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Scripts/TreeNode.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace EarClippingTriangulation 6 | { 7 | public class TreeNode 8 | { 9 | public TreeNode parent = null; 10 | public List> children = new List>(); 11 | 12 | public T Value; 13 | public bool isValue = false; 14 | 15 | public TreeNode(T val) 16 | { 17 | Value = val; 18 | isValue = true; 19 | } 20 | 21 | public TreeNode() 22 | { 23 | isValue = false; 24 | } 25 | 26 | public void AddChild(T val) 27 | { 28 | AddChild(new TreeNode(val)); 29 | } 30 | 31 | public void AddChild(TreeNode tree) 32 | { 33 | children.Add(tree); 34 | tree.parent = this; 35 | } 36 | 37 | public void RemoveChild(TreeNode tree) 38 | { 39 | if (children.Contains(tree)) 40 | { 41 | children.Remove(tree); 42 | tree.parent = null; 43 | } 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Scripts/TreeNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 847f6c6de5111594cb2982029c5236a8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Scripts/Triangle.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace EarClippingTriangulation 6 | { 7 | public class Triangle 8 | { 9 | 10 | public Vector3[] vertices = new Vector3[3]; 11 | public string name; 12 | 13 | public Triangle(Vector3 p1, Vector3 p2, Vector3 p3, string n) 14 | { 15 | vertices[0] = p1; 16 | vertices[1] = p2; 17 | vertices[2] = p3; 18 | name = n; 19 | } 20 | 21 | #if UNITY_EDITOR 22 | public void OnDrawGizmos() 23 | { 24 | Gizmos.color = Color.magenta; 25 | Vector3 center = Vector3.zero; 26 | for (int i = 0; i < vertices.Length; i++) 27 | { 28 | int nextIndex = (i + 1) % vertices.Length; 29 | Gizmos.DrawLine(vertices[i], vertices[nextIndex]); 30 | center += vertices[i]; 31 | } 32 | 33 | center.x /= 3; 34 | center.y /= 3; 35 | center.z /= 3; 36 | 37 | UnityEditor.Handles.Label(center, name); 38 | } 39 | #endif 40 | } 41 | } -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Scripts/Triangle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff853552f9a2b5c45aa3233463a9709a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Scripts/Triangulation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e4f3e5a80c5238489da41b614030521 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Scripts/TriangulrationTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace EarClippingTriangulation { 6 | /// 7 | /// 決め打ち座標で多角形を作成する 8 | /// 9 | public class TriangulrationTest : MonoBehaviour { 10 | 11 | public ArrayVector3[] nestedVertices; 12 | 13 | 14 | // Use this for initialization 15 | void Start() { 16 | Triangulation tri = GetComponent(); 17 | 18 | if(tri != null) 19 | { 20 | 21 | for (int i = 0; i < nestedVertices.Length; i++) 22 | { 23 | //DrawPolygon(ref nestedVertices[i].array, Color.HSVToRGB((float)i / nestedVertices.Length, 1, 1)); 24 | tri.AddPolygon(new Polygon(nestedVertices[i].array)); 25 | } 26 | 27 | tri.Triangulate(); 28 | } 29 | } 30 | 31 | void DrawPolygon(ref Vector3[] vertices, Color color, int index) 32 | { 33 | Gizmos.color = color; 34 | Vector3 centerPos = Vector3.zero; 35 | 36 | for (int i = 0; i < vertices.Length; i++) 37 | { 38 | int nextIndex = (i + 1) % vertices.Length; 39 | 40 | Gizmos.DrawLine(vertices[i], vertices[nextIndex]); 41 | centerPos += vertices[i]; 42 | #if UNITY_EDITOR 43 | UnityEditor.Handles.Label(vertices[i], "[" + i + "]"); 44 | #endif 45 | } 46 | centerPos /= vertices.Length; 47 | 48 | #if UNITY_EDITOR 49 | UnityEditor.Handles.Label(centerPos, "{" + index + "}"); 50 | #endif 51 | } 52 | 53 | private void OnDrawGizmos() 54 | { 55 | if (!Application.isPlaying) 56 | { 57 | for(int i = 0; i < nestedVertices.Length; i++) 58 | { 59 | DrawPolygon(ref nestedVertices[i].array, Color.HSVToRGB((float)i / nestedVertices.Length, 1, 1), i); 60 | } 61 | } 62 | } 63 | 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Scripts/TriangulrationTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 40dca4a2e63b1f64e81b4ce4cebac547 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Textures.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0cbe26da3983e98479bbc13d369bc9a4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Textures/kaiware.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IndieVisualLab/UnityGraphicsProgramming4/dd6822e22acb96118385f92a66eb7a285f2fae76/Assets/TriangulationByEarClipping/Textures/kaiware.png -------------------------------------------------------------------------------- /Assets/TriangulationByEarClipping/Textures/kaiware.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a088a95b03bbb254db0110a1f7f810d2 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 7 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | platformSettings: 61 | - serializedVersion: 2 62 | buildTarget: DefaultTexturePlatform 63 | maxTextureSize: 512 64 | resizeAlgorithm: 0 65 | textureFormat: -1 66 | textureCompression: 1 67 | compressionQuality: 50 68 | crunchedCompression: 0 69 | allowsAlphaSplitting: 0 70 | overridden: 0 71 | androidETC2FallbackOverride: 0 72 | - serializedVersion: 2 73 | buildTarget: Standalone 74 | maxTextureSize: 512 75 | resizeAlgorithm: 0 76 | textureFormat: -1 77 | textureCompression: 1 78 | compressionQuality: 50 79 | crunchedCompression: 0 80 | allowsAlphaSplitting: 0 81 | overridden: 0 82 | androidETC2FallbackOverride: 0 83 | spriteSheet: 84 | serializedVersion: 2 85 | sprites: [] 86 | outline: [] 87 | physicsShape: [] 88 | bones: [] 89 | spriteID: 90 | vertices: [] 91 | indices: 92 | edges: [] 93 | weights: [] 94 | spritePackingTag: 95 | pSDRemoveMatte: 0 96 | pSDShowRemoveMatteOption: 0 97 | userData: 98 | assetBundleName: 99 | assetBundleVariant: 100 | -------------------------------------------------------------------------------- /Logs/Packages-Update.log: -------------------------------------------------------------------------------- 1 | 2 | === Mon Apr 1 13:12:26 2019 3 | 4 | Packages were changed. 5 | Update Mode: mergeDefaultDependencies 6 | 7 | The following packages were added: 8 | com.unity.analytics@3.2.2 9 | com.unity.purchasing@2.0.3 10 | com.unity.ads@2.0.8 11 | com.unity.textmeshpro@1.3.0 12 | com.unity.package-manager-ui@2.0.7 13 | com.unity.collab-proxy@1.2.15 14 | com.unity.modules.ai@1.0.0 15 | com.unity.modules.animation@1.0.0 16 | com.unity.modules.assetbundle@1.0.0 17 | com.unity.modules.audio@1.0.0 18 | com.unity.modules.cloth@1.0.0 19 | com.unity.modules.director@1.0.0 20 | com.unity.modules.imageconversion@1.0.0 21 | com.unity.modules.imgui@1.0.0 22 | com.unity.modules.jsonserialize@1.0.0 23 | com.unity.modules.particlesystem@1.0.0 24 | com.unity.modules.physics@1.0.0 25 | com.unity.modules.physics2d@1.0.0 26 | com.unity.modules.screencapture@1.0.0 27 | com.unity.modules.terrain@1.0.0 28 | com.unity.modules.terrainphysics@1.0.0 29 | com.unity.modules.tilemap@1.0.0 30 | com.unity.modules.ui@1.0.0 31 | com.unity.modules.uielements@1.0.0 32 | com.unity.modules.umbra@1.0.0 33 | com.unity.modules.unityanalytics@1.0.0 34 | com.unity.modules.unitywebrequest@1.0.0 35 | com.unity.modules.unitywebrequestassetbundle@1.0.0 36 | com.unity.modules.unitywebrequestaudio@1.0.0 37 | com.unity.modules.unitywebrequesttexture@1.0.0 38 | com.unity.modules.unitywebrequestwww@1.0.0 39 | com.unity.modules.vehicles@1.0.0 40 | com.unity.modules.video@1.0.0 41 | com.unity.modules.vr@1.0.0 42 | com.unity.modules.wind@1.0.0 43 | com.unity.modules.xr@1.0.0 44 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.ads": "2.0.8", 4 | "com.unity.analytics": "3.2.2", 5 | "com.unity.collab-proxy": "1.2.15", 6 | "com.unity.package-manager-ui": "2.0.7", 7 | "com.unity.purchasing": "2.0.3", 8 | "com.unity.textmeshpro": "1.3.0", 9 | "com.unity.modules.ai": "1.0.0", 10 | "com.unity.modules.animation": "1.0.0", 11 | "com.unity.modules.assetbundle": "1.0.0", 12 | "com.unity.modules.audio": "1.0.0", 13 | "com.unity.modules.cloth": "1.0.0", 14 | "com.unity.modules.director": "1.0.0", 15 | "com.unity.modules.imageconversion": "1.0.0", 16 | "com.unity.modules.imgui": "1.0.0", 17 | "com.unity.modules.jsonserialize": "1.0.0", 18 | "com.unity.modules.particlesystem": "1.0.0", 19 | "com.unity.modules.physics": "1.0.0", 20 | "com.unity.modules.physics2d": "1.0.0", 21 | "com.unity.modules.screencapture": "1.0.0", 22 | "com.unity.modules.terrain": "1.0.0", 23 | "com.unity.modules.terrainphysics": "1.0.0", 24 | "com.unity.modules.tilemap": "1.0.0", 25 | "com.unity.modules.ui": "1.0.0", 26 | "com.unity.modules.uielements": "1.0.0", 27 | "com.unity.modules.umbra": "1.0.0", 28 | "com.unity.modules.unityanalytics": "1.0.0", 29 | "com.unity.modules.unitywebrequest": "1.0.0", 30 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 31 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 32 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 33 | "com.unity.modules.unitywebrequestwww": "1.0.0", 34 | "com.unity.modules.vehicles": "1.0.0", 35 | "com.unity.modules.video": "1.0.0", 36 | "com.unity.modules.vr": "1.0.0", 37 | "com.unity.modules.wind": "1.0.0", 38 | "com.unity.modules.xr": "1.0.0" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 1024 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_AmbisonicDecoderPlugin: 16 | m_DisableAudio: 0 17 | m_VirtualizeEffects: 1 18 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 8 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 1 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ContactPairsMode: 0 26 | m_BroadphaseType: 0 27 | m_WorldBounds: 28 | m_Center: {x: 0, y: 0, z: 0} 29 | m_Extent: {x: 250, y: 250, z: 250} 30 | m_WorldSubdivisions: 8 31 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | m_configObjects: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 7 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 2 10 | m_DefaultBehaviorMode: 0 11 | m_SpritePackerMode: 0 12 | m_SpritePackerPaddingPower: 1 13 | m_EtcTextureCompressorBehavior: 1 14 | m_EtcTextureFastCompressor: 1 15 | m_EtcTextureNormalCompressor: 2 16 | m_EtcTextureBestCompressor: 4 17 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd 18 | m_ProjectGenerationRootNamespace: 19 | m_UserGeneratedProjectSuffix: 20 | m_CollabEditorSettings: 21 | inProgressEnabled: 1 22 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 12 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | - {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0} 39 | m_PreloadedShaders: [] 40 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 41 | type: 0} 42 | m_CustomRenderPipeline: {fileID: 0} 43 | m_TransparencySortMode: 0 44 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 45 | m_DefaultRenderingPath: 1 46 | m_DefaultMobileRenderingPath: 1 47 | m_TierSettings: [] 48 | m_LightmapStripping: 0 49 | m_FogStripping: 0 50 | m_InstancingStripping: 0 51 | m_LightmapKeepPlain: 1 52 | m_LightmapKeepDirCombined: 1 53 | m_LightmapKeepDynamicPlain: 1 54 | m_LightmapKeepDynamicDirCombined: 1 55 | m_LightmapKeepShadowMask: 1 56 | m_LightmapKeepSubtractive: 1 57 | m_FogKeepLinear: 1 58 | m_FogKeepExp: 1 59 | m_FogKeepExp2: 1 60 | m_AlbedoSwatchInfos: [] 61 | m_LightsUseLinearIntensity: 0 62 | m_LightsUseColorTemperature: 0 63 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_AutoSimulation: 1 23 | m_QueriesHitTriggers: 1 24 | m_QueriesStartInColliders: 1 25 | m_ChangeStopsCallbacks: 0 26 | m_CallbacksOnDisable: 1 27 | m_ReuseCollisionCallbacks: 1 28 | m_AutoSyncTransforms: 0 29 | m_AlwaysShowColliders: 0 30 | m_ShowColliderSleep: 1 31 | m_ShowColliderContacts: 0 32 | m_ShowColliderAABB: 0 33 | m_ContactArrowScale: 0.2 34 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 35 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 36 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 37 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 38 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 39 | -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | m_DefaultList: 7 | - type: 8 | m_NativeTypeID: 108 9 | m_ManagedTypePPtr: {fileID: 0} 10 | m_ManagedTypeFallback: 11 | defaultPresets: 12 | - m_Preset: {fileID: 2655988077585873504, guid: c1cf8506f04ef2c4a88b64b6c4202eea, 13 | type: 2} 14 | - type: 15 | m_NativeTypeID: 1020 16 | m_ManagedTypePPtr: {fileID: 0} 17 | m_ManagedTypeFallback: 18 | defaultPresets: 19 | - m_Preset: {fileID: 2655988077585873504, guid: 0cd792cc87e492d43b4e95b205fc5cc6, 20 | type: 2} 21 | - type: 22 | m_NativeTypeID: 1006 23 | m_ManagedTypePPtr: {fileID: 0} 24 | m_ManagedTypeFallback: 25 | defaultPresets: 26 | - m_Preset: {fileID: 2655988077585873504, guid: 7a99f8aa944efe94cb9bd74562b7d5f9, 27 | type: 2} 28 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2018.3.9f1 2 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - PostProcessing 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.1 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_TestInitMode: 0 13 | CrashReportingSettings: 14 | m_EventUrl: https://perf-events.cloud.unity3d.com 15 | m_Enabled: 0 16 | m_LogBufferSize: 10 17 | m_CaptureEditorExceptions: 1 18 | UnityPurchasingSettings: 19 | m_Enabled: 0 20 | m_TestMode: 0 21 | UnityAnalyticsSettings: 22 | m_Enabled: 0 23 | m_TestMode: 0 24 | m_InitializeOnStartup: 1 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_RenderPipeSettingsPath: 10 | m_FixedTimeStep: 0.016666668 11 | m_MaxDeltaTime: 0.05 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | UnityGraphicsProgramming vol.4 2 | ===================== 3 | 4 | [IndieVisualLab](https://IndieVisualLab.github.io)によるUnity技術の同人誌「UnityGraphicsProgramming vol.4」のリポジトリ 5 | 6 | - 第1章 GPU-Based Space Colonization Algorithm [@mattatz](https://github.com/mattatz) - [サンプルコード](https://github.com/IndieVisualLab/UnityGraphicsProgramming4/tree/master/Assets/SpaceColonization) 7 | - 第2章 Limit sets of Kleinian groups [@fuqunaga](https://github.com/fuqunaga) - [サンプルコード](https://github.com/IndieVisualLab/UnityGraphicsProgramming4/tree/master/Assets/KleinianGroup) 8 | - 第3章 GPU-Based Cloth Simulation [@hiroakioishi](https://github.com/hiroakioishi) - [サンプルコード](https://github.com/IndieVisualLab/UnityGraphicsProgramming4/tree/master/Assets/GPUClothSimulation) 9 | - 第4章 StarGlow [@XJINE](https://github.com/XJINE) - [サンプルコード](https://github.com/IndieVisualLab/UnityGraphicsProgramming4/tree/master/Assets/StarGlow) 10 | - 第5章 Triangulation by Ear Clipping [@kaiware007](https://github.com/kaiware007) - [サンプルコード](https://github.com/IndieVisualLab/UnityGraphicsProgramming4/tree/master/Assets/TriangulationByEarClipping) 11 | - 第6章 Tessellation & Displacement [@sakope](https://github.com/sakope) - [サンプルコード](https://github.com/IndieVisualLab/UnityGraphicsProgramming4/tree/master/Assets/Tessellation) 12 | - 第7章 Poisson Disk Sampling [@a3geek](https://github.com/a3geek) - [サンプルコード](https://github.com/IndieVisualLab/UnityGraphicsProgramming4/tree/master/Assets/PoissonDiskSampling) 13 | --------------------------------------------------------------------------------