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 bromley · Jul 15, 2016 at 06:55 PM · shaderlightingmaterialshadowglass

Glass shadow problem

alt text

In this picture you can see the light passes through a window and ends on a surface... unfortunately you can see a lot of tiny points on the surface, but the glass is transparent. I don't know why this happens: shadow resolution and strenght are at maximum.

Anybody knows how to solve this?

immagine.png (465.5 kB)
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 Namey5 · Jul 16, 2016 at 12:58 AM 1
Share

Try increasing the bias of the light/modifying the clipping planes of your camera.

avatar image Zitoox · Jul 16, 2016 at 01:13 AM 0
Share

How did you do the glass? I tried but i can't figure out how to make a glass texture =/

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Eno-Khaon · Jul 16, 2016 at 01:24 AM

What you're seeing is the result of working around the shadow mapping's limitation that it is (almost, but not exactly) all-or-nothing in the shaders.

I'm assuming you're using the Standard Transparent shader, which supports a rather fascinating form of shadow casting. Specifically, it's using a 3-dimensional dithering texture to generate shadows based on the alpha value of the texture/color casting the shadow.

In the shader, it looks something like:

 alphaRef = tex3D(_DitherMaskLOD, float3(input.pos.xy*0.25, alpha*0.9375)).a;

The texture consists of a black and white texture (all or nothing), ranging from completely unshadowed to shadowed (0-1) for its z-axis depth, then following dithering patterns to add more and more interwoven pixels to transition between colors across the x and y axes.

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 insominx · Jul 16, 2016 at 01:37 AM 1
Share

That's great background information. How would you suggest the poster solve the problem?

avatar image Eno-Khaon insominx · Jul 16, 2016 at 02:46 AM 0
Share

Unfortunately, doing something about it isn't as easy as identifying the cause.

Any change, as an example, to create a higher-resolution variation on the dithered shadow Texture3D (The texture is 4x4x8, or 4x32 in 2D) would generally involve creating a custom shader, but since the shadowing details are in a reference file for the Standard shader, that means rebuilding parts of the shader just to make a tiny change.

After making such a shader, it would then be necessary to construct the Texture3D (either programmatically or by converting a 2D image into a 3D texture. Then, the image would be sent into the shader using $$anonymous$$aterial.SetTexture() or Shader.SetGlobalTexture to act as a replacement dithering texture.

As an example, I implemented an 8x8x16 variant in my own shader (created as an 8x256 Texture2D) and used it with:

 alphaRef = tex3D(_HQDither, float3(input.pos.xy*0.125, alpha*0.96875)).a;

The position values for x, y, and z all needed to be modified to accommodate the new dimensions of the texture, as well.

That said, even then, this doesn't actually solve the "problem" in the shadow. The "problem" is one that's not easily solved... at least, not in a realtime engine... However, this does mitigate the symptoms greatly by increasing the granularity in the shadow dithering.

(I'll add an image here once Unity Answers decides to let me)

avatar image
0

Answer by bromley · Jul 16, 2016 at 05:57 AM

Here the material properties alt text

Bias adjustment "solve" the problem, but i think that i have to modify material properties


immagine.png (19.1 kB)
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 bromley · Jul 17, 2016 at 08:56 AM 0
Share

Thanks for answers... now i think that ShaderLab may be a good solution

avatar image
0

Answer by Glurth · Jul 16, 2016 at 01:25 PM

If you are willing to eliminate the shadow completely: You could put the glass on a layer that is ignored by the light (light's culling mask field). This way it won't cast any shadow (alas, NOR be lit normally).

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 Namey5 · Jul 16, 2016 at 01:29 PM 1
Share

You could also just disable shadow casting on the mesh renderer.

avatar image Glurth Namey5 · Jul 16, 2016 at 03:16 PM 0
Share

Well, if you want to be all efficient and stuff... ;) I want to delete my answer now, ok?

avatar image Namey5 Glurth · Jul 17, 2016 at 12:47 AM 0
Share

Haha, nah you're fine.

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

80 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

Related Questions

Custom Sprite Shader Ignore Light 1 Answer

Unity 3d Lights, Shadows and material of objects? 1 Answer

Odd shadow effect, help! 1 Answer

"Interesting" Shader 2 Answers

How to create light like in minecraft? 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