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 Vonni · May 26, 2013 at 07:33 PM · shaderlabprocedural meshinline

Inner shadow on procedural 2D surface

I have arbitrary 2D shapes that are created at runtime by slicing other shapes. They are often very close to eachother and need the "shading" inside the mesh.

alt text

I have spent hours on end finding out a way to write this shader. Been searching the web for people doing something close to this and found none.

I guess I need a shader that gets all the mesh triangle edges and find the border of the mesh by removing those lines with an opposite line. And then somehow shade pixels based on their proximity to this border. But this sounds very heavy to me and I don't know if its even possible :S

Or maybe I'll procedurally create a purely visual mesh in 3D to get the distinction between my meshes I want (in addition to an invisible simple 2D mesh for further cutting).

I'm open to any suggestions, thanks in advance!

Note: - Very low poly shapes. - Camera is static, Orthographic, Side-view - Mobile (Android) - Meshes are created by user slicing meshes.

EDIT: spelling

uploadedimage.png (113.7 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
1

Answer by Phong · May 26, 2013 at 08:18 PM

Have you considered using the "colors" channel in the mesh? RageSpline uses this technique to put outlines around its spline based shapes. Its very easy to write a shader that uses colors in the mesh. You probably need to create an extra row of vertices slightly inset from the edge. Then give the edge vertices a dark color and the inset vertices a light color and write your shader to use these vertices.

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 Vonni · May 26, 2013 at 08:37 PM 0
Share

I will try this out, thanks. I would prefer a pure shader solution, but I guess there is a reason I can't find any trace of it anywhere :)

avatar image Phong · May 26, 2013 at 08:44 PM 0
Share

There are some outline shaders on the Unity Wiki site

http://wiki.unity3d.com/index.php/Shaders

I think I looked at them once but wasn't happy with the performance/appearance. The nice thing about the colors is it is VERY fast and can look great!

avatar image Vonni · May 26, 2013 at 08:51 PM 0
Share

Ye, no. Those shaders won't cut it. $$anonymous$$ost of them don't even work on 2D shapes because they use normals to expand. What I would do in that case would be to shrink my mesh. But i have concave meshes as well and would also like it to be a smooth transition. But I think I can make something nice with the inset verts and with vertex-coloring.

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

14 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

Related Questions

How to turn off sorting of transparent objects? 1 Answer

Blending 3 textures using a shader 1 Answer

optimising shaderlab code and using properties variable 1 Answer

How to smoothen/sharpen edges while using alphatest 0 Answers

Setting renderstate conditionally in the shader 1 Answer


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