Unity Twist Effect Black Hole

Shader "Hidden/Twist Effect" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}

SubShader
{
Pass
{
ZTest Always Cull Off ZWrite Off
Fog { Mode off }

CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest

#include "UnityCG.cginc"

uniform sampler2D _MainTex;

uniform float4 _MainTex_ST;

uniform float4 _MainTex_TexelSize;
uniform float _Angle;
uniform float4 _CenterRadius;

inline float TriWave(float x)
{
return abs(frac(x) * 2-1 )-0.5;

}
struct v2f {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
float2 uvOrig : TEXCOORD1;
};

v2f vert (appdata_img v)
{
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
float2 uv = v.texcoord.xy - _CenterRadius.xy;
o.uv = TRANSFORM_TEX(uv, _MainTex); //MultiplyUV (UNITY_MATRIX_TEXTURE0, uv);
o.uvOrig = uv;
return o;
}

float4 frag (v2f i) : COLOR
{
float2 offset = i.uvOrig;
float t = TriWave(_Time.y * 0.05);
float angle = 1.0 - length(offset / (_CenterRadius.zw*t ));
angle = max (0, angle);
angle = angle * _Angle * t;
float cosLength, sinLength;
sincos (angle, sinLength, cosLength);

float2 uv;
uv.x = cosLength * offset[0] - sinLength * offset[1];
uv.y = sinLength * offset[0] + cosLength * offset[1];
uv += _CenterRadius.xy;

return tex2D(_MainTex, uv) * (1 - abs(angle * 0.5));
}
ENDCG

}
}

Fallback off

}

时间: 2024-08-11 12:25:24

Unity Twist Effect Black Hole的相关文章

unity, 在image effect shader中用_CameraDepthTexture重建世界坐标

我用于渲染_CameraDepthTexture的相机是一个透视相机.正交的情况没试,估计差不多. unity的image effect的机制我们大致都了解:它是画了一个覆盖全屏的quad(具体尺寸和位置未知). 要注意的是image effect使用的投影矩阵并非相机的投影矩阵,而是使用了一个正交投影矩阵(具体形式未知),这一点我卡了好久才意识到,不过一想也很正常合理,毕竟只是想画个全屏quad,直接push个正交矩阵(即切换到2d模式)去画就好了. 虽然image effect使用的投影矩阵

关于Unity的PlayMaker

So, should you use Playmaker in production? Short answer is: Long answer follows. Playmaker Playmaker is a visual scripting tool for Unity. It has been a top-selling asset in the Asset Store for a couple of years. Learning environment I get invited t

unity3d 制造自己的水体water effect(一)

first,I wish you a happy new year, and study in spring festival's eve means you are hardworking,haha. I write in two languages. One passage write in Chineseone passage translate into English. My English is poor., If I write some thing wrong, welcome

Unity 实现物体破碎效果(转)

感谢网友分享,原文地址(How to Make an Object Shatter Into Smaller Fragments in Unity),中文翻译地址(Unity实现物体破碎效果) In this tutorial I will show you how to create a simple shattering effect for your Unity game. Instead of just "deleting" a crate (or any other obje

转:Oculus Unity Development Guide开发指南(2015-7-21更新)

http://forum.exceedu.com/forum/forum.php?mod=viewthread&tid=34175 Oculus Unity Development Guide开发指南转载请保留原始地   http://t.cn/RAblKoh Oculus/GearVR开发者群 302294234 Welcometo the Unity Development GuideIntroduction简介Welcometo the Oculus Unity Developer Gui

unity中使用FingerGestures插件3.0

FingerGestures是一个unity3D插件,用来处理用户动作,手势. 译自FingerGestures官方文档 目录 FingerGestures包结构 FingerGestures例子列表 设置场景 教程:识别一个轻敲手势 教程:手势识别器 教程:轻击手势识别器 教程:拖拽手势识别器 教程:滑动手势识别器 教程:长按手势识别器 教程:缩放手势识别器 教程:旋转手势识别器 教程:自定义手势识别器 教程:识别手势事件 建议:使用.net代理事件 fingerGestures包结构 路径,

Creating a Unity Game for Windows 8

原地址:http://www.davebost.com/2013/08/30/creating-a-unity-game-for-windows-8 The recent release of Unity 4.2 brings with it full-support for deploying Unity games to both Windows 8 and Windows Phone. Unity 4.2 is a powerful game development tool that c

Unity Manual —— Navigation and Pathfinding

一.两个问题 在Unity中,想要完成自动寻路,需要以下解决两个问题. 1.如何根据当前的level,找到目的地(how to reason about the level to find the destination) 2.如何到达该目的地(how to move there) 第一个问题是全局(globally),静态的,需要计算整个Scene: 第二个问题是局部(locally),动态的,需要实时考虑当前agent的移动方向与如何避免和其他agents发生碰撞,从而从出发点到达目的地 二

[Unity官方文档翻译]Primitive and Placeholder Objects Unity原生3D物体教程

Primitive and Placeholder Objects 原始的基础物体 Unity can work with 3D models of any shape that can be created with modelling software. However, there are also a number of primitive object types that can be created directly within Unity, namely the Cube, S