Hello everyone, I recently started programming shaders for MonoGame and I’ve been watching this tutorial for a shockwave shader. It’s not in HLSL but I’ve been able to translate everything. The problem I have is that when I pass in the position of my mouse, it draws it in a weird down-left arc.
Here’s the C# code:
Vector2 mouse = Mouse.GetState().Position.ToVector2(); shockwave.Parameters["center"].SetValue(Vector2.Normalize(mouse));
And here’s the shader:
float4 PixelShaderFunction(float2 UV : TEXCOORD0) : COLOR0
float ratio = res.x / res.y;
float2 scaled_UV = (UV - float2(0.5, 0)) * float2(ratio, 1) + float2(0.5, 0);
float2 disp = normalize(scaled_UV - center) * force / 10;
float4 color = tex2D(s, UV - disp);
Here’s a video of the problem.