HLSL SetValue for StructuredBuffer

Hello all, I must warn ahead, I am pretty new with hlsl. So any tips are welcome :smiley:.
I have the following hlsl code:

struct thing{
float2 valueOne;
float valueTwo;

StructuredBuffer things;

I was wondering if I can set “things” from my C# code?
And if not, what approach you would recommend for equivalent results?

Thanks in advance!

Typically structs are vertexshader input or pixel shader input.

for example.

Example diffuse light shader and its vertex pixel structures

The above is used here by this cs class file.

The shaders vertex structure relys on this class that defines the custom vertex structure that matches the hlsl.

However for what your asking i don’t think its possible unless its taking vertex data.

Within hlsl you can define a additional struct (besides the input vertex struc) like you have and set it up or even use the values you set within say a vertex or pixel shader function but it has to be called from the function inside hlsl. As far as i know. While its possible to use instancing and bind multiple vertex buffers there are pre-existing calls to use them.

Directly setting into a additional shader struct from the cs side, i don’t think you can do that, maybe but you would probably have to ask one of the main guys if that’s possible.
You can set to shader global variables though directly and just use them that way.

1 Like