【问题标题】:Vertex Texture Fetch always return 0顶点纹理获取总是返回 0
【发布时间】:2013-09-30 10:03:12
【问题描述】:

我正在开发基于着色器的地形。使用 VTF 获取顶点着色器中的高度数据。我的问题是,当我在顶点着色器中对高度图进行采样时,返回的值始终为零。

Texture2D texture;
SamplerState sampleType;
float height = texture.SampleLevel(sampleType, float4(input.tex, 0, 0), 0);

使用 D3DX11CreateShaderResourceViewFromFile(device, heightmap, NULL, NULL, &texture) 函数从 BMP 文件 (256x256x24bit) 加载纹理,并使用 deviceContext->PSSetShaderResources(0, 1, &texture) 传递给顶点着色器。功能级别为 D3D_FEATURE_LEVEL_10_0,着色器配置文件为 vs_4_0。

【问题讨论】:

    标签: directx-11 vertex-shader terrain


    【解决方案1】:

    你正在调用 deviceContext->PSSetShaderResources(0, 1, &texture),

    这意味着您将纹理传递给像素着色器。 您需要将纹理和采样器绑定到顶点着色器,而不是使用

    VSSetSamplersVSSetShaderResources

    改为。

    【讨论】:

      猜你喜欢
      • 2023-01-30
      • 1970-01-01
      • 2019-01-24
      • 2022-01-07
      • 2014-07-30
      • 2012-08-19
      • 1970-01-01
      • 1970-01-01
      • 2015-09-27
      相关资源
      最近更新 更多