Download

Converting this Unity shader to material on UE4

Hi folks,

Im having bad time trying to convert this sample shader into unreal material editor:

                        struct appdata_t  
                    {
			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 *0.01;
		    o.pos = mul(UNITY_MATRIX_MVP, o.pos);
		    return o;
        }
        
        fixed4 _OutlineColor;
        
        fixed4 frag(v2f i) :COLOR 
		{
	    	return _OutlineColor;
		}

Any help would be apreciated

What does the shader do? The materials in UE4 are way better than what Unity offers, but I don’t know the Unity shader code

I am typing on my phone so no access to UE4 but this is pretty simple, unless I am reading this incorrectly. Take a vertex position node, multiply it with the vertex normal * 0.01, do the matrix multiplication and plug that into world position offset.

If anyone who is more savvy with CG shader language can weigh in, even better.

Anyone have good primers on CG-shader-language to UE4 material editor conversions? If so, it would be most appreciated…

DamirH got it right. Its moving the vertex position in the direction of the normal. Heres how it would look in the material editor

95029d9090b03e1c88f44b00262781fe9ec0eb38.jpeg

Toon shader from asset store rigth?

This is the output from unity editor: As you can see is the black outline effect around the mesh:

is this the effect you want to archive?

Theres a post process effect on UE4 thats does this effect nicely but is not mobile friendly…

Any way, going back to your request i cant reproduce this line on ue4:
o.pos = mul(UNITY_MATRIX_MVP, o.pos);

That line doesn’t need to be reproduced, its just passing the vertices from model space to projection space, which is already done internally in the UE4 materials.

Thanks for you kind reply, im having troubles getting this effect work on unreal, finding how to make it work will make it more mobile friendly since post process effect outline is costly.