Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
keijiro committed Jan 23, 2018
0 parents commit f92a3ef
Show file tree
Hide file tree
Showing 56 changed files with 5,970 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitattributes
@@ -0,0 +1,9 @@
* -text

*.cs text eol=lf diff=csharp
*.shader text eol=lf
*.cginc text eol=lf
*.hlsl text eol=lf
*.compute text eol=lf

*.meta text eol=lf
13 changes: 13 additions & 0 deletions .gitignore
@@ -0,0 +1,13 @@
# Windows
Thumbs.db
Desktop.ini

# macOS
.DS_Store

# Vim
*.swp

# Unity
/Library
/Temp
8 changes: 8 additions & 0 deletions Assets/Retro3D.meta

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

8 changes: 8 additions & 0 deletions Assets/Retro3D/Editor.meta

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

32 changes: 32 additions & 0 deletions Assets/Retro3D/Editor/Retro3DPipelineAsset.cs
@@ -0,0 +1,32 @@
using UnityEditor;
using UnityEngine.Experimental.Rendering;
using UnityEditor.ProjectWindowCallback;

namespace Retro3D
{
class Retro3DPipelineAsset : RenderPipelineAsset
{
[MenuItem("Assets/Create/Render Pipeline/Retro3D/Pipeline Asset")]
static void CreateRetro3DPipeline()
{
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(
0, CreateInstance<CreateRetro3DPipelineAsset>(),
"Retro3D Pipeline.asset", null, null
);
}

class CreateRetro3DPipelineAsset : EndNameEditAction
{
public override void Action(int instanceId, string pathName, string resourceFile)
{
var instance = CreateInstance<Retro3DPipelineAsset>();
AssetDatabase.CreateAsset(instance, pathName);
}
}

protected override IRenderPipeline InternalCreatePipeline()
{
return new Retro3DPipeline();
}
}
}
11 changes: 11 additions & 0 deletions Assets/Retro3D/Editor/Retro3DPipelineAsset.cs.meta

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

46 changes: 46 additions & 0 deletions Assets/Retro3D/Retro3DPipeline.cs
@@ -0,0 +1,46 @@
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;

namespace Retro3D
{
public class Retro3DPipeline : RenderPipeline
{
CommandBuffer _clearCommand;

public override void Dispose()
{
base.Dispose();

if (_clearCommand != null) _clearCommand.Dispose();
}

public override void Render(ScriptableRenderContext context, Camera[] cameras)
{
base.Render(context, cameras);

if (_clearCommand == null)
{
_clearCommand = new CommandBuffer();
_clearCommand.name = "Clear";
_clearCommand.ClearRenderTarget(true, true, Color.black);
}

foreach (var camera in cameras)
{
context.ExecuteCommandBuffer(_clearCommand);

var culled = new CullResults();
CullResults.Cull(camera, context, out culled);
context.SetupCameraProperties(camera);

var settings = new DrawRendererSettings(camera, new ShaderPassName("Base"));
var filter = new FilterRenderersSettings(true);
filter.renderQueueRange = RenderQueueRange.opaque;
context.DrawRenderers(culled.visibleRenderers, ref settings, filter);

context.Submit();
}
}
}
}
11 changes: 11 additions & 0 deletions Assets/Retro3D/Retro3DPipeline.cs.meta

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

65 changes: 65 additions & 0 deletions Assets/Retro3D/Retro3DSurface.shader
@@ -0,0 +1,65 @@
Shader "Retro3D/Surface"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
_Color("Tint", Color) = (0.5, 0.5, 0.5)
}

HLSLINCLUDE

#include "UnityCG.cginc"

sampler2D _MainTex;
float4 _MainTex_ST;
half3 _Color;

struct Attributes
{
float4 position : POSITION;
float2 texcoord : TEXCOORD;
};

struct Varyings
{
float4 position : SV_POSITION;
noperspective float2 texcoord : TEXCOORD;
UNITY_FOG_COORDS(1)
};

Varyings Vertex(Attributes input)
{
float3 vp = UnityObjectToViewPos(input.position.xyz);
vp = floor(vp * 64) / 64;
Varyings output;
output.position = UnityViewToClipPos(vp);
output.texcoord = TRANSFORM_TEX(input.texcoord, _MainTex);
UNITY_TRANSFER_FOG(output, output.position);
return output;
}

half4 Fragment(Varyings input) : SV_Target
{
float2 uv = input.texcoord;
uv = floor(uv * 256) / 256;
half4 c = tex2D(_MainTex, uv);
c = floor(c * 12) / 12;
c.rgb *= _Color * 2;
UNITY_APPLY_FOG(input.fogCoord, c);
return c;
}

ENDHLSL

SubShader
{
Pass
{
Tags { "LightMode" = "Base" }
HLSLPROGRAM
#pragma vertex Vertex
#pragma fragment Fragment
ENDHLSL
}
}
}
9 changes: 9 additions & 0 deletions Assets/Retro3D/Retro3DSurface.shader.meta

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

9 changes: 9 additions & 0 deletions Assets/Standard Assets.meta

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

9 changes: 9 additions & 0 deletions Assets/Standard Assets/Characters.meta

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

9 changes: 9 additions & 0 deletions Assets/Standard Assets/Characters/ThirdPersonCharacter.meta

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

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

Binary file not shown.

0 comments on commit f92a3ef

Please sign in to comment.