Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
- Shader "Custom/AdditiveScreenTexture"{
- Properties {
- _TintColor ("Tint Color", Color) = (1,1,1,1)
- _EmissionGain ("Emission Gain", Range(0, 1)) = 0.052
- _Cloudy ("Cloudy", Range (0, 4)) = .15
- _Params ("Size (MinMax) Wind (MinMax)", Vector) = (32, 64, 1, 1)
- _ParamsB ("Angle (RAD) Variat", Vector) = (-1.87, -1.27, 5, 0)
- _Wind ("Wind speed", Range (0, 2)) = .2
- _Rotation ("Rotation", Range (0, 1)) = 0
- _Samples ("Samples", Range (1, 10)) = 2
- _MainTex ("Texture", 2D) = "white" {}
- }
- Category {
- Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
- Blend SrcAlpha One
- ZWrite Off
- SubShader {
- Pass {
- CGPROGRAM
- // Upgrade NOTE: excluded shader from DX11; has structs without semantics (struct v2f members worldPos)
- #pragma exclude_renderers d3d11
- #pragma vertex vert
- #pragma fragment frag
- fixed4 _TintColor;
- float _EmissionGain;
- half _Cloudy;
- half _Rotation;
- half _Wind;
- half4 _Params;
- half4 _ParamsB;
- int _Samples;
- sampler2D _MainTex;
- float4 _MainTex_ST;
- struct appdata_t {
- float4 vertex : POSITION;
- fixed4 color : COLOR;
- };
- struct v2f {
- float4 vertex : SV_POSITION;
- fixed4 color : COLOR;
- float2 worldPosition: TEXCOORD0;
- };
- v2f vert (appdata_t v)
- {
- v2f o;
- o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
- o.color = v.color ;
- o.worldPosition = mul(unity_ObjectToWorld, v.vertex);
- return o;
- }
- float pingpong(float value, float freq){
- return sin( (value*3.1415926536) * freq);
- }
- float semiRandom(float2 uv){
- return frac(sin(dot(uv, float2(12.9898, 78.233))) * 43758.5453);
- }
- fixed noise(v2f i, float size, float2 speed){
- float2 uv = speed * _Time.x + i.worldPosition.xy * size;
- return tex2D(_MainTex, uv).x;
- }
- // rotated 45 degrees
- fixed noise45(v2f i, float size, float2 speed){
- float2 uv = speed * _Time.x + i.worldPosition.xy * size;
- float y = uv.y * 0.7071067812;
- float x = uv.x * 0.7071067812;
- uv = half2(x+y,-x+y);
- return tex2D(_MainTex, uv).x;
- }
- fixed noise452(v2f i, float size, float2 speed) {
- float2 xy = speed * _Time.x + i.worldPosition.xy * size;
- // xy = xy * 0.7071067812;
- // xy = float2(xy.x+xy.y,-xy.x+xy.y);
- xy = tex2D(_MainTex, xy).xy ;
- return abs(xy.x + sin(( (xy.x * 1.3f + xy.y * 2.135f) - (xy.x * 1.172f + xy.y * .35f)) * _ParamsB.z * _Time.x) * 0.6f);
- }
- float2 rotate(float2 original, float angle ){
- float sinX = sin ( angle );
- float cosX = cos ( angle );
- float sinY = sin ( angle );
- float2x2 rotationMatrix = float2x2( cosX, -sinX, sinY, cosX);
- return mul(original, rotationMatrix );
- }
- fixed4 frag (v2f i) : SV_Target
- {
- float clouds = .5 + noise452(i, 1/_Params.x, rotate(float2(_Wind,0), _ParamsB.x)*_Params.z)*2;
- for(int s=1;s<_Samples;s++){
- float s01 = s/(float)(_Samples-1);
- float2 direction = rotate(float2(_Wind,0), lerp(_ParamsB.x, _ParamsB.y, s01) );
- clouds = clouds - ( noise452(i, 1/lerp(_Params.x, _Params.y, s01), direction * (lerp(_Params.z, _Params.w, s01)))) * lerp(.3, 1, s01);
- }
- float4 shaftColor = i.color*i.color;
- return lerp(shaftColor, shaftColor*clouds, _Cloudy) * _TintColor * (exp(_EmissionGain * 5));
- }
- ENDCG
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement