Vertex Shaders in custom nodes?

I’ve been reading these great series for c++ programmers who work on rendering:

I’m starting to miss the point of them…

Can we create a simple vertex shader assigned to a material the same way unity does?
I’ve been told 99% of fragment shaders (aka pixel shaders but wrong name) can be done via the Material Editor… can we create vertex shaders too ?

Thanks

You can’t create a vertex shader in material editor, but you can force a part of material graph to be calculated in vertex shader by using vertex interpolator material expression.

I received a different comment from somebody else who says I actually CAN add vertex shader code to a custom node… (not optimized, though).

Ugh…

It’s as optimized as any shader code. It’s just don’t have any materialeditor special optimizations. Like precalculations for dynamic parameters.

how would one use the vertex interpolator inside a custom node? Id like to calculate some stuff in the vertex shader and some stuff in the pixel shader, within a custom code snippet.

you would not do that, nope. When you have custom node connected to outputs that are evaluated in both vertex and pixel shader, you can separate the code inside by using #if VERTEXSHADER preprocessor directive, with a small remark that this might not work for nanite.

1 Like