Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 JedBeryll · Dec 15, 2016 at 09:59 AM · shadervectrosity

Border overlapping shader

Hi!

I'm using Vectrosity to draw circles as borders around units but there's a small issue. I want the borders to be invisible where they overlap (as shown on the image). I'm thinking i need to add a material with a special shader to vectrosity, i'm just not good with shaders, so is there already a shader that does this or do i have to work something out? Is there any other/better way to do this?

I can't just create the borders "overlapped" because the units are moving so at one time they should cover each other, other times the whole circle needs to be rendered.

alt text

overlap.png (5.1 kB)
Comment
Add comment
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

1 Reply

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

Answer by Pangamini · Dec 15, 2016 at 10:06 AM

There are many ways how to achieve what you want, but the question is, why do you need to use Vectrosity for it? With just drawing circles you have no information about the inside of the filled circle, so you can't really do much there. Also you didn't give many details on the specific usage inside your project, so it's hard to tell what would be the best approach

Quick sketches for 2 different solutions that crossed my mind now:

  1. Render each inner circle to a stencil; use the stencil in line renderer to get the insides discarded (should work with Vectrosity, if you have a way how to render the inside - filled circle)

  2. If you are aiming for a glow like effect (like in Left4Dead), you could render objects (circles, spheres whatever) into a separate buffer, blur it, subtract by the original non-blurred value (keep it in alpha or somewhere) and then just blend with the main RT

Comment
Add comment · Show 4 · 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 JedBeryll · Dec 15, 2016 at 10:19 AM 0
Share

Vectrosity seemed the cleanest way to draw different sized circles (like radar ranges that can change the radius) with the same border width. The circles are actually not filled, i just need to draw lines. See Endless space solar system borders but without the fill.

First sketch sounds somewhat like what i need, i just don't know how to render to a stencil.

avatar image JedBeryll · Dec 15, 2016 at 10:43 AM 0
Share

Ok i looked into the stencil and i should be able to figure something out. Looking at the pictures here seem to answer something similar.

Thanks for letting me know about this.

avatar image Pangamini JedBeryll · Dec 15, 2016 at 11:32 AM 0
Share

Also, there are better ways how to render a circle with uniform width than doing it with complex geometry. For example, I use a shader that can render a circle on a quad. There are no input textures, the shader simply takes the UV, calculates the distance from center (squared, sqrt is expensive :) ) And renders the circle based on that value. Then you can use advanced techniques utilizing ddx and ddy to make the edges of the circle smooth independently from the geometry size - meaning that the smooth edge may always be 2 pixels wide on your screen - making it a superb solution for antialiasing of these circles. Also, no geometry is required, so the circle will be as perfect as it can be, no matter how big the circle and your screen is. Just a food for thought.

avatar image JedBeryll JedBeryll · Dec 15, 2016 at 12:02 PM 0
Share

Interesting thoughts... I'll have to learn more about shader coding before i start messing with this.

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

81 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 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 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 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

Are there any 'ghost-like'/smokey shaders for a line material? 0 Answers

How do you write a flexible wireframe shader with backface culling? 1 Answer

How to force the compilation of a shader in Unity? 5 Answers

Add Light To Shader 1 Answer

Is it possible to pass SubShader tag as a parameter? 2 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