Unity Twist Effect Black Hole

Source: Internet
Author: User

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

}

Unity Twist Effect Black Hole

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.