Shader Question

Hey im new to the shaderbusiness and just started a few weeks ago at Node10. Now im trying to use my new knowledge:-). And here is the first problem im facing. Lets say i have 3 Grids in the Shader each at 42 resolution. Makes a total of 24 Points. If I would like to add an (different) offset to each Point. How can I do that? If i put 24 Offsetvalues on one Pin, i will get 24 layers, instead of the 3. So i was thinking if it is possible to write the offsetvalues in a texture with the size of 124 Pixels. Get the pixelvalues in the shader and add them to Position? I allready tried this but it`s not working sofar.

Is my approach right or is it simply not working this way?

Thanks for your help.

Greetings from Vienna

robi

to input a spread of values without spreading the fx itself you have to make it an array. e.g.:

float3 offset[24](24);

then you have to find a clever way to assign the input to the gridpoints. for example by its initial position, which you know because it’s a standard grid

but beware: if you spreaded the Grid (EX9) then you have actually 3 subsets being drawn independently and youd specify your array like:

code(lang=hlsl)
float3 offset8;

and still the problem mentioned by woei is the same how you’d distribute those values to the gridpoints.

alternatively you could check heightmap-displacement which uses a texture in the vertexshader to displace the vertices. in case of 3 subsets you could hand the effect over a spread of 3 such offsettextures respectively.

so, this is the full solution:

const int2 RES = {3,2}; //grid resolution
float3 offset[6](6); //vertex count

and inside the vertexshader:

int index; //generate the index for each vertex position
index=TexCd.y*(RES.y-1)*RES.x;
index+=TexCd.x*(RES.x-1);
	
PosO.xyz += offset[index](index); //do the offset