Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 BloodWiing · Feb 27, 2020 at 08:02 PM · lightingshadowsgenerationmesh rendererflat

Generated Flat Shaded mesh problems with leaking light on edges.

I worked on a little project using procedurally generated mesh and after a few tests noticed that it looks better when it's not shaded smoothly.

So yes, I've gave each triangle their own vertices, but this does raise a problem...


At the seams there seems to be light leaking, which is obvious why, but can't seem to find an easy solution.

Normal bias helped remove light that leaked over on to a flat surface, but it made it worse when it came to the seams.... :c


Images below:

alt text Bias: 0.05 | Normal bias: 3

alt text Bias: 0.05 | Normal bias: 0


I tried googling and found no answer to what I should do, well maybe I just searched using wrong terms or something... But in my case I got nothing.

Though I did find a post somewhere that mentioned using invisible mesh to only cast shadows. Don't know if that's the only way and if it would even work, but that's just what I've heard. :/


I will edit the post and show more settings if needed, but hopefully this is enough and someone knows how to get rid of this. :/

Yes, lowering the bias makes the leak smaller on the seams, but it also creates other artifacts in shadows.


Thank you for at least reading this question <3

unity-2020-02-25-22-58-07.png (38.2 kB)
unity-2020-02-25-22-58-01.png (57.3 kB)
Comment
Add comment · Show 1
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 BloodWiing · Mar 01, 2020 at 02:47 PM 0
Share

reviving this

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Namey5 · Mar 02, 2020 at 05:56 AM

There isn't really much you can do here using the shadowmap system that's part of the built-in renderer. Biasing is still a huge problem in the world of rendering, and most workarounds create other issues (like the normal bias you see here).

If you wanted to use normal bias without edge seams, you would need a second version of the mesh with a continuous surface (i.e. joining all vertices/triangles) set to render shadows only. That way, the normals will connect and the individual triangles won't separate during the shadow bias step. I try to avoid normal bias altogether because it does strange things with most non-uniform meshes, however that still leaves you with the problem of regular bias seams.

The only real 'fix' for that would be to use an additional contact shadows image effect to mask the edges properly. This works pretty flawlessly, but they aren't straightforward to implement, and most third party implementations aren't free. Here's an example Keijiro Takahashi made however;

https://github.com/keijiro/ContactShadows

Comment
Add comment · Show 2 · 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 BloodWiing · Mar 02, 2020 at 08:27 AM 0
Share

$$anonymous$$aking a second object that only casts shadows and has shared vertices isn't a hassle for me as that just requires a change of a boolean, but I'm worried about performance, especially if the object would be altered frequently (which is likely that I'll do).

So I'll try to look in to Contact Shadows.

Thank you for giving me some directions to what the issue is and what can be done to solve it! I'll update this if I progress :>

Also I'm still new to this markdown, how do you separate the paragraphs with a line break in between?

avatar image Namey5 BloodWiing · Mar 02, 2020 at 11:44 AM 0
Share

The rendering shouldn't cost anymore for performance (as you would be skipping the main mesh for shadow rendering, and only rendering the second during the shadow pass), but yes having two copies of the mesh would have some overhead in terms of actual processing.

As for adding line breaks, you can use the HT$$anonymous$$L break tag <br>. I'll be honest, I only figured out base HT$$anonymous$$L text tags work here recently.

avatar image
1

Answer by Bunny83 · Mar 03, 2020 at 12:13 AM

An alternative approach would be to use a mesh with shared vertices and don't use vertex normals at all. If your target hardware supports the ddx / ddy function you can calculate the surface normal inside the fragment shader with the partial derivative functions ddx and ddy:

 // in the cg fragment shader
 float3 x = ddx(IN.pos);  // IN.pos is the screen space vertex position
 float3 y = ddy(IN.pos);
 float3 normal = normalize(cross(x, y));

However it depends on what kind of shader(s) and advanced features you want to use if such a custom shader fits into your rendering pipeline.

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 martt_1er · Jun 18, 2020 at 07:54 AM 0
Share

Hi. I'm interested on this technique. Do you have any resource or tutorial which explain it a bit more? And in you opinion, is this technique heavier (in rendering calculation) than multiplying vertices, or lighter?

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

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

No shadows. 2 Answers

Shadows disappear when using Pro Image Effects or HDR 2 Answers

Weird Lighting / Shadow Since 5.1.3 Update 1 Answer

Shadow sprite rotation regardless of the light source 0 Answers

Crisp sharp shadows (self shadowing No Ambient light) 0 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