Hello,
It’s my first attempt trying to port a shadertoy shader into vvvv and I found an error that no search through google or forums seems to help me resolving it. The error is:
Offset texture instructions must take an offset, which can resolve to integer literal in the range -8 to 7.
This is the original script:
> void mainImage( out float4 fragColor, in float2 fragCoord )
> {
> float2 uv = (fragCoord.xy-.5*iResolution.xy) / iResolution.y;
> float2 UV = fragCoord.xy/iResolution.xy;
> float3 M = iMouse.xyz/iResolution.xyz;
> float T = iTime+M.x*2.;
> float t = T*.2;
> float rainAmount = iMouse.z>0. ? M.y : sin(T*.05)*.3+.7;
> float maxBlur = lerp(3., 6., rainAmount);
> float minBlur = 2.;
> float story = 0.;
> float heart = 0.;
> //float zoom = -cos(T*.2);
> //uv *= .7+zoom*.3;
> //UV = (UV-.5)*(.9+zoom*.1)+.5;
> float staticDrops = S(-.5, 1., rainAmount)*2.;
> float layer1 = S(.25, .75, rainAmount);
> float layer2 = S(.0, .5, rainAmount);
> float2 c = Drops(uv, t, staticDrops, layer1, layer2);
> #ifdef CHEAP_NORMALS
> float2 n = float2(dFdx(c.x), dFdy(c.x));// cheap normals
> #else
> float2 e = float2(.001, 0.);
> float cx = Drops(uv+e, t, staticDrops, layer1, layer2).x;
> float cy = Drops(uv+e.yx, t, staticDrops, layer1, layer2).x;
> float2 n = float2(cx-c.x, cy-c.x); // expensive normals
> #endif
> float focus = lerp(maxBlur-c.y, minBlur, S(.1, .2, c.x));
> float3 col = textureLod(iChannel0, UV+n, focus).rgb;
> fragColor = float4(col, 1.);
> }
This is what I came up with with the converting tool and looking at other similar porting examples:
float4 PS(float4 fragCoord : SV_POSITION): SV_Target {
float2 uv = (fragCoord.xy-.5R.xy) / R.y;
float2 UV = fragCoord.xy/R.xy;
//float3 M = iMouse.xyz/R.xyz;
float T = Time;//+M.x2.;
float t = T*.2;
float rainAmount = Size>0. ? Size : sin(T*.05).3+.7;
float maxBlur = lerp(3., 6., rainAmount);
float minBlur = 2.;
float story = 0.;
float heart = 0.;
//float zoom = -cos(T.2);
//uv = .7+zoom.3;
//UV = (UV-.5)(.9+zoom.1)+.5;
float staticDrops = S(-.5, 1., rainAmount)*2.;
float layer1 = S(.25, .75, rainAmount);
float layer2 = S(.0, .5, rainAmount);
float2 c = Drops(uv, t, staticDrops, layer1, layer2);
#ifdef CHEAP_NORMALS
float2 n = float2(dFdx(c.x), dFdy(c.x));// cheap normals
#else
float2 e = float2(.001, 0.);
float cx = Drops(uv+e, t, staticDrops, layer1, layer2).x;
float cy = Drops(uv+e.yx, t, staticDrops, layer1, layer2).x;
float2 n = float2(cx-c.x, cy-c.x); // expensive normals
#endif
float focus = lerp(maxBlur-c.y, minBlur, S(.1, .2, c.x));
float3 col = tex0.Sample(s0, UV+n, focus).rgb;
return float4(col, 1.);
The error itself is on this line
float3 col = tex0.Sample(s0, UV+n, focus).rgb;
What does it mean and how should I resolve this?