Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
keijiro committed Aug 15, 2015
1 parent b48a219 commit 4bc575b
Show file tree
Hide file tree
Showing 29 changed files with 2,998 additions and 0 deletions.
Binary file added Assets/Factory_Catwalk_Env.hdr
Binary file not shown.
56 changes: 56 additions & 0 deletions Assets/Factory_Catwalk_Env.hdr.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/Kino.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/Kino/Mirror.meta

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

81 changes: 81 additions & 0 deletions Assets/Kino/Mirror/Mirror.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//
// KinoMirror - Mirroring and kaleidoscope effect
//
// Copyright (C) 2015 Keijiro Takahashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using UnityEngine;

namespace Kino
{
[ExecuteInEditMode]
[RequireComponent(typeof(Camera))]
[AddComponentMenu("Kino Image Effects/Mirror")]
public class Mirror : MonoBehaviour
{
#region Public Properties

[SerializeField]
int _repeat;

[SerializeField]
float _offset;

[SerializeField]
float _roll;

[SerializeField]
bool _symmetry;

#endregion

#region Private Properties

[SerializeField] Shader _shader;
Material _material;

#endregion

#region MonoBehaviour Functions

void OnRenderImage(RenderTexture source, RenderTexture destination)
{
if (_material == null)
{
_material = new Material(_shader);
_material.hideFlags = HideFlags.DontSave;
}

var div = Mathf.PI * 2 / Mathf.Max(1, _repeat);

_material.SetFloat("_Divisor", div);
_material.SetFloat("_Offset", _offset);
_material.SetFloat("_Roll", _roll);

if (_symmetry)
_material.EnableKeyword("SYMMETRY_ON");
else
_material.DisableKeyword("SYMMETRY_ON");

Graphics.Blit(source, destination, _material);
}

#endregion
}
}
13 changes: 13 additions & 0 deletions Assets/Kino/Mirror/Mirror.cs.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/Kino/Mirror/Shader.meta

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

76 changes: 76 additions & 0 deletions Assets/Kino/Mirror/Shader/Mirror.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//
// KinoMirror - Mirroring and kaleidoscope effect
//
// Copyright (C) 2015 Keijiro Takahashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
Shader "Hidden/Kino/Mirror"
{
Properties
{
_MainTex ("-", 2D) = "" {}
}
CGINCLUDE

#include "UnityCG.cginc"

#pragma multi_compile _ SYMMETRY_ON

sampler2D _MainTex;
float _Divisor;
float _Offset;
float _Roll;

half4 frag(v2f_img i) : SV_Target
{
// Convert to the polar coordinate.
float2 sc = i.uv - 0.5;
float phi = atan2(sc.y, sc.x);
float r = sqrt(dot(sc, sc));

// Angular repeating.
phi += _Offset;
phi = phi - _Divisor * floor(phi / _Divisor);
#if SYMMETRY_ON
phi = min(phi, _Divisor - phi);
#endif
phi += _Roll - _Offset;

// Reflection at the border of the screen.
r = min(r, 1.0 - r);

// Convert back to the texture coordinate.
float2 uv = float2(cos(phi), sin(phi)) * r + 0.5;

return tex2D(_MainTex, uv);
}

ENDCG
SubShader
{
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
ENDCG
}
}
}
9 changes: 9 additions & 0 deletions Assets/Kino/Mirror/Shader/Mirror.shader.meta

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

Loading

0 comments on commit 4bc575b

Please sign in to comment.