Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fixed4 frag (v2f i) : SV_Target
- {
- fixed front = step(0, -dot(i.viewD, i.normal));
- // нормали + карта нормалей
- float4 n = tex2D (_NormalTex, i.uv * _TopTex_ST.xy + _TopTex_ST.zw);
- float3 normal = UnpackNormal (n);
- half3 worldNormal;
- worldNormal.x = dot(i.tspace0, normal);
- worldNormal.y = dot(i.tspace1, normal);
- worldNormal.z = dot(i.tspace2, normal);
- // оффсет с учётом интенсивности эффекта и угла между камерой и направлением триангла
- float refr = dot (worldNormal, i.viewD);
- // сдвиг от угла между направлением на камеру и нормалью пикселя
- float2 offset2 = -i.offsetRefr * _RefractionPower * refr;
- // текстура из скрин спейса
- fixed4 col = tex2D(_MainTex, (i.screenPos.xy / i.screenPos.w) * _MainTex_ST.xy + _MainTex_ST.zw + offset2);
- return col;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement