如何使用 SlimDX 設置 HLSL 統一變量的值? (How do I set the value of a HLSL uniform variable with SlimDX?)


問題描述

如何使用 SlimDX 設置 HLSL 統一變量的值? (How do I set the value of a HLSL uniform variable with SlimDX?)

I haven't been able to find the documentation for this, but it's probably pretty simple.  I have a pixel shader which needs variables to be updated.  The only thing I've come close with is the ConstantTable, but it's under Direct3D9 and not Direct3D11 which is what I'm using.

Using DirectX11 with SlimDX, how would I set the value of uniform variables I have in the shader?


參考解法

方法 1:

Direct3D 10 and 11 use the idea of constant buffers. The SlimDX Buffer class is the type you're looking for. Alternatively, if you're using effects, you can use one of the GetVariableBy* methods to get and set its values.

(by jnm2MikeP)

參考文件

  1. How do I set the value of a HLSL uniform variable with SlimDX? (CC BY-SA 3.0/4.0)

#hlsl #slimdx #directx






相關問題

如何將幾何著色器與輸出流一起使用? (How do you use Geometry Shader with Output Stream?)

поўнаэкранны квадрат у піксельным шэйдары мае экранныя каардынаты? (fullscreen quad in pixel shader has screen coordinates?)

硬編碼 HLSL 著色器 (Hardcoding HLSL Shader)

GLSL和HLSL之間的模型視圖區別? (Modelview Difference between GLSL and HLSL?)

未定義的 TEXCOORD 數量 (Undefined number of TEXCOORDs)

像素著色器總是返回白色 (Pixel shader always returning white)

GLSL / HLSL 著色器中的星球大戰全息效果 (Star Wars holographic effect in GLSL / HLSL shader)

在 GLSL 中混合多個紋理 (Blending multiple textures in GLSL)

警告 X4000:使用可能未初始化的變量 (warning X4000: use of potentially uninitialized variable)

著色器中的點積與直接向量分量總和性能 (Dot product vs Direct vector components sum performance in shaders)

Unity Compute Shader 中調用 numthreads 和 Dispatch 的區別 (Difference Between Calling numthreads and Dispatch in a Unity Compute Shader)

DirectX 11 曲面細分著色器不工作 (DirectX 11 Tesellation Shader Not Working)







留言討論