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
1
Question by dramamine · Oct 31, 2013 at 01:05 PM · shaderwireframesamplingtron

Shader supersampling

I'm currently learning about shaders and trying to write my own. In doing so, I'm trying to make a racing game that has that 80s neon Tron-esque wireframe look.

I've written a fragment shader that does... well, something like that.

alt text

That's pretty much what I'm going for, but as you can see, there's a lot of aliasing going on (it even looks somewhat better on the picture than in Unity). Since it's not a texture, I can't really do mipmapping, texture filtering or any of those readymade methods.

Does anyone have any ideas on how to improve this? My best guess is doing a second shader pass that does per pixel supersampling.

Is that the right way to do this? Also, if it is, I would appreciate any tips or resources on how to actually do shader supersampling.

Thanks.

ss.jpg (79.4 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

Answer by tanoshimi · Oct 31, 2013 at 01:36 PM

As you've not posted your existing code, I'll just assume your current fragment function goes something like:

 // If this pixel lies on a gridline
 if (frac(x/GridSpacing) < GridThickness || frac(z/GridSpacing) < GridThickness) {
     // draw the grid colour
     return grid;
 }
 else {
     // Not on a gridline - don't draw anything
     discard;
 }

So you're defining a "hard" boundary between points that lie on the grid and those that don't. Instead, why not use the distance() function to calculate how far a point lies from the centre of each gridline, and define some sort of rolloff function (perhaps logarithmic?) to fade the alpha of pixels that lie further from the centre of each line. Those that lie further than a certain threshold could be discarded altogether as previously.

That will create the smooth gradient you're looking for without any need for a second pass (which I'm not sure would have helped you anyway).

Comment
Add comment · Show 1 · 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 dramamine · Nov 01, 2013 at 09:01 PM 0
Share

Thanks for the reply. I can't believe I didn't think of that. However, that doesn't really solve my problem.

alt text

It's just something I jotted down quickly so it's far from perfect (the intersections look pretty bad, for instance), but it's clearly visible that the problem is still there.

Yeah, it looks much better near the camera, but everything that's a bit further looks pretty bad...

bla.jpg (48.0 kB)

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

16 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

Related Questions

Create a Wireframe Shader with Shader Forge 1 Answer

My custom shader doesn't render in wireframe 0 Answers

How to make vector monitor graphics in Unity? 3 Answers

Wireframe Shader With Shared Lines Removed 0 Answers

Pixel perfect sampling in surface 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