Support Forum

ALINE Line drawing is disturbed on Mac

Line drawing is disturbed on Mac.
The video below shows a new Built-in RP project in Unity 2020.3.20f1,
just imported ALINE 1.5.2 and opened the Example4_Styling demo.

ALINE on Mac

The same problem occurs in the URP project.
It renders beautifully on Windows with no problems.
I need line thickness adjustment on Mac as well.
Could you please fix this problem?

My Environment
Mac OS 12.3.1, CPU Intel, GPU Intel Iris Plus Graphics 655,
Unity 2020.3.20f1, Graphics API Metal, Build target Standalone for Mac

I embedded a GIF in the above post, but it seems that it may not be displayed, so I’ve uploaded snapshots.

Snapshot of movie 1

Snapshot of movie 2

Snapshot of movie 3


Video files are also uploaded in case you are interested.
Zipped .mov file 30sec 32MB (Google Drive)

I have read the release notes.
I would like to try version 1.5.1.
How can I get past versions?

I found the cause of this problem.
It is the “decodeLineJoinOffset()” in “aline_common.cginc”.
If this function is forced to return 0, the automaticJoins will not work, but the drawing will be undisturbed.
It seems that the bitwise operations are not working correctly on Metal.


Thank you for digging deeper.
Would it be possible for you to test to change the decodeLineOffset method to this:

int decodeLineJoinOffset(uint joinHintInstanceIndex, float2 uv) {
	// Which other line to try to join with.
	// The joinHintInstanceIndex is encoded as two 16-bit integer offsets
	// for which half of the range (<32768) indicates a negative offset from
	// the current line, and the rest indicate a positive offset.
	// The upper 16 bits is the offset for the backwards direction
	// and the lower 16 bits is the offset for the forwards direction.
	uint joinIndex = joinHintInstanceIndex;
	if (uv.y < 0) joinIndex = joinIndex >> 16;
	return (int)(joinIndex & 0xFFFF) - 32768;

and see if that changes anything?

Hmm. Actually I think I can see the issue. Unity is generating some bad shader code.

I first casts the joinHintInstanceIndex to a float before casting it back to a uint, which will result in a loss of precision and messed up output.

I’ll try to report this to Unity.

[EDIT] I’ve submitted a bug report here:

Hi, That function is exactly the same as the function in 1.5.2, right?
It was the same result.
Instead of one uint contains two values, why not use two int or short?

Two ints will use more memory, and drawing is actually limited quite a lot by the upload bandwidth to the GPU. Shorts cannot be used because glsl don’t really have support for that without extensions.

Anyway, you can try the latest version of ALINE (1.5.3), I have added a workaround there.

I tried 1.5.3 and it has the same problem.
Need to stop using bitwise operations on Metal.

And, until this issue is resolved, you should mention on your store page that Mac is not supported.

[Screenshot Aline1.5.3 on Mac]

However, my project does not use automaticJoins, so this solution is fine for now.


That’s weird. Would it be possible for you to select the aline_outline shader in the inspector and click the “Compile and show output” button (making sure Metal is selected as the target), and send me the output of that?


You should try it yourself on Mac…


I would, sadly neither I nor any one of my friends are using mac, but I will try to get a hold of one…

Please buy a cheap used Mac mini.
If Short is not supported by GLSL, why not branch processing between GLSL and others?