Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by gumboots · Mar 18, 2014 at 11:51 AM · 2dshaderoutlineoverlapping

Outline Overlapping Game Objects

Hi there,

I'm after an outline effect on quads, that when two quads overlap the outline only shows up outside both of them. Not a toon style outline, just a single pixel line going around the outside of the 2d geometry. I'm hoping somewhere here has utilised a similar effect.

Any and all help is appreciated.

EDIT: The quads will also be resized, sometimes proportionally sometimes not.

EDIT 2: It is for an iOS project. I am the worst, information wise.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image frarees · Mar 18, 2014 at 12:14 PM 0
Share

I'd go for a shader that draws a outline. You can use and tweak this one to fit your needs:

Silhouette-Outlined Diffuse

avatar image gumboots · Mar 19, 2014 at 09:58 PM 0
Share

Ah this looks like a good start, however modifying the shader to suit my needs is beyond my ability. It also appears to be quite a complex shader, forgive my ignorance but is it packed with functionality that I won't utilise? (The project is on iOS.)

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Owen-Reynolds · Mar 18, 2014 at 02:56 PM

If it's a square-edged outline, should be able to, essentially, put a slightly larger black square behind every quad. That way, when quads touch, each covers up the adjacent border of the other.

The problem is, real borders almost always have a tiny bit of rounding on the corners (when the border is 2+ pixels with a tad of transparency on the outer ring.) That gives a slight dip in the new end-to-end combined border, where the old corners meet. And a darker dot where the transparencies reinforce in the overlap. But a fully opaque square border should be fine.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image gumboots · Mar 19, 2014 at 09:56 PM 0
Share

Ah, that's a good solution for quads. Sadly my question had a little less info than it should have, I want the ability to stretch the quads to whatever shapes I like. I can obviously manually resize each border as I resize, but the problem is with dynamically sizing objects.

avatar image Owen-Reynolds · Mar 20, 2014 at 01:33 PM 0
Share

So, the problem is the border becomes too thick or thin as the objects grows/shrinks?

Just more math. Say the quad is 4 wide and you want a 0.1 border -- back-border is 4.2 wide. Set child back-border local scale to 4.2/4=1.05. Say the quad shrinks to 0.5 wide. Same 0.1 borders gives 0.7 for the back part. localScale should be 0.7/0.5=1.4.

Of course, you could keep square+border as separate objects. Less math (background scale is always X+0.2) but more things to move around.

avatar image gumboots · Mar 22, 2014 at 01:16 AM 0
Share

Yeah I was looking for an in-editor solution to see the effect, but doing the resize with code on awake solves the issue as well. Thanks very much!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Edge outline & 2D shadow Shader for planar mesh 0 Answers

2D Outline shader issue: Apply outline on separate sprites as a whole? 0 Answers

2D Lighting Material Overlap Issues 4 Answers

Unity 2D Shader Graph Sprite transparent when in shadow 0 Answers

3D Text - Stroke/Outline 4 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges