@@ -294,7 +294,7 @@ impl<W: Write> super::Writer<'_, W> {
294
294
// If params.size is zero then clamp to the actual size of the texture.
295
295
writeln ! (
296
296
self . out,
297
- "{l1}uint2 cropped_size = params.size != 0 ? params.size : plane0_size;"
297
+ "{l1}uint2 cropped_size = any( params.size) ? params.size : plane0_size;"
298
298
) ?;
299
299
writeln ! ( self . out, "{l1}coords = min(coords, cropped_size - 1);" ) ?;
300
300
@@ -342,7 +342,7 @@ impl<W: Write> super::Writer<'_, W> {
342
342
self . out,
343
343
"{l3}plane2.GetDimensions(plane2_size.x, plane2_size.y);"
344
344
) ?;
345
- writeln ! ( self . out, "{l2 }uint2 plane2_coords = uint2(floor(float2(plane0_coords) * float2(plane2_size) / float2(plane0_size)));" ) ?;
345
+ writeln ! ( self . out, "{l3 }uint2 plane2_coords = uint2(floor(float2(plane0_coords) * float2(plane2_size) / float2(plane0_size)));" ) ?;
346
346
writeln ! ( self . out, "{l3}uv = float2(plane1.Load(uint3(plane1_coords, 0u)).x, plane2.Load(uint3(plane2_coords, 0u)).x);" ) ?;
347
347
writeln ! ( self . out, "{l2}}}" ) ?;
348
348
@@ -405,10 +405,13 @@ impl<W: Write> super::Writer<'_, W> {
405
405
self . out,
406
406
"{l1}coords = mul(float3(coords, 1.0), sample_transform);"
407
407
) ?;
408
- // Calculate the sample bounds taking in to account the transform,
409
- // bearing in mind that it may contain a flip on either axis. We must
410
- // calculate and adjust for the half-texel separately for each plane as
411
- // it depends on the texture size which may vary between planes.
408
+ // Calculate the sample bounds. The purported size of the texture
409
+ // (params.size) is irrelevant here as we are dealing with normalized
410
+ // coordinates. Usually we would clamp to (0,0)..(1,1). However, we must
411
+ // apply the sample transformation to that, also bearing in mind that it
412
+ // may contain a flip on either axis. We calculate and adjust for the
413
+ // half-texel separately for each plane as it depends on the actual
414
+ // texture size which may vary between planes.
412
415
writeln ! (
413
416
self . out,
414
417
"{l1}float2 bounds_min = mul(float3(0.0, 0.0, 1.0), sample_transform);"
0 commit comments