Skip to content

Commit

Permalink
Merge pull request #18 from dkavolis/debug_voxels
Browse files Browse the repository at this point in the history
Debug voxels
  • Loading branch information
dkavolis authored Dec 27, 2018
2 parents 898a04b + 08848b9 commit 9f32e2a
Show file tree
Hide file tree
Showing 15 changed files with 577 additions and 215 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Material:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: FARGraphMaterial
m_Shader: {fileID: 4800000, guid: 37009ed9069dfce43a12d30fc381f931, type: 3}
m_ShaderKeywords: _FRESNEL_OFF _GLOSSYREFLECTIONS_OFF _METALLICGLOSSMAP _SPECGLOSSMAP
_SPECULARHIGHLIGHTS_OFF _TEXCOORD_UV
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _FRESNEL_OFF _GLOSSYREFLECTIONS_OFF _SPECGLOSSMAP _SPECULARHIGHLIGHTS_OFF
_TEXCOORD_UV
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
Expand Down Expand Up @@ -48,11 +48,11 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 0bbb43aff4f7811419ffceb1b16cf3d6, type: 3}
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 10300, guid: 0000000000000000f000000000000000, type: 0}
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
Expand Down Expand Up @@ -107,7 +107,7 @@ Material:
- _ZWrite: 1
m_Colors:
- _BurnColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 0, b: 0, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _RimColor: {r: 0, g: 0.375, b: 0.01810348, a: 0}
Expand Down
78 changes: 78 additions & 0 deletions Assets/Materials/FARVoxelMeshMaterial.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
%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: FARVoxelMeshMaterial
m_Shader: {fileID: 4800000, guid: 31ef6a8843dfc6f4bbab6ae8daf6cb80, type: 3}
m_ShaderKeywords: _ALPHAPREMULTIPLY_ON _GLOSSYREFLECTIONS_OFF _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
_SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 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:
- PixelSnap: 0
- _BumpScale: 1
- _Cutoff: 0.45
- _DetailNormalMapScale: 1
- _DstBlend: 10
- _GlossMapScale: 1
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _Mode: 3
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 1
- _SpecularHighlights: 0
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 0
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
76 changes: 76 additions & 0 deletions Assets/Shaders/DebugVoxelMesh.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
Shader "FerramAerospaceResearch/Debug Voxel Mesh" {
Properties{
_Color("Color", Color) = (1,1,1,1)
[NoScaleOffset] _MainTex("Albedo (RGB)", 2D) = "white" {}
_Cutoff("Alpha Cutoff", Range(0.01,1)) = 0.5
}
SubShader
{
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" "PreviewType" = "Plane"}
Blend SrcAlpha OneMinusSrcAlpha
LOD 200
ZWrite Off
Cull Off

// Simple AlphaTest pass to cut off transparent areas
Pass{
Tags{ "Queue" = "AlphaTest" "IgnoreProjector" = "True" "RenderType" = "TransparentCutout" }
ColorMask 0
ZWrite On

CGPROGRAM
#pragma vertex vert
#pragma fragment frag

#include "UnityCG.cginc"

struct v2f {
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
};

sampler2D _MainTex;
fixed _Cutoff;

v2f vert(appdata_img v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = v.texcoord;
return o;
}

fixed4 frag(v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.texcoord);
clip(col.a - _Cutoff);
return 0;
}
ENDCG
}

CGPROGRAM
#pragma surface surf Lambert alpha:blend decal:blend

sampler2D _MainTex;

struct Input {
float2 uv_MainTex;
};

fixed4 _Color;
fixed _Cutoff;

void surf(Input IN, inout SurfaceOutput o) {
// Albedo comes from a texture tinted by color
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;

// Need to set emmision to faded color for no lighting effect
o.Emission = c.rgb * c.a;
}
ENDCG
}
FallBack "Diffuse"
}
16 changes: 14 additions & 2 deletions FerramAerospaceResearch/FARAssets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ class FARAssets : MonoBehaviour
{

public static Dictionary<string, Material> materialDict;
public static Dictionary<string, Shader> shaderDict;

void Start()
{
materialDict = new Dictionary<string, Material>();
shaderDict = new Dictionary<string, Shader>();

/* FARLogger.Info("Asset bundles");
FARLogger.Info("" + AssetLoader.BundleDefinitions.Count);
Expand All @@ -32,12 +34,14 @@ void Start()
// AssetLoader.LoadAssets(LoadAssets,
// AssetLoader.GetAssetDefinitionWithName("FerramAerospaceResearch/Shaders/farshaders",
// "FARCrossSectionGraph"));
AssetLoader.LoadAssets(LoadAssets, AssetLoader.GetAssetDefinitionWithName("FerramAerospaceResearch/Assets/farassets", "FARGraphMaterial"));
AssetLoader.LoadAssets(LoadAssets, AssetLoader.GetAssetDefinitionsWithType("FerramAerospaceResearch/Assets/farassets", typeof(Material)));
AssetLoader.LoadAssets(LoadAssets, AssetLoader.GetAssetDefinitionsWithType("FerramAerospaceResearch/Assets/farassets", typeof(Shader)));
FARLogger.Info("Finished loading FAR Assets.");
}

void LoadAssets(AssetLoader.Loader loader)
{
for (int i = 0; i < loader.definitions.Length; i++ )
for (int i = 0; i < loader.definitions.Length; i++)
{
UnityEngine.Object o = loader.objects[i];
if (o == null)
Expand All @@ -47,8 +51,16 @@ void LoadAssets(AssetLoader.Loader loader)

// FARLogger.Info("Object " + i + " in bundle: " + o);
if (oType == typeof(Material))
{
FARLogger.Info("Adding material " + loader.definitions[i].name + " to dictionary");
materialDict.Add(loader.definitions[i].name, o as Material);
}

else if (oType == typeof(Shader))
{
FARLogger.Info("Adding shader " + loader.definitions[i].name + " to dictionary");
shaderDict.Add(loader.definitions[i].name, o as Shader);
}
}
}
}
Expand Down
Loading

0 comments on commit 9f32e2a

Please sign in to comment.