Quantcast
Channel: Questions in topic: "hlsl"
Viewing all articles
Browse latest Browse all 206

Why won't this vertex distortion shader work as intended?

$
0
0
Hello. I tried writing this shader to distort my vertices' positions using a "watery" texture's grayscale. The thing is, they are always distorting by the same amount, so it looks like the sprite is just moving without warping. My guess is that my world position calculation is not working as intended? ---------- v2f_vct vert_vct(vin_vct v) { v2f_vct o; float2 worldPos = mul (unity_ObjectToWorld, v.vertex).xy; v.vertex.xy += tex2Dlod(_DispTex, fixed4(worldPos.x + _SinTime.x, worldPos.y -_SinTime.x, 0, 0)).rg * _Strength; o.vertex = v.vertex + (fixed4(1, 0, 0, 0) * _OutlineSize); o.vertex.y += _SinTime.w * _Swaying; o.vertex = UnityObjectToClipPos(o.vertex); o.texcoord = v.texcoord; return o; } fixed4 frag_mult(v2f_vct i) : SV_Target { fixed4 col = _OutlineColor; col.a *= tex2D(_MainTex, i.texcoord).a; return col; }

Viewing all articles
Browse latest Browse all 206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>