Access vertex position in materials

Hi, how do i access the vertex position in the material editor?

Hey Eqric -

You can adjust the vertex positions using the World Position Offset input in your material setup. Are you looking for a way to call a particular vertex position? Can you let me know what you are ultimately trying to achieve and I can probably point you in the correct direction.

Thank You

Ketchum

Hi Eqric -

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.

Thank you.

Ketchum

1 Like

Sorry, i was away on a trip.
Not quite what i asked for, i need to find out the vertex position in the world, but i later found out about the “Absolute World Position” and it looks promising.

Hey Eqric -

If I am understanding what you want to do, then teh Absolute World Position node should be able to give you access to the information you need. As you work on it, if you have further questions feel free to ask here.

Thank You

Ketchum

Im not him but i have a question, im coming from unity and want to create this simple shader into material nodes:

 struct appdata_t  //appdata_tan: vertex consists of position, tangent, normal and one texture coordinate.
        {
			float4 vertex : POSITION;
			float3 normal : NORMAL;
		};

		struct v2f //fragmentInput
		{
			float4 pos : SV_POSITION;
		};

        fixed _Outline;//Editor Parameter

        
        v2f vert (appdata_t v) 
        {
            v2f o;
		    o.pos = v.vertex;
		    o.pos.xyz += v.normal.xyz *_Outline*0.01;
		    o.pos = mul(UNITY_MATRIX_MVP, o.pos);
		    return o;
        }
        
        fixed4 _OutlineColor;
        
        fixed4 frag(v2f i) :COLOR 
		{
	    	return _OutlineColor;
		}
        I dont know how to translate this onto unreal material

Hi son1cman -

I am not as familiar with ShaderLab language can you let me know what you shader is supposed to yield? (Picture example from Unity would be fine as well)

Thank You

Ketchum

Hi there!!!

https://d2ujflorbtfzji.cloudfront.net/package-screenshot/ddfb16bc-409d-4f34-8e5c-392e30ed6668_scaled.jpg

As you can see the shader does the black outline on the mesh…
(I know you can do this outline using post process effect material and custom depth, but this option doesnt work for mobile)

I have done some research and come up to this conclusion:

The World Position Offset input allows for the vertices of a mesh to be manipulated in world space by the Material(This shader just “extrude” each vertex along his normal vector)
Theres a content example that extrudes vertex, but i dont know how to make it outline my object. (Content Examples Sample Project for Unreal Engine | Unreal Engine 5.1 Documentation)

Hi son1cman -

There are two options that you can try here. Assuming your mesh is mostly smooth edged (not right angles meeting), you can try a setup like this:

which yields results like this:

As you can see there are issues with the way the outline is applied here which case the top pixels to render in the same depth resulting in the black top.

Alternatively and probably better ultimately for performance and for most accurate outline would be the old method of doing outlines which is to duplicate the mesh, increase the duplicate’s scale by a small outline (thickness of your outline) and invert the face normals.

In this case you would end up with each results very close to the post process method like this:

Thank You

Ketchum

Thanks for this awesome reply… how do you invert the normals on unreal? can you post the project files for the post process double mesh example? Thanks Erick

Hi son1cman -

No, the normals were inverted in Maya and imported back into the engine. Feel free to export the Cube and Sphere Mesh in this project for details.

Thank You -

Ketchum

Mobile_Outlines

Is it possible to get an answer to the original question as well?
I would like to access a specific vertex on the tesselated mesh.
Or isolate a set of vertices.

Something similar to what vertex paint does/provides, but done via the shader/hlsl instead.
Let’s say for example sake that the vertex is always the 10 vertex to the right and the 10 vertex from the top.
How would I go about applying a x10 to the vertex normal G of that specific vertex within the material?

I can do this for the area with world position. But its not always the 10x10 vertex that gets shifted.

@MostHost LA did you ever find a solution to this?