X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=resample_effect.frag;h=26838dcfbbad3f1a3df25cc18d44475c2cc998d9;hp=f54a8be28b35a23a21e3128175ad5098992b1501;hb=f216b7bef5a968c89f6fc78e83cc26a91e504a8a;hpb=c783d084e831c1a2112b9c9309407a03b5a4cf20 diff --git a/resample_effect.frag b/resample_effect.frag index f54a8be..26838dc 100644 --- a/resample_effect.frag +++ b/resample_effect.frag @@ -1,12 +1,13 @@ // DIRECTION_VERTICAL will be #defined to 1 if we are scaling vertically, // and 0 otherwise. -uniform sampler2D PREFIX(sample_tex); -uniform int PREFIX(num_samples); -uniform float PREFIX(num_loops); -uniform float PREFIX(sample_x_scale); -uniform float PREFIX(sample_x_offset); -uniform float PREFIX(slice_height); +// Implicit uniforms: +// uniform sampler2D PREFIX(sample_tex); +// uniform int PREFIX(num_samples); +// uniform float PREFIX(num_loops); +// uniform float PREFIX(sample_x_scale); +// uniform float PREFIX(sample_x_offset); +// uniform float PREFIX(slice_height); // We put the fractional part of the offset (-0.5 to 0.5 pixels) in the weights // because we have to (otherwise they'd do nothing). However, the support texture @@ -24,7 +25,9 @@ uniform float PREFIX(slice_height); // measured in _input_ pixels and tc is in _output_ pixels, although we could // compensate for that.) However, the shader should be mostly bandwidth bound // and not ALU bound, so an extra add per sample shouldn't be too hopeless. -uniform float PREFIX(whole_pixel_offset); +// +// Implicitly declared: +// uniform float PREFIX(whole_pixel_offset); // Sample a single weight. First fetch information about where to sample // and the weight from sample_tex, and then read the pixel itself. @@ -40,9 +43,9 @@ vec4 PREFIX(do_sample)(vec2 tc, int i) vec2 sample = tex2D(PREFIX(sample_tex), sample_tc).rg; #if DIRECTION_VERTICAL - tc.y = sample.g + floor(sample_tc.y) * PREFIX(slice_height) + PREFIX(whole_pixel_offset); + tc.y = sample.g + (floor(sample_tc.y) * PREFIX(slice_height) + PREFIX(whole_pixel_offset)); #else - tc.x = sample.g + floor(sample_tc.y) * PREFIX(slice_height) + PREFIX(whole_pixel_offset); + tc.x = sample.g + (floor(sample_tc.y) * PREFIX(slice_height) + PREFIX(whole_pixel_offset)); #endif return vec4(sample.r) * INPUT(tc); }