Hey, I am trying to make a simple Wobble shader using HDRP and custom post processing in HLSL. However, I am getting black areas on the edges of the screen where texcoord's x value is not within the range of 0-1 (my assumption).
Here's the fragment:
float2 wobble(float2 uv, float amplitude, float frequence, float speed)
{
float offset = amplitude * sin(uv.y * frequence + _Time * speed);
return float2(uv.x + offset, uv.y);
}
float4 CustomPostProcess(Varyings input) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
float2 uv = input.texcoord;
float amplitude = 0.0030;
float frequence = 25.00;
float speed = 10.0;
uv = wobble(uv,_Amplitude, _Frequence, _Speed);
float3 outColor = LOAD_TEXTURE2D_X(_InputTexture, uv * _ScreenSize.xy).xyz;
return float4(outColor, 1);
}
And here is the result:
![alt text][1]
[1]: /storage/temp/154106-m.jpg
Of course the image is getting bent by the Wobble effect, but I need to fit the uv in such a way that these areas will not be black. If I clip the uv's x like this:
if (uv.x < 0.0f)
uv.x = 0.0;
// OR
uv.x = frac(uv.x);
Then I get what I need for the left side of the screen, but I couldn't find a way to handle the other side.
This issue also happens with some other tests I run with different effects, whenever I try to mess with the uv (texcoord). So I kinda need some explanation of how that works properly, and how to recalculate the uv to make the image fit into the screen space properly.
↧