AbsoluteWorldPosition and WorldPositionOffset relationship

Hi all,

currently I’m a little confused about how the high level Material BP graph concepts are mapped to specific vertex/pixel shaders in UE4. Especially I’m interested in the AbsoluteWorldPosition node and WorldPositionOffset input of a material.

The documentation of Absolute World Position node says it’s the position of the current pixel, so it’s calculated in the pixel shader. As I know there is no Material expression for Vertex World Position directly. In the source code, I see that there are calls to GetMaterialWorldPositionOffset() in vertex shaders (e.g. BasePassForForwardShadingVertexShader.usf). But If I only can use Absolute World Position node to access some position information of the current PIXEL, then connect the result to WorldPositionOffset, how can this information be used in the vertex shader (that runs before PS)? For me, now Absolute World Position is something that “sometimes can act as vertex position”, but generally it contains the pixel position. So it’s the point where magic happens that I would like to understand.

Basically, my question is how this kind of material can work:

what it does:

Sorry for maybe not begin clear, I may misunderstood some trivial points, but after reading the Rendering and Material documentations I’m still not sure about how these things work.

Thanks in advance.

Hey tszucs -

So you are on the right track, but remember that all input nodes like Absolute World Position are also vectors. So in the math you are using above the node is returning a pixel location as vector information only then passes this vector into you math. At the end of the chain your math is then passed into the vertex information of the World position offset. Its important to remember that all materials in UE4 are HLSL scripts which do not work on the direct shader pathway directly but utilize the basic pathways the code sets up to allow for more complicated effects. In more basic terms, think of it like everything is already rendered, materials are just adjusting the rendered image.

Thank You

Eric Ketchum

Thanks for the info, I think it might worth mentioning somewhere in the Material documentation how they work :slight_smile:

I have doubts about the validity of this answer and don’t see how it answers the question (maybe i’m missing something?). Whatever you feed to “World Position Offset” is evaluated in the vertex shader right? If so, where does “Absolute World Position” come from? Is it the world position of the VERTEX and not the pixel when used in this manner? I also agree that the documentation could be better here, whatever the answer is.