How to transform geometry in DX11?


#1

I’d like to scale and translate geometry before sending it to e.g. VertexNoise (DX11.GeomFX).

How can I do that? Do I have to write a custom geometry shader?

Thanks a lot!


#2

pretty sure instance noodles has a geometryFX for this.

But in case you want to try it yourself, all you need to do is to apply your transform in the shader to the positions.

Pos.xyz = mul(PosO, transform_matrix).xyz;

PosO is are your input vertex positions and should be float4 so it can be multiplied with a 4x4 matrix.


#3

Thanks a lot @tekcor.

Yes, found it: TransformBuffered (DX11.GeomFX)

I’ve tried similar things before but couldn’t make it work.

I’ve now tried your line. PosO seems to be float3 though. I changed it to
Out.PosO.xyz = mul(float4(PosO.xyz,1),transform_matrix).xyz;
which seems to compile but doesn’t transform the geometry.

transform geometry.zip (4.1 KB)

I’m going to stick with the buffered version, for now, but it would be nice to know why it doesn’t work.


#4

Unfortunately, I ran into another problem with this.

TransformBuffered (DX11.GeomFX) is not spreadable. I know about IID. And that works well if I want to use the same object multiple times. But I have different objects and need each of them only once.

What can I do about that? Is there a way of using TransformBuffered (DX11.GeomFX) with multiple different geometries?

Thanks!


#5

I’ve read about a similar topic here: Instancing Spread of different geometries

I’ve managed to do what I want using Merge (DX11.GeomFX).

image
transform geometry.zip (4.8 KB)

What I actually need should be much simpler though. I want to avoid instancing (as it involves a lot of patching and performance overhead as mentioned in the thread above). Instead, I would like to output a spread of multiple geometries that I can use with regular shaders like Constant (DX11.Effect).

This is how far I’ve got, but only the first geometry is being rendered:

image
transform geometry - without instancing.zip (8.7 KB)


#6

StreamOut.zip (4.6 KB)


#7

Thanks a lot for your help, @antokhio . Unfortunately it’s slightly broken though.

VertexCount node was red initially but I found it here: Geometry shaders spreadable?

In addition the technique “PassMesh” doesn’t seem to exist anymore in Template.fx. When I change it to the only available other one “Constant” the output of the renderer stays black.


#8

Make sure there is a same template as in the folder, just try rename that template in to something, I think there is vvvv bug with help patch, it changes shader on it’s own

edit just use that instead:
StreamOut.zip (9.1 KB)


#9

Thanks a lot. The patch does the transformation but it also merges the geometries into a single one. If you use spreads on the Constant shader both geometries will be treated as a single one and e.g. show up twice or with both of the same color.

Is it possible to get a spread of geometries as a result?

Thanks again!


#10

As far as I know Geometry Shaders are not spreadable, I ran into the same issue already!

Then you basically need to write your own shader without geometry shaders.

Geometry Shaders are anyway not neccessary for your purpose.

You can just edit your forward shader which you use for rendering with the code from vertex noise in the vertex shader?


#11

@teckor it possible, at list on node17_dx11_shading there is an example finally ;]

however you need to hardcode amount of subsets…
Capture

streamout_renderer_advanced_03_multistream.zip (7.1 KB)


Output multiple textures from shader
#12

oh thats interesting @antokhio
just not a realy good option most of the time if it needs to be hardcoded. only if you procedurally generate the code but then I’d rather do some batching


#13

Thanks for all of your help. I learnt a lot!

That’s what I ended up going with. As hard-coding the would have been too restricting and tedious in my case.