Skip to content

Commit

Permalink
Added SwirlingSwarm.
Browse files Browse the repository at this point in the history
  • Loading branch information
keijiro committed May 31, 2017
1 parent f8e337d commit d5b4800
Show file tree
Hide file tree
Showing 22 changed files with 675 additions and 295 deletions.
1 change: 0 additions & 1 deletion Assets/Swarm/CrawlerSwarm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ void Update()
_compute.SetFloat("NoiseFrequency", _noiseFrequency);
_compute.SetFloat("NoiseSpread", _noiseSpread / InstanceCount);
_compute.SetFloat("NoiseOffset", Time.time * _noiseMotion);
_compute.SetFloat("Time", Time.time);

// Update the position buffer.
var kernel = _compute.FindKernel("CrawlerUpdate");
Expand Down
6 changes: 3 additions & 3 deletions Assets/Swarm/CrawlerSwarm.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 54276434dda9c694e85abaf98cdd981d, type: 3}
m_Name: Default Gradient
m_Name: Default Swarm Gradient
m_EditorClassIdentifier:
_redCoeffs: {x: 0.5, y: 0.5, z: 1, w: 0}
_greenCoeffs: {x: 0.5, y: 0.5, z: 1, w: 0.333}
Expand Down
75 changes: 75 additions & 0 deletions Assets/Swarm/Editor/Default Tube Material.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Default Tube Material
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
9 changes: 9 additions & 0 deletions Assets/Swarm/Editor/Default Tube Material.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

144 changes: 144 additions & 0 deletions Assets/Swarm/Editor/Default Tube Template.asset

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions Assets/Swarm/Editor/Default Tube Template.asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions Assets/Swarm/Editor/SwirlingSwarmEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Swarm - Special renderer that draws a swarm of wobbling/crawling tubes.
// https://github.com/keijiro/Swarm

using UnityEngine;
using UnityEditor;

namespace Swarm
{
// Custom inspector for SwirlingSwarm
[CustomEditor(typeof(SwirlingSwarm)), CanEditMultipleObjects]
public class SwirlingSwarmEditor : Editor
{
SerializedProperty _instanceCount;

SerializedProperty _template;
SerializedProperty _radius;
SerializedProperty _material;
SerializedProperty _gradient;

SerializedProperty _spread;
SerializedProperty _length;
SerializedProperty _noiseFrequency;
SerializedProperty _noiseMotion;

void OnEnable()
{
_instanceCount = serializedObject.FindProperty("_instanceCount");

_template = serializedObject.FindProperty("_template");
_radius = serializedObject.FindProperty("_radius");
_material = serializedObject.FindProperty("_material");
_gradient = serializedObject.FindProperty("_gradient");

_spread = serializedObject.FindProperty("_spread");
_length = serializedObject.FindProperty("_length");
_noiseFrequency = serializedObject.FindProperty("_noiseFrequency");
_noiseMotion = serializedObject.FindProperty("_noiseMotion");
}

public override void OnInspectorGUI()
{
serializedObject.Update();

EditorGUILayout.PropertyField(_instanceCount);

EditorGUILayout.Space();

EditorGUILayout.PropertyField(_template);
EditorGUILayout.PropertyField(_radius);
EditorGUILayout.PropertyField(_material);
EditorGUILayout.PropertyField(_gradient);

EditorGUILayout.Space();

EditorGUILayout.PropertyField(_spread);
EditorGUILayout.PropertyField(_length);
EditorGUILayout.PropertyField(_noiseFrequency);
EditorGUILayout.PropertyField(_noiseMotion);

serializedObject.ApplyModifiedProperties();
}
}
}
12 changes: 12 additions & 0 deletions Assets/Swarm/Editor/SwirlingSwarmEditor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ CBUFFER_START(Params)
float NoiseFrequency;
float NoiseSpread;
float NoiseOffset;
float Time;
CBUFFER_END

float Random(float u, float v)
Expand Down Expand Up @@ -77,7 +76,7 @@ void CrawlerUpdate(uint id : SV_DispatchThreadID)
// Retrieve the previous position.
float3 p = PositionBuffer[IndexOffset1 + id].xyz;

// Sample the point in the distance field.
// Retrieve a sample from the distance field.
float4 df = SampleVolume(p);

// Two independent noise fields.
Expand Down
File renamed without changes.
118 changes: 0 additions & 118 deletions Assets/Swarm/Shader/SimplexNoiseGrad3D.cginc

This file was deleted.

9 changes: 0 additions & 9 deletions Assets/Swarm/Shader/SimplexNoiseGrad3D.cginc.meta

This file was deleted.

39 changes: 0 additions & 39 deletions Assets/Swarm/Shader/Swarm2.compute

This file was deleted.

Loading

0 comments on commit d5b4800

Please sign in to comment.