日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

HLSL Texture Object Sample 的一些笔记

發布時間:2025/7/25 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HLSL Texture Object Sample 的一些笔记 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Practical Rendering And Computation With D3D11 書上的解釋

"The Sample method allows for hardware texture filtering (minification, magnification,
and mip-map interpolation) to be performed, according to a given sampler state." p340

?"When Sample is called on a texture that contains multiple mip-map levels, the mipmap
level is automatically selected based on the screen-space derivatives (also known
as gradients) of the texture coordinates." p341

總結

SampleLevel比Sample運算簡單,因為它指定了mipmap-level, 不會執行texture mipmap之間的插值計算。

Texture.Sample, Offset參數的解釋

https://www.gamedev.net/forums/topic/496105-directx-10-sampling-surounding-texels-in-pixel-shader-solved/

Hi there... I was wondering what the correct way is to sample surounding texels in a pixel shader?
I assume I should make a sampler state that does point sampling, then use something along these lines to read the surounding texels to implement my own interpolation:

extern Texture2D dataTexture;
SamplerState TextureSampler
{
?? ?Filter = MIN_MAG_MIP_POINT;
?? ?AddressU = Clamp; AddressV = Clamp;
};

float2 texelSize = float2(TexelWidth, TexelHeight);

float t0 = dataTexture.Sample(TextureSampler, input.texCoord + float2(-1, -1) * texelSize);
float t1 = dataTexture.Sample(TextureSampler, input.texCoord + float2(-1, 0) * texelSize);
float t2 = dataTexture.Sample(TextureSampler, input.texCoord + float2( 0, 0) * texelSize);
float t3 = dataTexture.Sample(TextureSampler, input.texCoord + float2( 0, -1) * texelSize);

Anyone know a better way to do this???
The reason why I have to write my own interpolation in the shader is because some of the values should not be interpolated between...
for the textures where I only have one value range, I am using the MIN_MAG_MIP_LINEAR sampler state and then do a single Sample command.

[Edited by - GoodFun on June 2, 2008 9:40:55 AM]

---------------------------------------------------
Yes, the way you're doing it is correct.

It's common to do this sort of thing when you're using a texture to store look-up values.
One thing to keep in mind is that you will probably want to offset your texture fetches by
half a pixel so that you sample in the center of the pixel instead of on the exact border.
That way you can be sure you're fetching the value you expect.

neneboricua

---------------------------------------------------
Actually, this isn't required for DirectX10. In DX10, pixel offsets refer to the centre of the pixel,
not the top-left (which was the case in DX9 and earlier).

OP: Yes, there is an easier way to do it. DX10's texture sampling functions support direct integer
texel offsets. So for example, you can just do this:


dataTexture.Sample(TextureSampler, input.texCoord, int2(-1, 0));

This will sample the texel to the immediate left of the one at input.texCoord.
This means that you don't need to manually generate and apply an offset directly to the texture coordinate,
and can use integer offsets directly.

Sc4Freak

總結

Offset 可以認為是偏移指定的紋理坐標單位。(1.0 / texels_width, 1.0 / texels_height).

?

轉載于:https://www.cnblogs.com/hzzhouqq/p/8866519.html

總結

以上是生活随笔為你收集整理的HLSL Texture Object Sample 的一些笔记的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。