How to use Texture Samplers

Started by
11 comments, last by BenS1 11 years, 5 months ago
The coords for the <uint> texture are indeed integer based. I'm not sure if they've done it that way for clarity. If you think about it, sampling probably just uses integer based accesses beneath the hood and lerps the values. But then .. couldn't integers be interpolated as well ! I guess it's the case that the common scenarios have influenced the design here.

Does the Load function support wrapping etc (The documentation doesn't say)?[/quote]
From the documentation :
Note When one or more of the coordinates in Location exceed the u, v, or w mipmap level dimensions of the texture, Load returns zero in all components. Direct3D guarantees to return zero for any resource that is accessed out of bounds.

So I guess it's like border addressing, but with only zero as the border value. I'm assuming that u & v are the standard texture coords (in this case de-normalized) and w is the mip-map level. So if my assumption is correct, then there is no wrapping.

Out of interest, what's the difference between DXGI_FORMAT_R8_UNORM and DXGI_FORMAT_A8_UNORM?[/quote]

I don't know, I see them as the same thing in practice but then I'm not familiar with a whole range of techniques and so there could be some part of the pipeline that requires it that way. My best guess is that it's simply for clarity
Advertisement
For Load the coordinates are integer based because you don't get any filtering. You're explicitly specifying which texel you want to sample, so for instance 10.1 and 10.9 would both return the same the same texel (since texels are centered at 0.5 increments). Load isn't something you use for typical UV mapping scenarios, where you want filtering applied to the result.

The difference between R8_UNORM and A8_UNORM is that R8_UNORM will return the texel value in the red component of the sample, while A8_UNORM will return the value in the alpha channel. There's no difference in how the data is stored in the texture, it only affects how the texture is sampled.
Ok thanks again Gavin and MJP.

I seem to have it working now.

Thanks
Ben

This topic is closed to new replies.

Advertisement