I created my first custom shader and want to do some vertex displacement based on an input texture. I tried in various ways to make ShaderGraph "remember" that this is still a vertex position in Object space after the manipulations ("Multiply", "Combine", tried various things), but nothing helped. In the end I worked around it by adding a "Transform" node with Object -> Object. This feels like a hack though. What would be the right way to do it?
#ShaderGraph "Transform"-Node workaround for vertex displacement
1 messages · Page 1 of 1 (latest)
You aren’t showing the relevant bits to answer the question. But in general, the object space enum is just a selector for the math inside the node, it has no meaning outside the node. What you get out of nodes is a pure value without any context.
Hmm so why can't I connect the RGB(3) to the Multiply "B" then?
And what would be relevant? The output of the transform directly connects to the Vertex Master Position
well, you didnt specify that the actual problem was, what would make sense to show is where the values originate and where they go to. you are only showing the point where you notice the issue, not where it originates. Maybe you have values in the vertex and frag part of the shader and need to move the vertex position into the frag part.
if you have the multiply connected to the vertex position you cannot connect values that are derived from data that only exists in the fragment shader
Ah. Well, sure. The whole shader graph is rather large but I'll copy paste. I'm trying to create a NatureRenderer shader, with Wind and grass height controlled by a global texture. So let's start with the wind:
Oh you might actually have just explained the issue
So, for the full picture, first the wind, which is connected to R and B channels of the "Combine" node in the first screenshot:
Then here's the "G" part of the Combine node: The height controlled by a global texture:
use SampleTextureLOD
Quickly scanned the docs... why?
I have no MipMaps for my global texture
It's basically a world texture, defining where grass grows
it allows you to connect to the vertexposition output
when in the vertex shader, mip data cannot be derived, so you need to provide a choice, which you can do with the -LOD sampler
Right! That worked! And makes sense. I wouldn't have guessed that though. Did ShaderGraph provide any info, warning or similar that I missed? Or should I just have known