added animation package and made small changes
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 315c793af77d9e44aa38fe8aa3f270d8
|
||||
folderAsset: yes
|
||||
timeCreated: 1442874757
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,105 @@
|
||||
|
||||
// =================================
|
||||
// Namespaces.
|
||||
// =================================
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
// =================================
|
||||
// Define namespace.
|
||||
// =================================
|
||||
|
||||
namespace MirzaBeig
|
||||
{
|
||||
|
||||
namespace Shaders
|
||||
{
|
||||
|
||||
namespace ImageEffects
|
||||
{
|
||||
|
||||
// =================================
|
||||
// Classes.
|
||||
// =================================
|
||||
|
||||
[ExecuteInEditMode]
|
||||
[System.Serializable]
|
||||
|
||||
public class Sharpen : IEBase
|
||||
{
|
||||
// =================================
|
||||
// Nested classes and structures.
|
||||
// =================================
|
||||
|
||||
// ...
|
||||
|
||||
// =================================
|
||||
// Variables.
|
||||
// =================================
|
||||
|
||||
// ...
|
||||
|
||||
[Range(-2.0f, 2.0f)]
|
||||
public float strength = 0.5f;
|
||||
|
||||
// ...
|
||||
|
||||
[Range(0.0f, 8.0f)]
|
||||
public float edgeMult = 0.2f;
|
||||
|
||||
// =================================
|
||||
// Functions.
|
||||
// =================================
|
||||
|
||||
// ...
|
||||
|
||||
void Awake()
|
||||
{
|
||||
shader = Shader.Find("Hidden/Mirza Beig/Image Effects/Sharpen");
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
void OnRenderImage(RenderTexture source, RenderTexture destination)
|
||||
{
|
||||
material.SetFloat("_strength", strength);
|
||||
material.SetFloat("_edgeMult", edgeMult);
|
||||
|
||||
// ...
|
||||
|
||||
blit(source, destination);
|
||||
}
|
||||
|
||||
// =================================
|
||||
// End functions.
|
||||
// =================================
|
||||
|
||||
}
|
||||
|
||||
// =================================
|
||||
// End namespace.
|
||||
// =================================
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// =================================
|
||||
// --END-- //
|
||||
// =================================
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1832d7674d4d42c43a3d110b583423d5
|
||||
timeCreated: 1437882603
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- mat: {fileID: 2100000, guid: c7117444282a7b34480c3e5b79e2ffe0, type: 2}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,62 @@
|
||||
|
||||
Shader "Hidden/Mirza Beig/Image Effects/Sharpen"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||
//_strength ("Strength", Range(0.0, 1.0)) = 1.0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
// ...
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
|
||||
uniform float _strength;
|
||||
uniform float _edgeMult;
|
||||
|
||||
// ...
|
||||
|
||||
float4 frag (v2f_img image) : SV_Target
|
||||
{
|
||||
float4 textureColour = tex2D(_MainTex, image.uv);
|
||||
|
||||
// x9 because colour is subtracted 8 times as well as the base.
|
||||
|
||||
float4 sharpenedTextureColour = textureColour * 9.0f;
|
||||
|
||||
// Offset distance proportional to texture size (usually same as screen size).
|
||||
|
||||
float4 offset = 1.0f / (_ScreenParams / _edgeMult);
|
||||
|
||||
// Begin offsets counter-clockwise.
|
||||
|
||||
sharpenedTextureColour -= tex2D(_MainTex, image.uv + float2(offset.x, offset.y)); // Top right.
|
||||
sharpenedTextureColour -= tex2D(_MainTex, image.uv + float2(0.0f, offset.y)); // Up.
|
||||
sharpenedTextureColour -= tex2D(_MainTex, image.uv + float2(-offset.x, offset.y)); // Top left.
|
||||
sharpenedTextureColour -= tex2D(_MainTex, image.uv + float2(-offset.x, 0.0f)); // Left.
|
||||
|
||||
sharpenedTextureColour -= tex2D(_MainTex, image.uv + float2(-offset.x, -offset.y)); // Bottom left.
|
||||
sharpenedTextureColour -= tex2D(_MainTex, image.uv + float2(0.0f, -offset.y)); // Bottom.
|
||||
sharpenedTextureColour -= tex2D(_MainTex, image.uv + float2(offset.x, -offset.y)); // Bottom right.
|
||||
sharpenedTextureColour -= tex2D(_MainTex, image.uv + float2(offset.x, 0.0f)); // Right.
|
||||
|
||||
// Return mix between original and sharpened.
|
||||
|
||||
return lerp(textureColour, sharpenedTextureColour, _strength);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc8394c64a9199543ac3a9c092a70906
|
||||
timeCreated: 1437246983
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user