Shader Graph (basic question)

manda

Newcomer
For learning purpose and in order to deal with the shader permutation issue, I have decided to implement a basic Shader Graph.
As you might know some Shader Graphs don't support vertexcode they only create pixelcode. In my project I have chosen to deal with both vertex and pixel code. Therefore I need to deal with generic codes. For example basic nodes like arithmetics such as Add, Subtract, Multiply should be generic nodes so that they can be used both in pixel shader and in vertex shader. Generic nodes are handled as vertex code by default, only if there is pixel code dependecy then that generic node is set to be pixel code. The main question I have is how is this generally handled in Shader Graphs that support vertex AND pixel code?
 
I can't speak for everybody, but in the system I'd done, there's no "default to vs" or "default to ps" about an individual node in a graph. A node is just something that corresponds to a tiny snippet of code, and it has no embedded "purpose" or anything.

The way I did it was rather simple. In the same way that vertex and pixel shaders are 2 separate stages of the pipeline, I made them 2 separate graphs in the overall description of the renderstate for a given object. You don't really have to do anything to the nodes to make them "aware" of what type of shader thread they're running in. The most you might have to do to a node to make it "aware" is mark the node as something that may not successfully compile in a vs or a ps, and that's just static data, and it's something of a rarity. I didn't bother trying to worry about a node being "unusual" for use in a vertex shader or anything, or try to say you don't want to do vertex texturing -- it was more or less a caveat utilisor type of thing. If you do something that can't work, you'll see it generate errors.
 
Back
Top