所有不同的 HLSL 采样器类型有何用途?

发布于 08-02 12:08 字数 1263 浏览 14 评论 0原文

我目前正在使用 DX9/SM3 以及有关 HLSL 采样器的 MSDN 文档 似乎非常缺乏解释如何使用不同的采样器类型。更糟糕的是,他们试图在一篇文章中涵盖 DX9 和 DX10,因此他们将所有关键字混在一起:

采样器名称 = SamplerType { 纹理 = <texture_variable>; [state_name = state_value;] ... };

...

采样器类型

<块引用>

[in] 采样器类型,为以下类型之一:samplersampler1Dsampler2Dsampler3D、samplerCUBEsampler_stateSamplerState

Direct3D 9 和 Direct3D 10 之间的差异:

Direct3D 10 支持一种附加采样器类型:SamplerComparisonState

我感觉与本文相反,SamplerState 仅适用于 DX10。事实上,我看到的所有代码都使用 sampler_state 来表示 SamplerType。 BasicHLSL (DX9) 的一个简单示例:

sampler MeshTextureSampler =
sampler_state
{
    Texture = <g_MeshTexture>;
    MipFilter = LINEAR;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
};

为什么存在所有不同的 _SamplerType_ 以及何时使用 samplersampler2D 而不是 sampler_state?无论如何,在获取时您需要明确,例如 tex2D、texCUBE,那么这里发生了什么?

I'm working with DX9/SM3 at the moment, and the MSDN documentation on HLSL samplers seems to be sorely lacking in explaining how to use the different sampler types. What's worse is they try to cover DX9 and DX10 in a single article, so they jumble together all the keywords:

sampler Name = SamplerType { Texture = <texture_variable>; [state_name = state_value;] ... };

...

SamplerType

[in] The sampler type, which is one of the following: sampler, sampler1D, sampler2D, sampler3D, samplerCUBE, sampler_state, SamplerState.

Differences between Direct3D 9 and Direct3D 10:

Direct3D 10 supports one additional sampler type: SamplerComparisonState.

I get the feeling that contrary to this writeup, SamplerState is DX10 only. Virtually all the code I see uses sampler_state for SamplerType. A quick example from BasicHLSL (DX9):

sampler MeshTextureSampler =
sampler_state
{
    Texture = <g_MeshTexture>;
    MipFilter = LINEAR;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
};

Why do all the different _SamplerType_s exist and when would you use, say, sampler or sampler2D instead of sampler_state? You need to be explicit when fetching anyhow, e.g. tex2D, texCUBE, so what is going on here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

霓裳挽歌倾城醉2024-08-09 12:08:39

你说得对。这很奇怪。

DirectX 9 语法的文档似乎是错误的。我绝不是 HLSL 或 DirectX 方面的专家,但我总是只看到 DirectX 9 中的采样器是这样声明的:

SamplerType Name = sampler_state{   Texture = <texture_variable>;   [state_name = state_value;]   ... }; 

我可能遗漏了一些东西,但对我来说,上面的语法比文档中的语法更有意义。您声明具有给定类型的采样器,并指定采样器状态。

更新:显然这是错误的。我已经在官方论坛上启动了一个帖子,到目前为止我已经只是得到确认,这是错误的。我还直接向 DirectX 团队发送了一封邮件。只是为了安全起见。

You're right. That is very odd.

It seems as if the documentation on the DirectX 9 syntax is wrong. I'm by no means an expert on either HLSL or DirectX, but I've always only seen samplers in DirectX 9 being declared like this:

SamplerType Name = sampler_state{   Texture = <texture_variable>;   [state_name = state_value;]   ... }; 

I might be missing something but to me the above syntax makes more sense than the one in the documentation. You declare a sampler with a given type, and specifies the sampler state.

UPDATE: Apparently it IS wrong. I've started a thread on the official forums and so far I've only gotten a confirmation that it is wrong. I've also sent a mail directly to the DirectX team. Just to be on the safe side.

橪书2024-08-09 12:08:39

采样器名称 = SamplerType { 纹理 = ; [状态名称=状态值;]};

这是正确的!
该声明仅对效果有效。

编辑:官方论坛位于 MSDN 上。您可以使用“社区添加”发布建议或错误。

sampler Name = SamplerType { Texture = ; [state_name = state_value;]};

It is correct!
The declaration is valid only for effects.

EDIT: the official forums are on MSDN. You can post a suggestion or an error using "Community Additions".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文