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 /
  • Help Room /
avatar image
0
Question by jesseparsons1 · Oct 15, 2016 at 08:13 PM · shadershadowsshader programmingcustom

How can I make this custom shader support shadows?

Daniel Zeller wrote this brilliant low poly shader: https://github.com/danielzeller/Lowpoly-Water-Unity (a sample project can be downloaded from that link), and I have been trying to have this shader additionally support shadows but to no avail. I have so far tried adding:

 Tags {"Queue"="Transparent" "LightMode" = "ForwardBase"}
 #pragma multi_compile_fwdadd_fullshadows
 #include "Lighting.cginc"
 #include "AutoLight.cginc"

in struct v2f {}:

  LIGHTING_COORDS(9,10)

in v2f vert() {}:

  TRANSFER_VERTEX_TO_FRAGMENT(o);

and in half4 frag() {}:

 float attenuation = LIGHT_ATTENUATION(i);

If anyone could please give me any help with this it would be much appreciated!

Thanks!

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 Namey5 · Oct 16, 2016 at 01:28 AM

Objects in the Transparent Queue (almost always) cannot receive shadows due to the way they are rendered. The only real way you could have a transparent object receive shadows would be to have it use a GrabPass, which is not guaranteed to work, be efficient or produce an outcome without problems of its own.

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 jesseparsons1 · Oct 16, 2016 at 08:03 PM 0
Share

Ah I see, thanks for your response!

avatar image jesseparsons1 · Oct 17, 2016 at 10:14 AM 0
Share

I have been trying to change this to be in a different Queue to transparent, and then add all of the shadow things, but it doesn't seem to work and I get strange results. How can I change the Queue and still have the shader function in the same way?

avatar image Namey5 jesseparsons1 · Oct 17, 2016 at 10:23 AM 1
Share

That's the thing, you really can't. Transparency will only work properly if rendered in a particular order, and due to the way Unity handles transparency and shadows you can't have faultless transparency and shadows without some trickery.

avatar image jesseparsons1 Namey5 · Oct 17, 2016 at 11:13 AM 0
Share

Right, I don't actually want the water to be transparent in any way, I'd prefer it to be opaque, so is there a way of doing this so that the water becomes opaque and it supports shadows?

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

95 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

Related Questions

Geometry shader double sided leaf, shadows projected on both sides. 0 Answers

Vert/frag shader not receiving shadow despite all relevant code being present 1 Answer

Add hard shadows to a Toon Shader 0 Answers

Shadows on alpha clipping/vertex offset shaders misaligned when using screen space texture 0 Answers

Among Us Masking (RGB) Question 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