[Unity] Outline by normals for mobile game URP

Hello there ! :slight_smile:
I was wondering if you guys ever had to create an outline based on the normals of the mesh that would run easily on mobile on more than one character on screen (URP)? If so, which technique did you used to grant this result ?

The outline effect that I am looking for is the same which provides Unitychan toon shader outline (shader too heavy on mobile + doesn’t work with URP) or by copying the mesh and reversing its normals (two skinned meshes for one element is also too heavy).

I’ve tried to simplify the Outline part of the Unitychan toon shader in order to use it else where. But as I am an absolute noobie on the HLSL language I can’t get to understand very well how it works and how to implement it in the shader graph.

Thanks in advance! I would really appreciate a little help o/

IIRC heavier vertex count avoids any clone/duplication . I’m not even sure URP shaderGraphing can do it without some shader snips

but try two pass method

1 Like

Thanks for your answer @Torbach ! :slight_smile:
I’ve started to look into HLSL via the tutorials you gave me but it says:

If you define multiple passes in the default render pipeline they’re drawn one after the other (URP only ever draws one pass afaik).

Does that mean the two pass method won’t be working on URP? What did you meant about “shader snips”?
I’ve spotted that he also have a postprocessing outline tutorial. I am scared that it could be costy on mobile, what do you think about it?

by snips i was refereeing to Custom function node

technical details are outside my skillset – however I did find this with the URP using post-process; I think this setup should get you started if not for info the rendering/technical artists can dive into

The Toon Outline Shader you imported at the beginning consists of two parts: the actual Shader that
handles the rendering operations needed to produce the outline and a Material that will activate the
Shader.

The Shader (“ToonBasicOutline”) can be found in Assets > Shaders and the Material can be
found in Assets > Material

(Figure 04)
image

Hi Lyott,

you can check this also.
This shader has two passes. The first pass is pushing the polys by normals.
It is not complex. Should run on mobile device.

Here you will find the shader from Anthony Bléchet.
http://www.shaderslab.com/demo-19---outline-3d-model.html

Cheers

Hey again :slight_smile: ! Thank you guys for your answers!

After research + tests, the two pass method (Inverted Hull) doesn’t work in URP as this render pipeline does not accept more than 1 pass.

:smirk: However… there is a little trick that managed to work! I found it in this forum.

Globally, you need to divide your two pass shader into two different shaders: one that contains the outline, and the other one the shading/texture.
Then on your mesh renderer you need to add one more material element which will be used to add your outline mat (other forum that explains how to do it).

I’ve tried this trick with Anthony Bléchet’s outline shader (that @yunus posted) with two characters on screen on mobile and would run quite good.

NOTE: if you have more than one material id referred on your mesh renderer, the outline will only affect the last one.

1 Like