#Problem with outline meshes
1 messages · Page 1 of 1 (latest)
As you can see this is my simplest outline which should just invert a mesh (the shader is added in a second material) without any scaling or add-ons to personalize that. I'm not going forward because in most of my low poly assets (many of them, of which some are assets downloaded) this happens: the mesh is not just doubled but the faces split between them, as you can see above with the material added to a single tree.
You can see that even better when increasing the outline more.
What am I doing wrong? From the tutorials I'm looking at, this should not happen...
This is because you have flat shaded mesh. It's triangles have unique vertices. This is a known limitation of inverted hull.
Either don't use such meshes, or use a different technique, like screen space outlines.
You can also duplicate the object, scale it up a bit and render it's back faces with an unlit shader. A bit of a dirty hack, but it works.
Yeah, well...
Scaling doesn't work, it breaks most of the edges of the mesh, it seems like it's not the same as moving the vertex away. I can't change or edit meshes because there are too many, about 3/400 objects have them, and I need the flat shading for the game style. I've read that another option was to duplicate the mesh in blender for each object, apply smooth shade and add it to UV1, but this requires, again, many, many hours, for something that might not work (I failed every single try doing the outlines).
I tried full screen outline with scene depth which I don't like for many reasons, two of them are that the outline grow inside the object - masking some of the 3d features of the object, since I'm using a pixelart filter it will mask most of the small objects made of 2/3 pixels - and you need to use layers to choose which objects are outlined and which aren't. Since you can't just select more layers to a GO, and I'm already using the layers for many things, I'm not gonna rely on those, so this solution would force me to have outlines on everything or nothing. On top of that, it didn't work for far objects, when I tried to draw outlines for objects far away the outline would completely break turning a lot of faces completely black, even the terrain. It only works with close objects.
I've tried to add outlines earlier in the project (about a year ago) when there weren't so many objects, but I failed for similar reasons. With new Unity 6 and much more experience with shaders I hoped to fix that problem and finally add cool outlines but it turned out to be another big mess with no solution working whatsoever.
P.s. I have thousands of objects rendered, inverted hull was for sure going to add a lot of load, even for low poly meshes. I just hoped to have a solution that work.
- Scaling should work. Not sure what you mean by breaking the the edges.
- You can do outside outlines with a full screen feature. It depends on the outline algorithm in the full screen shader.
- You don't have to use layers if you have a custom render pass. Or you could change the layer just for the rendering time.
Inverted hull outlines can be a part of the mesh itself, no extra shaders needed
Which means the outline hull can be smooth shaded to begin with
It's also possible to start with a smooth shaded mesh and instead use a shader to render the faces as flat, which saves on vertex count
- Scaling multiplies vertex coordinates by a factor from the pivot, causing uneven thickness on non-spherical shapes... Normal extrusion moves each vertex outward by a fixed distance along its normal vector, ensuring a perfectly uniform outline thickness regardless of the object's proportions
- Both outlines I tried with scene depth didn't work
- As far as I've seen the only way to apply outlines only in a portion of the objects with a full screen shader is to render part of the objects that needs the outline with a camera that filters the rendered objects with the layer mask, then a second stack camera renders the rest without the outline. To do that, you need to have objects in different layers. I've not seen any other ways to do that, so it would be cool to have some source or documentation for that
Does this require to edit the mesh in some 3d software like blender?
Same question for that sentence
I'm not saying that It's not possible to resolve the problems I encountered, I'm saying that I found no solution for those problems and I spent countless hours for different days trying to implement many outline algorithms, so please don't say "you just need to try different things" in a very generic way or I'm still not moving whatsoever to resolve my problem 😭
- Ok, you're right about this one.
- "I tried and it didn't work" isn't really a proper argument.
- There are many ways to do it. 2 cameras setup is a really poor implementation. You should have a custom render pass instead. You can read more about it in the manual: https://docs.unity3d.com/6000.3/Documentation/Manual/urp/customizing-urp.html
The gist of it:
- Have a custom pass that renders only the desired objects(can filter by component if you don't want to use layers) to a render texture/target as a mask.
- Then a full screen pass before/after post processing that would render an outline near/inside/outside the pixels in the mask.
"Have a custom pass that renders only the desired objects(can filter by component if you don't want to use layers) " this sounds expensive, my scene has some thousands of objects rendered, especially when looking far away. Would it work?
That's entirely up to you. You don't need to filter them every frame. You could register them in a list once when they're enabled, for example. That's more of an implementation detail.
First method yes preferably, the outline would be modeled into the mesh
Second method not necessarily
You can recalculate normals from import settings to force smoothness, beyond that you'd do what you're already doing with the outline but additionally render the base mesh faces as hard
I've spent the past hours trying to implement that and I failed hard. There are very few exaples of scriptablerenderfeatures online and the doc page stays very generic on how to use it. I tried creating a custom scriptable renderer added in the pipeline so it could calculate the outline based on scene depth only for the objects that implemented a certain class which added their renderer when enabled (same thing as you adviced me) but as far as I've understand I can't do that because the scene depth is passed via the whole camera, so I'd still need to have two cameras to calculate the outline based on the depth texture. Or at least, I tried doing that and I found no way to do it in other ways. I even tried coding something with some chatbot but ofc failed and didn't change a lot, the way it tried to "filter out" all the objects that had not my class used to add them to the outline renderer list is by adding a white material and masking every other thing out, which I don't like because it still calculates every outline and I0m pretty sure this system failsin many ways.
On top of that, this is just to render some selected object. I still haven't found a single way to outline the objects in a way that I like, because scene depth still breaks when the camera has a far view and grows inwards.
This is what happens with scene depth, half of the ground is black for reasons, if I decrease the filter to not have the black ground the outlines become very less pronounced and I don't like them
Like that, with a more sensible step in the shader graph. Black ground is not a problem anymore but now the outlines are very few.
I really am going crazy about that. I'm considering trying to find someone with competence online and hire him but I fear that this might take some hours even for them and cost an eye
outline is probably the only graphical feature I tried to implement three different times during the developent of my game and after many hours I simply gave up
OK, there's a whole lot of info in these messages. Let's break it down. Start from sharing your code and a list of issues you need to solve and we'll go over them one by one.
I wouldn't use edge detection/scene depth for per-object outlines. This page https://ameye.dev/notes/easiest-outline-in-unity/ has an explanation of how you can outline specific objects as well with some pointers mentioned at the end of the page. The shader included should work better than basic scaling of the object in object/world space.
Do you need the whole scene to receive edges or just specific meshes?
Using depth-based edge detection will usually look wonky and give some artifacts when moving around. This page explains an alternative that you could look at where a secondary texture is generated (instead of depth/normals/luminance) for better control of where edges show up. https://linework.ameye.dev/section-map/
But as dlich says step by step 🙂
I wouldn't use edge detection/scene depth for per-object outlines. This page https://ameye.dev/notes/easiest-outline-in-unity/ has an explanation of how you can outline specific objects as well with some pointers mentioned at the end of the page. The shader included should work better than basic scaling of the object in object/world space.
Vertex extrusion is what they were doing originally. They have a lot of flat shaded meshes( triangles with unique verts), so extruding the verts creates disconnected faces.
Yeah I saw that but just scaling it along normal right? I was alluding to something mentioned in this article: https://www.videopoetics.com/tutorials/pixel-perfect-outline-shaders-unity/ which gives some great ways to improve the 'vertex extrusion' method. It's still not as smooth as screen-space outlines, but it might give an improvement.
Also smoothing the normals could work using something like this: https://github.com/DumoeDss/AquaSmoothNormals
The smoothing technique seems really interesting, the auto smooth when importing seems extremely cool. It would still keep the flat normals, right? If the original mesh has flat normals
This would probably fix vertex extrusion in a quick way (I'd just need to reimport everything). I wonder if drawing a second mesh per object would lag that much, since I have many objects. I'd need to outline most of the objects in the scene (trees, dropped items etc) and just keep some exceptions, maybe something that is being lit like a fire/torch or something selected
Are you talking about recalculating normals on import, which I mentioned earlier?
Yes but with the package mentioned above, which does that automatically without requiring me to remember to import it with smooth normals AND it saves it in the UV8, which I don't know if your method would work or would force the smooth normals in the in-game file (so, I guess, in UV0). Moreover I think I can personalize the auto-import to automatically re-import all the 3d meshes in the assetr folder saving me some hours of manual re-importing every file
Right, keeping the flat mesh but saving smooth normals as vertex data
Which is the inverse of what I suggested by starting with a smooth mesh and letting the shader render the faces as flat as needed
There's probably no difference in workflow to letting the package do the calculation vs letting the importer recalculate the normals
Smooth vertices are cheaper and not having to have an extra channel of vertex data is more optimized, but the shader would be at least a little more complex
UV0 isn't used for normals but for texture mapping
There's a dedicated vertex data channel for normals which all methods will use regardless
I thought you were against any kind of asset modification. If you're not, then such techniques might be easier than screen space outlines indeed.
Of course, the option remains to bake the whole outline extrusion into the mesh itself
Wouldn't even require another material but it depends how much you want to restrict your workflow for the sake of performance
afaik the github tool I linked doesn't really modify the asset other than storing additional data in uv7 or uv8, so it seems lightweight enough
I'll try a bit of things and I'll let you know, right now I'm outside home, thanks everyone for the help anyway
Yes, that's what I liked..
But it's not working 😭 I installed the tool, no error are shown. I tried to create a very basic mesh-inverter (didn't even placed colors yet) that instead of using the normal vecotr it uses the UV8, it doesn't work T.T
This is the very basic shader that should create an inverted hull
Since I'm still using the normals, as you can see it doesn't work (as expected)
Linking the UV node with the UV7 selected instead of the normal vector should do the trick, so I did that, and I generated the UV7 via tool.
As you can see, there's now the UV7 created. So the script created something, even if no output is given. If I try to use the UV7 without any UV7 it obviously doesn't work and the mesh just moves upwards.
I even tried creatign the UV7 "live" with the shader arleady set to UV7 to check if something changes, and it does, so I expect the UV7 to have the correct values.
However... this is what happens when I use the UV7 T.T
the mesh is randomly broken
This is without the thickness scaling effect... same
Wait. UV has a vector 4 and normals has a vecotr 3. I'll try something. EDIT: still doesn't work with the split.
Doesn't work..
I would try outputting the UV7 directly as color and comparing it to object normals as color to see if they're similar at all
As a sanity check if you recalculate a mesh's normals as smooth you'll know they should match
Unless the tool intentionally writes them in some other space or differently otherwise
Also if you want recommendations before you commit to one of the many outline solutions you could explain in greater detail what kind of workflow and performance concerns you have
Remapped?
Right, as long as you're remapping them in the same way
Anyway they do look noticeably different
Just a guess but if the mesh happens to have a rotation in its transform, the normal baking tool may write incorrect object space normals
That wouldn't explain why the corners split, but it may be a separate issue
The mesh has no rotation when I use the tool because I apply it directly to the mesh, which has no transform, I tried anyway to do the smooth calculations when the position of the single object I was using was in 0, 0, 0 without rotation and it didn't change...
...if you meant the model's inside rotation, I really don't know, the trees are the only asset I downloaded and didn't make mysef, but it does the same with all the other meshes..
If all transforms in the mesh/prefab hierarchy are at 0 rotation, there's no "inside rotation" either so it's not the cause
If you look at the package the example shader has
//Unpack normals and Transform normals from TangentSpace to ObjectSpace so they're in tangent space, not object space
Hi! I got back to work today, and "I" found the problem in the mesh normal tool. Honestly by "I" I mean Gemini since I know very little about how the normals are calculated. I hope you don't mind a bit of AI use for code where my knowledge is low.
"The main bug was that the original tool transformed the averaged smooth normals into Tangent Space (TBN) before saving them. On a flat-shaded mesh, the tangents and bitangents are faceted just like the normals, so multiplying a smooth normal by a faceted TBN matrix made the data faceted again. I modified the Execute function in the BakeNormalJobV3 to bypass the TBN transformation entirely and save the raw Object Space smooth normal instead.
Another issue was floating point precision during the vertex merging process. Models from Blender often have microscopic differences in vertex positions, causing the tool to treat them as different points. I implemented a coordinate rounding logic in the bake script to round positions to 3 decimal places before hashing, which forces the tool to correctly merge vertices that are logically in the same spot." - Gemini
Finally, we adjusted the Shader Graph to manually Split the UV7 input and recombine it into a Vector3. This ensures that the 4-component UV data is correctly interpreted as a 3D direction for the extrusion math."
It seems like the inverted hull works well now. Now:
- I'm gonna create a script that processes ALL the meshes in my assets all at once so they all have the UV7 filled with smooth normals.
- I'm going to refine my shader and personalize it for my game (e.g. vanishing or turning transparent when objects are far away, removing lines inside the object etc.)
- I'm going to add the second material with the outline object to ALL the items that need the outline.
- I'm gonna pray that this doesn't cause lag. With thousands and thousands of objects loaded doubling the load might decrease the performance too much. This is where I fear this approach could fail....
Reading the package's readme would've saved the tangent space confusion
I'm skeptical if this method really is better in workflow or in performance than the alternatives, but I assume you've chosen this one for a reason
The reason is that every other method failed somehow
and this failed too.. it seems like some of my meshes have angles too acute, breaking the inverted hull effect and creating uneven edges, with some edges that have no outlines. Spent other 6/7 hours on that just to fail, again.
With all your "conditions", I think screen space outlines is gonna be the closest approach to what you want after all.
Without counting my failed approach to filter out gameobjects from the outline of a screen space, so supposing I want to apply outlines to every gameobject, the main problem remains that every solution I found to create outines is by using scene depth (doesn't work with far objects, many faces become completely black), edge detections (doesn't work with transparent) and color edges (too many outlines in part where I don't want them)
I even found some combinations of those techniques but they didn't work. Every single outline solution I found resolved some problems but created others
This is an object with not so acute angles that has a decent inverted hull
This tree has the leaves too acute. As you can see the vertical edges are very narrow, if present at all...
The irony of the orange outline of Unity working perfectly... ugh...
- You can filter with layers. If you need more sophisticated filtering - custom render pass and command buffer.
- You should also use normals in addition to depth for better edge detection and avoiding artifacts.
- For transparent objects you'll need to render them to a custom depth buffer. An extra pass can solve this.
There are solutions to all your problems. You're having them simply because you're trying out a simple naive solution and giving up immediately. Obviously that's not gonna work how you want.
It's a screen space outline.
Yes, well... The problem is that I'm mostly a java backend dev (as a job) so everything I know about unity, shaders etc. is learnt by simple tutorials. So it's really hard to personalize a naive solution with little knowledge of shaders, it feels like this requires a really in-depth knowledge. It took me more than 10 days to code my toon shader which has a kinda complex (for me) lighting in Forward+, I thought I had enough knowledge to try again outlines but seems not.
For the points:
- Yeah I tried to use custom code (since I don't want to use layers) and failed. I'm going to try again if I manage to find a solution for the screen space outline, but it's a "later" problem
2 & 3. I'm trying right now this approach. I already tried to use both normals and depth with this video (https://www.youtube.com/watch?v=nc3a3THBFrg) but failed since most of my objects are transparent and the normals somehow don't work with transparent shaders. I'm going to try again now
In this tutorial, I will show you how to get full screen outlines using "Scharr operator" Edge detection algorithm using Unity 6 in Universal Render Pipeline (URP).
👉 Resources!
Project files https://www.patreon.com/posts/132406000/
Per Object Outlines https://youtu.be/JCXYR_5vhNc
Fullscreen Shaders Introduction https://youtu.be/xj_LLsJKO8E
...
Transparent objects would need both normals and depth rendered to a render texture in a separate pass and you'll need to use them in your outline shader. Transparent objects are rendered in forward rendering path, so they're missing in gbuffer and depth buffer.
Can you explain what kind of transparent objects you need to have an outline though? Do they absolutely have to be transparent?
Yes, actually almost every object is transparent. The game is in a "simulation", so many objects have shaders that have a "spawning" effect that slowly creates the objects. On top of that every tree can become transparent when the player is behind it, and this is a really important feature to make the game playable
I already use a render texture to downscale the camera's size and have a pixelart effect. Do I need a second camera?
Trees also have semi-transparency so no I can't just stop drawning them
Fading can be done with opaque shaders and dithering. Also, you can change to an opaque material after the fade. You can render the player behind opaque objects with a render feature. I feel like all these are silly reasons to use transparent materials.
No. You can render to a render texture via a custom render pass/ render graph api.
What semi transparency?
transparency should really be reserved for materials like glass/water and special effects/particles like energy barriers and stuff like that.
I coded that part more than two and a half years ago, I remember that I tried dithering but failed and I ended up implementing normal transparency with Z-axis order so I didn't render faces inside the object. This is another part of the game that took me countless hours and now it works, and it would require a lot of time to recode that from zero using dithering, without knowing if I'd get in the same problems as before. "If it works, don't touch it". But I'm really curious if using transparency has an heavier computational load or just makes everything more complex, like adding outlines
"If it works, don't touch it"
Yeah, but it doesn't. It prevents/makes it harder for you to implement the outlines.
Transparence can contribute to overdraw, so yes it can lead to performance issues.
Though, it's not a direct relation. It's complicated.
Trees are fully opaque here. If I go behind them:
Depending on the distance of the camera they can become completely transparent. There's also a setting that sets maximum transparency of the trees
For example by default setting zooming has the camera really close to the trees and they become transparent
Either use dithering, or change the design of the feature - instead of making them transparent, draw a silhouette of the character through the trees.
No silouette, the player needs to see behind. Again, I'll be really straight to the point - I coded transparency in about 50 hours and outline already took the same amount, failing every single try. I'm not betting that dithering will work this time, even if I have much more experience than 3 years ago when I implemented transparency, just to code a single graphical effect. I didn't plan to spend that much, again, on implementing a seemingly simple graphical feature as the outline. At this point I'm trying to write a custom pass to output the normals texture, but I prefer by far to just drop the outline forever or until I can pay someone to add that than to waste so much time in refactoring a big part of my game just for that. I can spend 50 hours in adding features and making the game actually fun instead of doing that
If you just need an outline for selection(meaning always around one object, and only for it's silhouette), you could probably just render it to a mask, and then render an outline at the border in full screen pass. No messing with depth/normals or any other issues.
and by "not working" for the dithering I mean of course that my skills are enough to make it work without spending who knows how many hours on making it work
No, it would be to improve overall graphics, outline seems to make everything looks better - when done correctly
not to highlight only a single object
Ah, okay. So it's a stylistic outline!
Yes
..not even mandatory, "on" by default but can be turned off in the settings. Jeez, so much time for a graphical feature.
Well, graphics engineer is whole separate profession that people get big money paid for. Of course it's not simple.
And outlines are considered an intermediate-hard problem in computer graphics.
Yeah, with all your requirements, I can't think of a simpler way than screen space outlines. And it's not gonna be easy if you want to keep your transparent materials.
Outlines + semitransparency / dithered transparency is also a design problem, not just a technical one
Should the outlines also fade? Or should they conform to the cutout area even with dithering?
Outlines and fading are combined very rarely
Yes, they should fade away with the objects, the easiest example is the tree. So, I guess a screen space outline is technically not suitable for that? I know how to fade away an inverted hull outline, but I don't even know if it's actually possible to do that with a fullscreen shader. If filtering away objects without using layer is already hard, I fear how hard it is to have semi-transparent outlines....
I can understand why 😭 I'm a coder after all, trying my best to make this work
merry christmas to both btw ❤️ thanks for helping
Fading makes most techniques problematic
If you fade the mesh and the inverted hull, the inverted hull will be visible through the whole mesh during this semitransparency
Even if I draw based on the z-axis? That's how I resolved tree transparency without showing faces that were inside the mesh itself
How does that work?
There are some techniques but as far as I know related to render order and transparency clearing which have their own caveats
I really don't remember but I have to since I'm running in a similar problem with normals. I managed to create the custom pass that draws the normal texture for transparents too, but it's kinda broken and it works only by disablign the depth write in the normal output material texture. And disabling the depth write of course breaks the mesh rendering order, for the various objects I created a manual order on the custom render pass, but now I'm struggling with the faces of the objects: the lines of the faces behind are being draw on top of the front faces. I think I need to do the same solution I did with my trees. I'll write here how that works when I reverse-engineer my own old code 😛
This is the closest I've been to make this work, but many problem persist (outline face rendering order, outlines are not animated with the vertex displacement of the wind made by the tree's shader, there's no object filter to filter out the object I don't want to outline, depth outline is rendered on top of the normals even if it's behind those objects, no fading outline for single objects, outline thickness still not working.... Many, many problems to fix. But at least it doesn't seems like the performance is going down)
Well it sounds like whoever implements the outline will have to know how your custom depth thing works, right
Or swap to opaque dithering
I'm a one man army 😭 I have to remember everything
I will probably do this later on, I have other things to refactor now
No more than everything of what you do 
Anyway, using transparency only where absolutely necessary is a good rule of thumb, like for glass or effects
Because transparency is poorly compatible with most other rendering features
I'll take note for future projects and I'll write this down for the refactoring. When I coded the trees transparency I was at my first 2/300h of experience with Unity in various hobby projects, and it was my first 3d one, so I coded it as best as possible and honestly i'm impressed it just works ahah
Certainly a bigger challenge than you really would've needed to contend with, so not wasted experience
Hi! Sorry for bothering you again. But I'm really close to having something that's working 😁 Normals outlines seems to work perfectly. Depth outlines, however, turn everything black depending on the camera's angle with the terrain or meshes faces angle with the camera. The menu has a more horizontal angle (the game is from top-down) so it can be seen better here. I'd like to have the outlines as it shows when the depth step value is at 0.22, so depth outlines outline some part of the tree and almost all the trunk, in the game it has a very cool effect, but most of the trees in the distance turn black and the terrain too. The terrain is in the outline targets and can technically be outlined because without that it would not be counted to detect the depth of the trees, and they wouldn't have outlines at all.
Is there a way to fix this? I've seen that it is a very common problem with scene depth outlines. I'll send my current setup in a matter of minutes
Code is too long I can't place it in a simple message 😭 [edit: removed link, see below]
That's the custom pass, made to correctly order the transparents, take the normal and depth textures from the two relative shaders and output them [edit: removed link, see below]
Those are the settings. The materials for the normals are two because one has vertex displacement according to the wind, and is applied only to objects in the ZTransparency layer (currently only trees - might have to change that later to apply it to the trees without using layer) and the other material is for every other static object without vertex animation in the shader
The outline target component also filters correctly which objects will have outlines or not, incredibly well. It uses the rendering layer material to check if the rendering layer of the object is the same, otherwise it will not draw an outline on it. That part is not important so I'll not send the monobehaviour "outline target" component
And that's the final full screen shader
Outlines usually combine the normal and depth conditions. Not interpolate between them.
Sharing code properly:
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Oh thanks!
A tool for sharing your source code with the world!
I'll try to do that
if I recall correctly I already tried that, it still failed because some objects - like the terrain - have normals, so when deciding to write the depth outline only in the normals (so the faces cannot turn completely black) the terrain would have most of the normals outlined, where the completely black faces appeared. I'll retry now
No clue how to read your message. It doesn't make sense to me.
Combining both conditions is actually what should prevent you from having the surface completely black
if there the depth difference between the current pixel and one of it's neighbors is above threshold AND the normal is facing perpendicular to the view direction, then you want an outline usually.
Modifying the depth threshold would allow controlling the depth difference required for the outline, while modifying normal threshold, the between the pixel normal and the view direction.
I have done something similar: now depth related outlines are applied only where normals would be, with a different step value. And then another normal outlines is added to the final product
It works, very well!
BUT for one small thing
There's an "invisible" grid where pixel of the outline are removed, and it seems dependant on the line thickness.
It's really hard to see without a full hd video, I'll record it and try to do my best
I hope you can see how there are some large "gaps" between the outlines where they are simply not rendered. Also I noticed that the gaps gets smalled when I increase precision of my pixelart the gaps become smaller up until when the game is in full precision (1920*1080, no downscaling) the gaps vanish
It does the same with only the normals OR depth outlines alone, so it's not a depth/normal problem
That to me implies the pixelated image is being shrunk, which due to nearest neighbor filtering would make pixels disappear
I thought so but as you can see it vanishes in precise points
For example, if I understand correctly, this is what you're telling me: some pixels are "vanished"
I highlighted zome of the zones
as you can see there are parts where the outlines are drawn and parts where they are not drawn. You can see it better when I zoom in and out or rotate the camera: those zones stay still, while the camera rotates
That's a screenshto from the video
If the vanishing seems to appear as vertical bars, I would guess the RT has the wrong width
But it's not a very confident guess
They occur regularly throughout
I have finally cracked the solution! I can even set single outlines transparent, different colors or alpha-clip them (e.g. used in the player spawn generation animation)!
I'll probably do a post later this week in my website and in bluesky. @storm pivot @scenic ridge Would you want to be cited in the "thank you" section of the post? (Nobody reads them, but I do them anyway 😅 )
Website is senfinecogames.com
https://www.reddit.com/r/Unity3D/comments/1q0cnwt/spent_an_ungodly_amount_of_time_to_make_outlines/ Also that's the unfinished product (outlines don't even become transparent when trees are, I think I'll leave it like that, it's useful), I'm not completely happy with how they look, but it's the best I can do right now. Flickering is sadly a whole-project problem
I'm fine without being mentioned. Just mentioned some things that you would find out yourself anyway.
More than that, I'm interesting in how you got it working and/or what the issue was.
Today I'll do the post, I'll make it a short show off/tutorial. Most of the problems were related to draw order, pixel thickness and the weird lines that were caused by floating-point errors and unwanted texture filtering that created "soft" gradients between pixels, leading to flickering gaps (the horizontal and vertical lines) where the shader failed to detect a clean edge. To fix this, I implemented a hard-snapped sampling method that forces the shader to align coordinates to the exact center of each pixel, ensuring binary results and a stable outline
looking forward to the show off/tutorial if you still plan to do it. im also trying to get some more accurate outlines on my project
Yes yes, sorry, it's taking time because I stumbled upon other problems that I didn't notice and I'm fixing them. I'll release the code with a brief explanation as soon as possible ❤️
Hi!
... yes I never stopped refining the outlines. Turns out I still had tons of bugs. If you're still interested, I also wrote the article in my website!
https://www.senfinecogames.com/2026/01/26/dynamic-pixel-perfect-outlines-for-unity-urp-opaque-transparent-full-screen-outline-walkthrough/
It's a walkthrough, not a plug-and-play solution, even if I gave some code with github. My solution is too much customized for my problem, I don't think it can be generalized easily.
I'm also pretty sure it can be optimized a lot, and I'm really open to suggestions, but... I'm definitely not gonna touch a line of code related to outlines for the next months. I've spent so, so much time with this simple feature...
awesome, i was still reading about outlines so this is perfect, thank you ^^