• Create Account

### #ActualHodgman

Posted 13 March 2012 - 07:23 AM

Yes, tex2D/tex2Dlod are what you're looking for

In UV-space, a u value of 0 is the left hand side of the left-most texel. A u value of 1 is the right hand side of the right-most texel.
If your texture is 120 pixels wide, and you want to fetch the 60th texel (texel number 59), the u coordinate for the centre of that texel is:
(59.0 + 0.5) / 120.0.

If you used 59.0/120.0, you would be exactly between texel #58 and #59. This is probably defined to round-up to #59 (when using point filtering), but I never trust floating-point math that much, so I always make sure that I specify the centre of each texel as above.

### #5Hodgman

Posted 13 March 2012 - 07:22 AM

Yes, tex2D/tex2Dlod are what you're looking for

In UV-space, a u value of 0 is the left hand side of the left-most texel. A u value of 1 is the right hand side of the right-most texel.
If your texture is 120 pixels wide, and you want to fetch the 60th texel (texel number 59), the u coordinate for the centre of that texel is:
(59.0 + 0.5) / 120.0.

If you used 59.0/120.0, you would be exactly between texel #58 and #59. This is probably defined to round-up to #59, but I never trust floating point, so I always make sure that I specify the centre of each texel as above.

### #4Hodgman

Posted 13 March 2012 - 07:22 AM

Yes, tex2D/tex2Dlod are what you're looking for

In UV-space, a u value of 0 is the left hand side of the left-most texel. A u value of 1 is the right hand side of the right-most texel.
If your texture is 120 pixels wide, and you want to fetch the 60th texel (texel number 59), the u coordinate for the centre of that texel is:
(59.0 + 0.5) / 120.0.

If you used 59.0/120.0, you would be exactly between texel #58 and #59. This is probably defined to round-up to #59, but I never trust floating point, so I always make sure that I specify the centre of each texel as above.

### #3Hodgman

Posted 13 March 2012 - 07:20 AM

Yes, tex2D/tex2Dlod are what you're looking for

In UV-space, a u value of 0 is the left hand side of the left-most texel. A u value of 1 is the right hand side of the right-most texel.
If your texture is 120 pixels wide, and you want to fetch the 60th texel (texel number 59), the u coordinate for the centre of that texel is:
(59.0 + 0.5) / 120.0

### #2Hodgman

Posted 13 March 2012 - 07:19 AM

Yes, tex2D/tex2Dlod are what you're looking for

In UV-space, a u value of 0 is the left hand side of the left-most texel. A u value of 1 is the right hand side of the right-most texel.
If your texture is 120 pixels wide, and you want to fetch the 5th texel (texel number 4), the u coordinate for the centre of that texel is:
(4.0 + 0.5) / 120.0

### #1Hodgman

Posted 13 March 2012 - 07:19 AM

Yes, tex2D/tex2Dlod are what you're looking for

In UV-space, a u value of 0 is the left hand side of the left-most texel. A u value of 1 is the right hand side of the right-most texel.
If your texture is 120 pixels wide, and you want to fetch the 5th texel (texel number 4), the u coordinate for the centre of that texel is: (4.0 + 0.5) / 120.0

PARTNERS